主库:172.30.78.7
#依赖包
[root@ycdbtools]# ll
total 1052
-rw-r--r--. 1 root root 729508 Sep 7 2017 ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm
-rw-r--r--. 1 root root 197696 Aug 23 2019 readline-6.2-11.el7.x86_64.rpm
-rw-r--r--. 1 root root 141864 Aug 23 2019 readline-devel-6.2-11.el7.x86_64.rpm
#创建用户
[root@ycdb/]# groupadd -g 10000 postgres
[root@ycdb/]# useradd -m -u 10001 -g postgres -d /home/postgres -s /bin/bash postgres
[root@ycdb/]# passwd postgres
#创建软件目录
[root@ycdb/]# mkdir pg12.2
#服务存在6.2.10版本的,所以安装报错,升级一下readline
[root@ycdb/]# rpm -ivh readline-6.2-11.el7.x86_64.rpm
warning: readline-6.2-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
file /lib64/libreadline.so.6.2 from install of readline-6.2-11.el7.x86_64 conflicts with file from package readline-6.2-10.el7.x86_64
file /usr/lib64/libhistory.so.6.2 from install of readline-6.2-11.el7.x86_64 conflicts with file from package readline-6.2-10.el7.x86_64
#升级readline(readline只要用于命令行的自动补齐功能,还是很用帮助的,当然你不用也可以)
[root@ycdb/]# rpm -Uvh readline-6.2-11.el7.x86_64.rpm
warning: readline-6.2-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:readline-6.2-11.el7 ################################# [ 50%]
Cleaning up / removing...
2:readline-6.2-10.el7 ################################# [100%]
[root@dbserver /]# rpm -Uvh readline-devel-6.2-11.el7.x86_64.rpm
warning: readline-devel-6.2-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:readline-devel-6.2-11.el7 ################################# [100%]
#准备安装
[root@ycdb/]# cd postgresql-12.2/
[root@ycdb postgresql-12.2]# ./configure --prefix=/pg12.2
.................
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: src/interfaces/ecpg/include/ecpg_config.h is unchanged
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
#使用make world将contrib目录下的扩展工具一起编译
[root@dbserver postgresql-12.2]# make world
.......
PostgreSQL, contrib, and documentation successfully made. Ready to install.
#安装
[root@ycdb postgresql-12.2]# make install-world
.......
PostgreSQL, contrib, and documentation installation complete
#在此目录下创建data目录
[root@ycdb postgresql-12.2]# cd /pg12.2/
[root@ycdb pg12.2]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 30 16:08 bin
drwxr-xr-x. 4 root root 4096 Sep 30 16:08 include
drwxr-xr-x. 4 root root 4096 Sep 30 16:08 lib
drwxr-xr-x. 5 root root 46 Sep 30 16:08 share
#创建
[root@ycdb pg12.2]# mkdir data
[root@ycdb pg12.2]# chown postgres:postgres ./data
#切换到postgres
[root@dbserver pg12.2]# su - postgres
#初始化数据库
[postgres@ycdb~]$ /pg12.2/bin/initdb -D /pg12.2/data/
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... PRC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
#配置环境变量
[postgres@ycdb ~]$ vi .bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/pg12.2/bin
export PGHOME=/pg12.2
export PGDATA=/pg12.2/data
export PATH
#启动postgres
[postgres@ycdb~]$ pg_ctl -D /pg12.2/data/ start
#OK启动成功
[postgres@ycdb ~]$ psql
psql (12.2)
Type "help" for help.
postgres=#