煙...
5 master れ #
.conf 殊 襴襦 企
#locate pg_hba.conf
#/var/lib/pgsql/9.4/data/pg_hba.conf
cd /var/lib/pgsql/9.4/data/
pg_hba.conf殊 replication 覯ip 焔
{{
vi pg_hba.conf
}}}
host replication postgres 192.168.56.102/32 trust
host replication postgres 192.168.56.103/32 trust
host all all 192.168.56.101/32 trust
host all all 192.168.56.1/32 trust
postgesql.conf
vi postgresql.conf
wal_level=host_standby #archive襦 れ覃 slave 蠏殊
max_wal_senders=10 #multi slave node れ
listen_addresses = '*'
archive_mode = on
archive_command = 'cp %p /var/lib/pgsql/9.4/ARCHIVE/%f'
# synchronous_standby_names = 'slave1' # 蠍磯逢朱 覲旧 蟆曙
archive 襦蠏 襴
mkdir /var/lib/pgsql/9.4/ARCHIVE
蟠 覲蟆
chown -R postgres.postgres /var/lib/pgsql
postgresql restart
su - postgres
cd /usr/pgsql-9.4/bin
./pg_ctl -D /var/lib/pgsql/9.4/data stop -m fast
./pg_ctl start -l /var/lib/pgsql/9.4/data/pg_log/postgres.log -D /var/lib/pgsql/9.4/data
or
systemctl restart postgresql-9.4
systemctl stop postgresql-9.4
6 slave れ #
master 覲旧
cd /
systemctl stop postgresql-9.4
mv /var/lib/pgsql/9.4/data /var/lib/pgsql/9.4/data_old
su - postgres
pg_basebackup -h 192.168.56.102 -p 5432 -U postgres -D /var/lib/pgsql/9.4/data --xlog --checkpoint=fast --progress
ls /var/lib/pgsql/9.4/data
exit
postgesql.conf
cd /var/lib/pgsql/9.4/data/
vi postgresql.conf
wal_level = minimal
hot_standby = on
#archive_mode = on
#archive_command = 'cp %p /var/lib/pgsql/9.4/ARCHIVE/%f'
recovery.conf
cd /var/lib/pgsql/9.4/data/
vi recovery.conf
restore_command = 'cp /var/lib/pgsql/9.4/ARCHIVE/%f %p'
archive_cleanup_command = 'pg_archivecleanup /var/lib/pgsql/9.4/ARCHIVE/ %r'
recovery_target_timeline = 'latest'
standby_mode = on
primary_conninfo = 'host=192.168.56.102 port=5432'
#application_name=slave1' # 蠍磯逢朱 覲旧 蟆曙
蟠 覲蟆
chown -R postgres.postgres /var/lib/pgsql
postgresql restart
systemctl restart postgresql-9.4