postgresql之同步流复制陷阱
作者:互联网
根据同步流复制模式,需要等待至少一个备库接受wal并返回确认信息后主库才向客户端返回成功,一方面保障数据完整性,另一方面如果备库宕机,主库的写操作将出现等待状态,实验环境为一主一备
模拟备库故障
[postgres@localhost pg_root]$ pg_ctl stop -m fast waiting for server to shut down....2021-11-01 05:15:10.927 EDT [3890] LOG: received fast shutdown request 2021-11-01 05:15:10.928 EDT [3890] LOG: aborting any active transactions 2021-11-01 05:15:10.928 EDT [3895] FATAL: terminating walreceiver process due to administrator command 2021-11-01 05:15:10.929 EDT [3892] LOG: shutting down 2021-11-01 05:15:10.932 EDT [3890] LOG: database system is shut down done server stopped
在主库上查询,查询不受影响
postgres=# select * from ceshizhujixieru; id ---- 2 (1 row)
在主库上插入数据,一直除以等待状态
通常一主一备不会采用同步复制,因为备库宕机后会对生产产生影响,postgresql支持一主多备,
标签:11,01,postgresql,EDT,05,复制,2021,陷阱,15 来源: https://www.cnblogs.com/LuoYao666/p/15494759.html