当前位置:网站首页>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 .
边栏推荐
- ssh/scp 使不提示 All activities are monitored and reported.
- Golang MD5 encryption and MD5 salt value encryption
- /Bin/ld: cannot find -lcrypto
- 【LeetCode】1254-统计封闭岛屿的数量
- 树-二叉搜索树
- Wavedec2 in MATLAB, talk about the wavedec2 function [easy to understand]
- Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
- [leetcode] 577 reverse word III in string
- [leetcode] 167 - sum of two numbers II - enter an ordered array
- 全是精华的模电专题复习资料:基本放大电路知识点
猜你喜欢
《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量
【LeetCode】1162-地图分析
Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
PostgresSQL 流复制 主备切换 主库无读写宕机场景
The outline dimension function application of small motherboard
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
Wechat Alipay account system and payment interface business process
动态规划入门一,队列的bfs(70.121.279.200)
Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
爱可可AI前沿推介(7.2)
随机推荐
2278. Percentage of letters in string
[leetcode] 977 square of ordered array
beforeEach
已知两种遍历序列构造二叉树
【LeetCode】877-石子游戏
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
/bin/ld: 找不到 -lssl
[leetcode] 977 - carré du tableau ordonné
/Bin/ld: cannot find -lxslt
Deux séquences ergodiques connues pour construire des arbres binaires
Some problems about pytorch extension
使用FFmpeg命令行进行UDP、RTP推流(H264、TS),ffplay接收
Target detection - make your own deep learning target detection data set with labelimg
Digital collection system development (program development) - Digital Collection 3D modeling economic model system development source code
6092. Replace elements in the array
【LeetCode】977-有序數組的平方
[network security] network asset collection
[leetcode] 1162 map analysis
fastjson List转JSONArray以及JSONArray转List「建议收藏」