暂无图片
如何解除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


请输入正文
提交
相关推荐
pg如何查看wal文件的物理路径?
回答 2
参数logdirectory决定了pgwal日志存放的目录名字,默认为log;不过这个是相对目录,相对于$PGDATA,$PGDATA目录可以查看参数datadirectory
postgreSQL 12为什么没自动清理wal日志?已经自动归档了,但是wal日志没自动删除
回答 1
已采纳
WAL文件积压大多数情况都与复制槽有关,请检查所有database下的复制槽,是否有不使用的。另外就是空闲长事务、两阶段提交事务也会引起。
postgresql能不能在流复制从库上建逻辑复制同步几张表到另外一个库?
回答 2
已采纳
其实没理解的你的意思。我们一般都是一主两从。其中第二个从有延迟复制的功能。这样等于在2个从库。总体来说效果和你的说差不多。第二个从和第一个从数据差不多。之所以要延迟是为了防止误操作。如果不为了这个。那
现在postgresql最普遍的高可用方案是什么?
回答 4
已采纳
国外有一本专门介绍PG高可用的书籍,上面有这几种方案:patroni、repmgr、pgpoolII
pg中查看某个字段的不同值?哪个系统表的那个字段来标识
回答 1
pgstats.ndistinct
pg_ctl reload的问题
回答 2
只是加载配置文件,不影响实例。使用“pgctlreload”命令或直接调用函数“pgreloadconf()”时,其本质都是发送SIGHUP命令给服务主进程。
一般公司大项目用postgresql多吗?
回答 1
这个分布式数据库用的非常多,
pg中有类似mysql中的各种组提交的机制吗??
回答 1
commitdelay和commitsiblings
如何把oracle 的游标转成postgresql的?
回答 1
已采纳
PL/pgSQL—SQLProceduralLanguage
sqlsrever不用维护吗?
回答 7
用维护,而且我感觉维护起来比mysql和pg难。只不过国内用的少