In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to achieve Postgresql stream replication active / standby switching", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to achieve Postgresql stream replication active / standby switching"!
-- operating system command to determine whether the sending process or the receiving process ps-ef | grep "wal" | grep-v "grep"-- data view select pid,usename,application_name,client_addr,state,sync_state from pg_stat_replication;--or slave library select pid,status,last_msg_send_time,last_msg_receipt_time,conninfo from pg_stat_wal_receiver;-- system function view select pg_is_in_recovery () -- Database control information pg_controldata | grep cluster-- view recovery.conf configuration file-- version before 9.0 trigger mode of master / slave switch file-- 1. Configure standby library file, add trigger_file parameter recovery.conftrigger_file='/pgdata/data/.postgresql.trigger.5432'--2, close main library pg_ctl stop-m fast--3, create trigger file, restart backup library Observe whether the recovery.conf becomes recovery.donetouch / pgdata/data/.postgresql.trigger.5432--4 and the old master library becomes the standby library-- edit the recovery.conf file recovery_target_timeline='latest'standby_mode=onprimary_conninfo='host=192.168.8.25 port=5432 user=repuser'-- password file cat .pgpass192.168.25: 5432:replication:repuser:re12a345192.168.8.81:5432:replication:repuser:re12a345chmod 0600 .pgpass-- switch the pg_ctl promote mode between the master and the slave-1, Close the main library pg_ctl stop-m fash--2, execute pg_ctl promote--3 for the standby library, switch the old master library to the standby library-- pg_rewind stream replication maintenance data synchronization tool-- when the standby library is activated as the master library If the old master library is not closed, then the old master library cannot be switched to a standby library and does not need to be re-backed up. Pg_rewind replication changes (incremental refresh synchronization)-- prerequisites can be met. 1. The wal_log_hints parameter in the postgresql.conf configuration file is set to on, and database 2 needs to be restarted.-- data-checksums is used during database installation, and io error is found. There is a loss in enabling performance-- node2 activation slave library-- node1 closes the slave library, and use pg_rewind incremental synchronization pg_rewind-- target-pgdata $PGDATA-- source-server='host=192.168.8.25 posrt=5432 user=postgres dbname=postgres'-P-- the above command is executed successfully The postgres user password will be written to ~ / .pgpass-- modify recovery.conf to start a new slave library-- delay the addition parameter of recovery.conf. Currently, it supports srecoverystarting minewriting application yearly delayflows 1min replication, delay parameter priority synchronous_commit=on recovery_min_apply_delay=1min # priority-remote_aplysynchronous_commit=remote_apply # main database operation blocked for 1 minute The result returned after the slave application is completed recovery_min_apply_delay=1min # priority-synchronous replication is preferably submitted with one master and two slaves. Note that when there is a downtime in the synchronous library, the primary database will block synchronous_standby_names=db1,db2 # the first slave library list is synchronous slave library, and the second potential synchronous slave library synchronous_standby_names='FIRST 2 (db1,db2,db3)'# the first two are synchronous slave library The third is the potential synchronization repository synchronous_standby_names='ANY 2 (db1,db2,db3)'# any two are the synchronization repository, and the other are the potential synchronization repository-cascade replication a > b > Cmure 1, asynchronous flow replication, deployment standby library b, replication is normal Start deploying the standby library C, execute-h apg_basebackup-D / pgdata/data-Fp-Xs-v-P-h 192.168.28.74-p 5432-U repuser--2, configure c recovery.conf file, host brecovery_target_timeline='latest'standby_mode=onprimary_conninfo='host=192.168.8.25 port=5432 user=repuser application_name=c'--3, start c so far, I believe you have a deeper understanding of "how to achieve Postgresql stream replication master / slave switch" You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.