postgresql从库提升为主库
一、停主库
1、查看当前连接
select pid,datname,usename,client_addr,client_port, application_name from pg_stat_activity;
2、杀死当前账户连接
select pg_terminate_backend(pid) from pg_stat_activity where usename=‘postgres‘ ;
3、停止主库服务
pg_ctl stop -m fast -D /usr/local/postgresql/data
4、从库激活为主库
pg_ctl promote -D /usr/local/postgresql/data
5、检查从库是否提升为主库成功
pg_controldata -D /usr/local/postgresql/data | grep cluster
Database cluster state: in production -- 说明: 如果值为 "in production" 说明是主库,如果值为 "in archive recovery" 说明是从库
参考:https://blog.51cto.com/lee90/2097494
相关推荐
WanKaShing 2020-11-12
zhbvictor 2020-10-29
kls00 2020-10-15
89921334 2020-07-29
83911930 2020-07-28
89407707 2020-06-27
89921334 2020-06-26
89244553 2020-06-21
84593973 2020-06-21
83911930 2020-06-16
yaoding 2020-06-14
89244553 2020-06-11
89407707 2020-06-11
89921334 2020-06-10
89407707 2020-06-10
goodriver 2020-06-09
kevinli 2020-06-06
84593973 2020-06-05