问题1: checking for dtrace... no configure: error: dtrace not found 解决方法: yum install -y systemtap-sdt-devel.x86_64 问题2: checking for flags to link embedded Perl... Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .). BEGIN failed--compilation aborted. no configure: error: could not determine flags for linking embedded Perl. This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not installed. 解决方法: yum install perl-ExtUtils-Embed -y 问题3: checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking which template to use... linux checking whether NLS is wanted... no checking for default port number... 5432 checking for dtrace... /usr/bin/dtrace checking for block size... 16kB checking for segment size... 1GB checking for WAL block size... 16kB checking for gcc... no checking for cc... no configure: error: in `/var/soft/postgresql': configure: error: no acceptable C compiler found in $PATH 解决方法: yum install gcc 问题4: configure: error: readline library not found If you have readline already installed, see config.log for details on the failure. It is possible the compiler isn't looking in the proper directory. Use --without-readline to disable readline support. 解决方法: yum install readline readline-devel 问题5: checking for inflate in -lz... no configure: error: zlib library not found If you have zlib already installed, see config.log for details on the failure. It is possible the compiler isn't looking in the proper directory. Use --without-zlib to disable zlib support. 解决方法: yum install zlib zlib-devel 问题6: checking for CRYPTO_new_ex_data in -lcrypto... no configure: error: library 'crypto' is required for OpenSSL 解决方法: yum install openssl openssl-devel 问题7: checking for pam_start in -lpam... no configure: error: library 'pam' is required for PAM 解决方法: yum install pam pam-devel 问题8: checking for xmlSaveToBuffer in -lxml2... no configure: error: library 'xml2' (version >= 2.6.23) is required for XML support 解决方法: yum install libxml2 libxml2-devel 问题9: checking for xsltCleanupGlobals in -lxslt... no configure: error: library 'xslt' is required for XSLT support 解决方法: yum install libxslt libxslt-devel 问题10: configure: error: Tcl shell not found 解决方法: yum install tcl tcl-devel 问题11: checking for ldap.h... no configure: error: header file is required for LDAP 解决方法: yum install openldap openldap-devel 问题12: checking for Python.h... no configure: error: header file is required for Python 解决方法: yum install python python-devel
[root@db01 postgresql]# su - postgres Last login: Sun Aug 30 22:11:36 CST 2020 on pts/2 [postgres@db01 ~]$ initdb 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 /data/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 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:
pg_ctl -D /data/pgsql/data -l logfile start
2.9 修改pg_hba.conf文件(主库操作)
1 2 3 4 5 6 7 8
local all all trust # IPv4 local connections: host all all 0.0.0.0/0 md5 # IPv6 local connections: # Allow replication connections from localhost, by a user with the # replication privilege. local replication all trust host replication all 192.168.137.0/24 trust
2.10 修改修改postgresql.conf配置文件(主库操作)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
archive_mode = on archive_command = 'cp "%p" "/data/pgsql/data/arch/%f"' max_wal_senders = 10 max_replication_slots = 10 wal_level = logical hot_standby = on wal_log_hints = on synchronous_commit = on synchronous_standby_names = 'walreceiver' logging_collector = on log_filename = 'postgresql-%a.log' log_truncate_on_rotation = on log_rotation_age = 1d log_rotation_size = 0
2.11 启动数据库(主库操作)
1 2 3 4 5 6 7 8 9 10 11 12
[postgres@db02 ~]$ pg_ctl -D /data/pgsql/data start [postgres@db02 ~]$ psql postgres=# CREATE ROLE pgpool WITH LOGIN; postgres=# CREATE ROLE repl WITH REPLICATION LOGIN; postgres=# \password pgpool postgres=# \password repl postgres=# \password postgres # pgpool_status中显示 postgres=# GRANT pg_monitor TO pgpool; # 查看结果 replication_state postgres=# \du postgres=# exit
2.12 备库删除data(备库操作)
1
rm -rf /data/pgsql/data
2.13 备端基础备份(备库操作)
1 2
[postgres@db02 ~]$ cd /data/pgsql/ [postgres@db02 ~]$ pg_basebackup -h 192.168.137.129 -U repl -Xs -Fp -R -Pv -D data