前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >源码安装PostgreSQL 10.3

源码安装PostgreSQL 10.3

作者头像
用户8196625
发布2023-09-06 15:32:43
1570
发布2023-09-06 15:32:43
举报
文章被收录于专栏:oracleaceoracleace

使用源码编译PostgreSQL 10.3全过程。

服务器环境

代码语言:javascript
复制
root@YaoYuan ~# cat /etc/*release
Oracle Linux Server release 7.9
NAME="Oracle Linux Server"
VERSION="7.9"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Oracle Linux Server 7.9"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:9:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.9
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.9
Red Hat Enterprise Linux Server release 7.9 (Maipo)
Oracle Linux Server release 7.9
root@YaoYuan ~# uname -a
Linux dell.scutech 4.14.35-2047.505.4.3.el7uek.x86_64 #2 SMP Wed Jul 21 14:02:03 PDT 2021 x86_64 x86_64 x86_64 GNU/Linux

下面源码

代码语言:javascript
复制
 wget --no-check-certificate https://ftp.postgresql.org/pub/source/v15.3/postgresql-15.3.tar.bz2
 tar xf postgresql-15.3.tar.bz2

这样在当前目录下展开了PostgreSQL的源程序

代码语言:javascript
复制
$ ll postgresql-15.3
总用量 780
-rw-r--r--.  1 oracle oinstall    397 5月   9 05:13 aclocal.m4
drwxr-xr-x.  2 oracle oinstall   4096 5月   9 05:25 config
-rwxr-xr-x.  1 oracle oinstall 601977 5月   9 05:13 configure
-rw-r--r--.  1 oracle oinstall  89369 5月   9 05:13 configure.ac
drwxr-xr-x. 61 oracle oinstall   4096 5月   9 05:24 contrib
-rw-r--r--.  1 oracle oinstall   1192 5月   9 05:13 COPYRIGHT
drwxr-xr-x.  3 oracle oinstall     87 5月   9 05:25 doc
-rw-r--r--.  1 oracle oinstall   4264 5月   9 05:13 GNUmakefile.in
-rw-r--r--.  1 oracle oinstall    277 5月   9 05:13 HISTORY
-rw-r--r--.  1 oracle oinstall  63842 5月   9 05:26 INSTALL
-rw-r--r--.  1 oracle oinstall   1875 5月   9 05:13 Makefile
-rw-r--r--.  1 oracle oinstall   1213 5月   9 05:13 README
drwxr-xr-x. 16 oracle oinstall   4096 5月   9 05:26 src

编译安装

代码语言:javascript
复制
./configure
make world
sudo make install-world
...
parallel group (2 tests):  event_trigger oidjoins
     event_trigger                ... ok          111 ms
     oidjoins                     ... ok          200 ms
test fast_default                 ... ok          130 ms
============== shutting down postmaster               ==============
============== removing temporary instance            ==============

=======================
 All 212 tests passed.
=======================

make[1]: 离开目录“/home/oracle/postgresql-15.3/src/test/regress”
oracle@YaoYuan postgresql-15.3$ sudo make install-world

make world用时4分钟多。

在/etc/profile中增加如下内容,这样每个用户登录的时候都会执行

代码语言:javascript
复制
LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH
MANPATH=/usr/local/pgsql/share/man:$MANPATH
export MANPATH
PATH=/usr/local/pgsql/bin:$PATH
export PATH
export PGDATA=/usr/local/pgsql/data

创建用户

代码语言:javascript
复制
adduser postgres

初始化数据库

代码语言:javascript
复制
root@YaoYuan ~# mkdir -p /usr/local/pgsql/data
root@YaoYuan ~# chown postgres /usr/local/pgsql/data
root@YaoYuan ~# su - postgres
上一次登录:四 7月 27 18:41:37 CST 2023pts/0 上
-bash-4.2$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

-bash-4.2$

启动数据库

代码语言:javascript
复制
-bash-4.2$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
waiting for server to start.... done
server started
-bash-4.2$ /usr/local/pgsql/bin/createdb test
-bash-4.2$ /usr/local/pgsql/bin/psql test
psql (15.3)
Type "help" for help.

test=#
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2023-08-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 oracleace 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档