PostgreSQL 10(8) 마스터 스트리밍 복제
3441 단어 PostgreSQL
#
mkdir -p /data/postgres/v10.10
groupadd postgres && useradd -m -d /data/postgres/home -g postgres postgres
mkdir -p /data/pgbackup/{6401,6402}/archive
cd /data/postgres/home
wget https://ftp.postgresql.org/pub/source/v10.10/postgresql-10.10.tar.gz
tar -zxvf postgresql-10.10.tar.gz -C /data/postgres/v10.10 --strip-components 1
cd /data/postgres/v10.10
./configure --prefix=/data/postgres/v10.10
make && make install
chown -R postgres:postgres /data/postgres
su postgres
echo 'export PATH=$PATH:/data/postgres/v10.10/bin' >> ~/.bashrc
source ~/.bashrc
# Master
initdb -D /data/pg6401
# Master
mv /data/pg6401/postgresql.conf /data/pg6401/postgresql.conf.bak
cat << EOF > /data/pg6401/postgresql.conf
port = 6401
listen_addresses = '*'
cluster_name = 'kkcluster'
hot_standby = on
max_wal_senders = 10
wal_keep_segments = 64
wal_level = replica
archive_mode = on
archive_timeout = 86400
archive_command = 'test ! -f /data/pgbackup/6401/archive/%f && cp %p /data/pgbackup/6401/archive/%f'
EOF
# Master
cat << EOF > /data/pg6401/recovery.done
standby_mode = 'on'
recovery_target_timeline = 'latest'
primary_conninfo = 'application_name=slave port=6402 user=replica password=replica sslmode=disable sslcompression=1 target_session_attrs=any'
restore_command = 'cp /data/pgbackup/6401/archive/%f %p'
archive_cleanup_command = '/data/postgres/v10.10/bin/pg_archivecleanup /data/pgbackup/6401/archive %r'
EOF
# Master
echo "host all all 0.0.0.0/0 md5" >> /data/pg6401/pg_hba.conf
# Master
pg_ctl -D /data/pg6401 -l /data/pg6401/logfile.log start
# Master
psql -p 6401 -c "CREATE ROLE replica login replication encrypted PASSWORD 'replica';"
# Standby Master
mkdir -p /data/pg6402 && chown postgres:postgres /data/pg6402
pg_basebackup -F p -X stream -v -P -R -D /data/pg6402 -p 6401 -U replica -W
chmod -R 700 /data/pg6402
# Standby
mv -f /data/pg6402/recovery.done /data/pg6402/recovery.conf
sed -i "s/6401/6402/g;s/port=6402/port=6401/g" /data/pg6402/recovery.conf
sed -i "s/6401/6402/g" /data/pg6402/postgresql.conf
# Standby
pg_ctl -D /data/pg6402 -l /data/pg6402/logfile.log start
# Master && Standby
psql -p 6401 -c "select * from pg_stat_replication;"
psql -p 6402 -c "select * from pg_stat_replication;"
# Master && Standby /
ps -aef | grep -E 'sender|receiver'
# Master && Standby
pg_controldata -D /data/pg6401 | grep -E 'cluster|checkpoint'
pg_controldata -D /data/pg6402 | grep -E 'cluster|checkpoint'
#
psql -p 6401 -c "checkpoint;"
psql -p 6401 -c "select pg_switch_wal();"
psql -p 6401 -c "checkpoint;"
pg_ctl -D /data/pg6401 -l /data/pg6401/logfile.log stop
pg_ctl -D /data/pg6402 promote
mv -f /data/pg6401/recovery.done /data/pg6401/recovery.conf
pg_ctl -D /data/pg6401 -l /data/pg6401/logfile.log start
#
psql -p 6402 -c "checkpoint;"
psql -p 6402 -c "select pg_switch_wal();"
psql -p 6402 -c "checkpoint;"
pg_ctl -D /data/pg6402 -l /data/pg6402/logfile.log stop
pg_ctl -D /data/pg6401 promote
mv -f /data/pg6402/recovery.done /data/pg6402/recovery.conf
pg_ctl -D /data/pg6402 -l /data/pg6402/logfile.log start
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Redmine 데이터베이스를 MySQL에서 PostgreSQL로 마이그레이션 (보충)Redmine 의 Database 를 MySQL 로 운용하고 있었습니다만, MySQL 5.6 이상이나 MariaDB 에는 , , 이러한 티켓이 수년 동안 방치된 상황을 감안하여, PostgreSQL로 마이그레이션하기...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.