当前位置:网站首页>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 recovery2. 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 smart2. Active standby switching
# 129 The host switches to the main library
pg_ctl promote -D /data/dbdata/pgsql/14/5432/data3. 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 start4. 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 production5. 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 .
边栏推荐
- College entrance examination admission score line crawler
- [leetcode] 577 reverse word III in string
- [leetcode] 1020 number of enclaves
- Target detection - make your own deep learning target detection data set with labelimg
- 《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
- 【LeetCode】695-岛屿的最大面积
- The task cannot be submitted after the installation of flick is completed
- /bin/ld: 找不到 -lpam
- 【LeetCode】189-轮转数组
- 【idea】推荐一个idea翻译插件:Translation「建议收藏」
猜你喜欢

PostgresSQL 流复制 主备切换 主库无读写宕机场景

Redux - detailed explanation

【LeetCode】417-太平洋大西洋水流问题

【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData

Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
![[network security] network asset collection](/img/3e/6665b5af0dedfcbc7bd548cc486878.png)
[network security] network asset collection

Ant group's large-scale map computing system tugraph passed the national evaluation

Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)

树-二叉搜索树

2022 college students in Liaoning Province mathematical modeling a, B, C questions (related papers and model program code online disk download)
随机推荐
Floyed "suggestions collection"
愛可可AI前沿推介(7.2)
/Bin/ld: cannot find -lxml2
[leetcode] 167 - sum of two numbers II - enter an ordered array
【LeetCode】1140-石子游戏II
[leetcode] 1020 number of enclaves
数字藏品系统开发(程序开发)丨数字藏品3D建模经济模式系统开发源码
How to use percona tool to add fields to MySQL table after interruption
二叉树前,中,后序遍历
/Bin/ld: cannot find -lcrypto
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
6096. Success logarithm of spells and potions
Add an empty column to spark dataframe - add an empty column to spark dataframe
College entrance examination admission score line climbing
[leetcode] 200 number of islands
6095. 强密码检验器 II
How to intercept the value of a key from the JSON string returned by wechat?
【LeetCode】977-有序数组的平方
【idea】推荐一个idea翻译插件:Translation「建议收藏」
[2. Basics of Delphi grammar] 3 Object Pascal constants and variables