当前位置:网站首页>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 .
边栏推荐
- Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
- /bin/ld: 找不到 -lssl
- 【LeetCode】1905-统计子岛屿
- lseek 出错
- For the problem that Folium map cannot be displayed, the temporary solution is as follows
- Fastjson list to jsonarray and jsonarray to list "suggested collections"
- [development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
- 全是精华的模电专题复习资料:基本放大电路知识点
- Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
- 6095. Strong password checker II
猜你喜欢

Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC

Aiko ai Frontier promotion (7.2)

The outline dimension function application of small motherboard

2022 college students in Liaoning Province mathematical modeling a, B, C questions (related papers and model program code online disk download)

Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit

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

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

《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究

树-二叉搜索树

【LeetCode】417-太平洋大西洋水流问题
随机推荐
Thoroughly understand browser strong cache and negotiation cache
2279. Maximum number of backpacks filled with stones
/Bin/ld: cannot find -lxslt
蚂蚁集团大规模图计算系统TuGraph通过国家级评测
Custom exception
(4) Flink's table API and SQL table schema
folium地图无法显示的问题,临时性解决方案如下
Aiko ai Frontier promotion (7.2)
Pyinstaller打包exe附带图片的方法
[leetcode] 977 - carré du tableau ordonné
Folium, diagnosis and close contact trajectory above
Target detection - make your own deep learning target detection data set with labelimg
[leetcode] 19 delete the penultimate node of the linked list
Ant group's large-scale map computing system tugraph passed the national evaluation
[2. Basics of Delphi grammar] 3 Object Pascal constants and variables
Name of institution approved in advance
【LeetCode】283-移动零
[leetcode] 876 intermediate node of linked list
已知兩種遍曆序列構造二叉樹
奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface