赞
踩
主机ip:10.0.2.5
从机ip:10.0.2.6
rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm
rpm -ivh libzstd-1.5.5-1.el7.x86_64.rpm
rpm -ivh postgresql15-libs-15.4-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql15-15.4-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql15-server-15.4-1PGDG.rhel7.x86_64.rpm
[root@localhost ~]# su postgres
bash-4.2$ cd /usr/pgsql-15/bin/ bash-4.2$
./initdb -D /var/lib/pgsql/15/data/
bash-4.2$ exit
exit
[root@localhost ~]# vi /var/lib/pgsql/15/data/postgresql.conf
listen_addresses = '*'
wal_level = replica
[root@localhost ~]# vi /var/lib/pgsql/15/data/pg_hba.conf
host replication repl 10.0.2.6/32 md5
host all all 0.0.0.0/0 md5
[root@localhost ~]# systemctl enable postgresql-15 && systemctl restart postgresql-15
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-15.service to /usr/lib/systemd/system/postgresql-15.service.
[root@localhost ~]# su - postgres
-bash-4.2$ psql
postgres=# create user repl login replication encrypted password ‘repl’;
CREATE ROLE
postgres=# exit
-bash-4.2$ exit
[root@localhost ~]# pg_basebackup -h 10.0.2.5 -p 5432 -U repl -Xs -v -Fp -P -R -D /var/lib/pgsql/15/data
[root@localhost ~]# chown -R postgres:postgres /var/lib/pgsql/15/data
[root@localhost ~]# systemctl start postgresql-15
[root@localhost ~]# su postgres
bash-4.2$ psql
postgres=# select pid,state,client_addr,sync_priority,sync_state,sent_lsn,write_lsn from pg_stat_replication;
pid | state | client_addr | sync_priority | sync_state | sent_lsn | write_lsn
------±----------±------------±--------------±-----------±----------±----------
2020 | streaming | 10.0.2.6 | 0 | async | 0/4000148 | 0/4000148
(1 row)
[root@localhost ~]# su postgres
bash-4.2$ psql
postgres=# select pid,status,sender_host,sender_port from pg_stat_wal_receiver;
pid | status | sender_host | sender_port
------±----------±------------±------------
4025 | streaming | 10.0.2.5 | 5432
(1 row)
[root@localhost ~]# systemctl status postgresql-15
[root@localhost ~]# su postgres
bash-4.2$ psql -U postgres
postgres=# ALTER USER postgres with encrypted password ‘Aa@123456’;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。