暂无图片
如何解除postgresql的主从关系
我来答
分享
Asky
2022-10-20
如何解除postgresql的主从关系

我想解除pg的主从关系,把从库停掉了,但是主库还有相关的进程,请问如何彻底解除主从关系呢。


[postgres@host134 data]$ ps -ef|grep postgres

postgres 31074 31073 0 08:58 ? 00:00:00 postgres: logger
postgres 31076 31073 0 08:58 ? 00:00:00 postgres: checkpointer
postgres 31077 31073 0 08:58 ? 00:00:00 postgres: background writer
postgres 31078 31073 0 08:58 ? 00:00:00 postgres: walwriter
postgres 31079 31073 0 08:58 ? 00:00:00 postgres: autovacuum launcher
postgres 31080 31073 0 08:58 ? 00:00:00 postgres: archiver
postgres 31081 31073 0 08:58 ? 00:00:00 postgres: stats collector
postgres 31082 31073 0 08:58 ? 00:00:00 postgres: logical replication launcher
postgres 32049 26601 0 09:01 pts/0 00:00:00 psql -h 192.168.1.134 -U postgres
postgres 32055 31073 0 09:01 ? 00:00:00 postgres: postgres postgres 192.168.1.134(41616) idle

我来答
添加附件
收藏
分享
问题补充
6条回答
默认
最新
阎书利

你加粗的两个进程
1.这个postgres: logical replication launcher进程是逻辑复制使用的,在发布实例和订阅实例都存在。主要的作用就是启动逻辑复制工作进程,如果你原来主备是流复制的主从的话,那这个进程和你解除主备没关系,而且流复制主库向备库发送wal日志的wal sender进程也不存在。如果你实在看这个进程不顺眼,把max_logical_replication_workers改成0,然后重启,这个进程就没了,但是没有什么必要。

2.这个idle的进程是连接到主库的进程,就是你psql -h连进来了,啥也没干,也没退出的。我这就是个单机环境的。你看最后一行不也就是你这样的进程么。
image.png

[xmaster@mogdb-kernel-0005 ~]$ ps -ef| grep xmaster 
root       37701   37676  0 Oct08 pts/0    00:00:00 su - xmaster
xmaster    37702   37701  0 Oct08 pts/0    00:33:23 -bash
root       38341   38313  0 Oct08 pts/1    00:00:00 su - xmaster
xmaster    38342   38341  0 Oct08 pts/1    01:30:03 -bash
xmaster    38501       1  0 Oct08 pts/5    01:07:09 -bash
xmaster   347665       1  0 17:16 ?        00:00:00 /opt/ysl_pg14/soft/bin/postgres
xmaster   347666  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: logger 
xmaster   347668  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: checkpointer 
xmaster   347669  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: background writer 
xmaster   347670  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: walwriter 
xmaster   347671  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: autovacuum launcher 
xmaster   347672  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: stats collector 
xmaster   347673  347665  0 17:16 ?        00:00:00 postgres: enmo_6001: logical replication launcher 
xmaster   355186       1  0 20:16 pts/2    00:00:00 -bash
xmaster   359058  355186  0 21:45 pts/2    00:00:00 psql -h 172.16.0.176 -U puser
xmaster   359064  347665  0 21:45 ?        00:00:00 postgres: enmo_6001: puser postgres 172.16.0.176(58746) idle

复制

我多连几个psql,它就有好几个了
image.png

暂无图片 评论
暂无图片 有用 0
打赏 0
暂无图片
李宏达

把replication的参数停掉

暂无图片 评论
暂无图片 有用 0
打赏 0
游湖

replication参数停掉。或者hba参数文件里面去掉replication

暂无图片 评论
暂无图片 有用 0
打赏 0
Asky
题主
2022-10-21
请问具体是那个参数呢?
游湖

hba参数文件里面去掉replication 那一行

暂无图片 评论
暂无图片 有用 0
打赏 0
游湖

pg_hba.conf

 replication   replication all 。。。。。             0.0.0.0/0 md5

暂无图片 评论
暂无图片 有用 0
打赏 0
游湖

recovery.signal 从库的这个文件中参数注释掉

standby_mode=on


primary_conninfo

暂无图片 评论
暂无图片 有用 0
打赏 0
Asky
题主
2022-10-21
我的从库已经停掉了的,不打算启动的,但是主库会还有postgres: postgres postgres 192.168.1.134(41616) idle 这样的进程
回答交流
Markdown


请输入正文
提交