温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Pg 流复制方式HA 版本升级步骤

发布时间:2020-07-28 21:37:51 来源:网络 阅读:4478 作者:pgmia 栏目:数据库

一、HA Description:

Master:192.168.1.10

Slave:192.168.1.20

VIP: eth0:pgvip(master and slave) 192.168.1.30

PGDATA: /pgdata95

pg_version: 9.5.2


二、upgrade steps:

(一)升级Slave数据库软件版本

1.postgres(192.168.1.20)

pg_ctl -D /pgdata95 stop -m fast


2.postgres(192.168.1.20)

update postgresql soft version,不使用pg_upgrade命令方式升级,仅小版本升级使用9.5.2 --》 9.5.3

安装同主分支版本 例如,9.5.3

3.postgres(192.168.1.20)

修改数据库PATH为最新版本的bin路径,例如,

# Installation prefix

prefix=/opt/pgsql/9.5.7(新版本软件目录)

# Data directory

PGDATA="/pgdata95"(原data目录)

启动salve

pg_ctl -D /path/to/database start



(二)停止VIP,禁止提供服务

4.root(192.168.1.10)

ifconfig eth0:pgvip down


(三)Master 执行检查点

5.db super(192.168.1.10)

checkpoint;


6.postgres(192.168.1.10)

SELECT sent_location, replay_location

FROM pg_stat_replication WHERE usename = 'rep_user';


7.postgres(192.168.1.10)

重复以上查询,直到sent_location 和 replay_location 相等


8.postgres(192.168.1.10)

pg_ctl -D /pgdata95 stop -m fast


(四)提升Slave为Master

9.postgres(192.168.1.20)

pg_ctl -D /pgdata95 promote


(五)启动VIP,对外提供服务

10.root(192.168.1.20)

ifconfig eth0:pgvip 192.168.1.30 up


(六)通知研发或者运维重启应用程序的数据库连接池

11.如果必要,通知研发与支持重启应用程序的数据库连接池。


(七)升级 Master 数据库软件版本

12.postgres(192.168.1.10)

update postgresql soft version

修改数据库PATH为最新版本的bin路径,例如,

# Installation prefix

prefix=/opt/pgsql/9.5.7(新版本软件目录)

# Data directory

PGDATA="/pgdata95"(原data目录)


(八)重做Slave

13.postgres(192.168.1.10)

清空数据库数据目录,rm -Rf /pgdata95


14.postgres(192.168.1.10)

pg_basebackup -U rep_user -h 192.168.1.20 -D /pgdata95 --checkpoint=fast --xlog-method=stream -R


(九)启动新的Slave

15.postgres(192.168.1.10)

pg_ctl -D /path/to/database start


使用方式

以上升级最好在数据库主版本一致的情况下进行

  1. 如slave(9.5.2)升级到(10.0.beta1),pg_upgrade升级方式

    slave日志报错:

    2017-05-23 00:09:19.319 CST [10078] FATAL:  database system identifier differs between the primary and standby

    2017-05-23 00:09:19.319 CST [10078] DETAIL:  The primary's identifier is 6417769161397888214, the standby's identifier is 6422989582

    707312045.

    2017-05-23 00:09:34.340 CST [10098] FATAL:  database system identifier differs between the primary and standby

    2017-05-23 00:09:34.340 CST [10098] DETAIL:  The primary's identifier is 6417769161397888214, the standby's identifier is 6422989582

    707312045.

    如遇到此情况,需要先停止Master数据库对外服务,然后升级Master为大版本,重新做Slave解决

  2. 如果slave(9.5.2)升级到(9.5.3)

 可以顺利升级




向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI