当前位置:网站首页>Postgressql stream replication active / standby switchover primary database no read / write downtime scenario
Postgressql stream replication active / standby switchover primary database no read / write downtime scenario
2022-07-02 15:47:00 【Six element】
Catalog
One Scenario introduction
PostgreSQL Stream replication primary and standby environments , There is no read / write in the main database , Database down , The original and standby databases are switched to the primary database , Switch from the original primary database to the standby database . The main database downtime methods are smart、fast、immediate, The main library downtime based on these three methods , How to switch between active and standby .
Two Based on the environment
Main library :192.168.5.128
For the library :192.168.5.129
3、 ... and Status check
1. Active / standby status check
pg_controldata -D /data/dbdata/pgsql/14/5432/data/
128:Database cluster state: in production
129:Database cluster state: in archive recovery
2. Stream replication synchronization check
select * from pg_stat_replication;
Four Active standby switching
1. Main library down
# 128 The host simulation database is closed
pg_ctl -D /data/dbdata/pgsql/14/5432/data stop -m smart
2. Active standby switching
# 129 The host switches to the main library
pg_ctl promote -D /data/dbdata/pgsql/14/5432/data
3. Adjust the original primary warehouse to standby warehouse
# 128 Switch the host to the standby database
touch /data/dbdata/pgsql/14/5432/data/standby.signal
echo "primary_conninfo = 'host=192.168.5.129 port=5432 user=repl password=repl'" >> /data/dbdata/pgsql/14/5432/data/postgresql.conf
pg_ctl -D /data/dbdata/pgsql/14/5432/data start
4. Active / standby status check
pg_controldata -D /data/dbdata/pgsql/14/5432/data/
128:Database cluster state: in archive recovery
129:Database cluster state: in production
5. Stream replication synchronization check
select * from pg_stat_replication;
6. data validation
# Now the main library 129 Update data
pgbench=# select * from t1 where id=1;
id | t | mod_time
----+------+----------
1 | test |
(1 row)
pgbench=# update t1 set t=' test 1' where id=1;
pgbench=# select * from t1 where id=1;
id | t | mod_time
----+-------+----------
1 | test 1 |
(1 row)
# Ready to use warehouse 128 Query data
pgbench=# select * from t1 where id=1;
id | t | mod_time
----+-------+----------
1 | test 1 |
(1 row)
7. result
After the active standby switch , The active and standby status is normal , Data update is normal .
8. Active / standby switchback
Just switch back according to the above steps
5、 ... and other
in addition , Main library fast and immediate Downtime mode , The main and standby switching mode is the same as .
边栏推荐
- Jsp+mysql006 community management system
- 2279. Maximum number of backpacks filled with stones
- How to use percona tool to add fields to MySQL table after interruption
- 【LeetCode】695-岛屿的最大面积
- (4) Flink's table API and SQL table schema
- Wise target detection 23 - pytoch builds SSD target detection platform
- [development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)
- matlab中wavedec2,说说wavedec2函数[通俗易懂]
- 提前批院校名称
- 【LeetCode】1905-统计子岛屿
猜你喜欢
【LeetCode】1905-统计子岛屿
[salesforce] how to confirm your salesforce version?
爱可可AI前沿推介(7.2)
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
【LeetCode】1254-统计封闭岛屿的数量
[experience cloud] how to get the metadata of experience cloud in vscode
Loss function and positive and negative sample allocation: Yolo series
使用 percona 工具给 MySQL 表加字段中断后该如何操作
Aiko ai Frontier promotion (7.2)
Two traversal sequences are known to construct binary trees
随机推荐
Two traversal sequences are known to construct binary trees
How to use percona tool to add fields to MySQL table after interruption
《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
C # get PLC information (kepserver) II
(4) Flink's table API and SQL table schema
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
6092. Replace elements in the array
Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
[leetcode] 167 - sum of two numbers II - enter an ordered array
/bin/ld: 找不到 -lssl
提前批院校名称
Redux - detailed explanation
beforeEach
SQL修改语句
[leetcode] 577 reverse word III in string
(5) Flink's table API and SQL update mode and Kafka connector case
/Bin/ld: cannot find -lcrypto
Name of institution approved in advance
[idea] recommend an idea translation plug-in: translation "suggestions collection"
Wise target detection 23 - pytoch builds SSD target detection platform