当前位置:网站首页>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 .
边栏推荐
- 【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
- [leetcode] 977 square of ordered array
- Jsp+mysql006 community management system
- 已知两种遍历序列构造二叉树
- [leetcode] 1254 - count the number of closed Islands
- 6091. Divide the array so that the maximum difference is K
- 2278. Percentage of letters in string
- 《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
- Moveit obstacle avoidance path planning demo
- 6095. Strong password checker II
猜你喜欢

Custom exception

使用 percona 工具给 MySQL 表加字段中断后该如何操作

树-二叉搜索树

PTA 天梯赛习题集 L2-001 城市间紧急救援

Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics

Aike AI frontier promotion (7.2)

《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量

Why does the system convert the temp environment variable to a short file name?

XPT2046 四线电阻式触摸屏

Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
随机推荐
Fastjson list to jsonarray and jsonarray to list "suggested collections"
[leetcode] 695 - maximum area of the island
/Bin/ld: cannot find -lxslt
folium地图无法显示的问题,临时性解决方案如下
2279. 装满石头的背包的最大数量
Xpt2046 four wire resistive touch screen
Pyinstaller打包exe附带图片的方法
College entrance examination admission score line crawler
【idea】推荐一个idea翻译插件:Translation「建议收藏」
[leetcode] 1254 - count the number of closed Islands
SQL修改语句
College entrance examination score line climbing
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)
使用FFmpeg命令行进行UDP、RTP推流(H264、TS),ffplay接收
【LeetCode】1254-统计封闭岛屿的数量
How to use percona tool to add fields to MySQL table after interruption
The task cannot be submitted after the installation of flick is completed
Some problems about pytorch extension
locate: 无法执行 stat () `/var/lib/mlocate/mlocate.db‘: 没有那个文件或目录
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit