ThingWorx 고가용성 > Pgpool-II와 함께 PostgreSQL HA 배포 예제 > 5. node1로 스트리밍 복제를 위해 데이터베이스 구성
5. node1로 스트리밍 복제를 위해 데이터베이스 구성
/db/node0archive, /db/node1archive/db/node2archive 폴더가 작성되고 세 노드 간에 공유되었는지 확인합니다.
단계 1
사용자 복제기 만들기(node0과 동일한 작업)
단계 2
행 #10을 제외하고 동일한 node0에 대한 postgres.conf 매개 변수을 사용하도록 node1의 postgres.conf를 편집합니다. 행 #10은 대신 다음 값을 가져야 합니다.
매개 변수
노드
10
synchronous_standby_names
'node0,node2'
단계 3
node1은 node0과 동일한 start_replication.sh를 가져야 합니다.
start_replication.sh 스크립트는 node1 및 node2에서 복제 프로세스를 시작하는 데 사용됩니다.
* 
node1 및 node2에서만 start_replication.sh 스크립트를 실행합니다.
단계 4
node1에 대해 Master.sh 스크립트의 대상을 변경합니다.
retargetMaster.sh 스크립트를 만듭니다.
vim /db/bin/retargetMaster.sh
다음 콘텐츠를 사용합니다(node0 버전과는 약간 다름).
#!/bin/bash -x
NEW_MASTER_HOSTNAME=$1
NEW_ARCHIVE_FOLDER=$2
if grep -q "$1" /db/postgres/recovery.conf
then
echo $1 is current target,server does not need a restart, done!
else
#service postgresql stop
/usr/pgsql-10.x/bin/pg_ctl -D /db/postgres stop -m fast
#/db/bin/start_replication.sh $NEW_MASTER_HOSTNAME
# Write out new recovery.conf file
rm /db/postgres/recovery.conf
echo "standby_mode = 'on'" >> /db/postgres/recovery.conf
echo "primary_conninfo = 'port=5432 host=$NEW_MASTER_HOSTNAME user=replicator password=trUf6yuz2?_Gub sslmode=disable sslcompression=1 application_name=node1'" >> /db/postgres/recovery.conf
echo "trigger_file='/db/trigger'" >> /db/postgres/recovery.conf
echo "restore_command = 'cp -f $NEW_ARCHIVE_FOLDER/%f %p>/db/postgres/recovery.conf
echo "archive_cleanup_command = '/usr/bin/pg_archivecleanup $NEW_ARCHIVE_FOLDER %r>/db/postgres/recovery.conf
echo "recovery_target_timeline = 'latest'" >> /db/postgres/recovery.conf
/usr/pgsql-10.x/bin/pg_ctl -D /db/postgres -l /db/postgres.log start
echo target is $1 now
fi
그런 다음 스크립트 실행 파일을 만듭니다.
chmod a+x /db/bin/start_replication.sh
chmod a+x /db/bin/reargetMaster.sh
단계 5
Update pg_hba.conf(node0과 동일한 작업).
도움이 되셨나요?