Greenplum实战--standby master的模拟故障与修复

本文详细介绍了在Greenplum数据库中,Master节点的Standby在异常情况下的数据同步修复流程,包括故障模拟、状态检查、数据同步及Master节点故障后的Standby切换,为数据库维护人员提供了实用的操作指南。

standby master的模拟故障与修复

 

本文档主要演示GreenPlum数据库的Master节点的Standby在异常后的数据同步及Master节点故障后,Standby的切换。在操作前通过gpstate命令查看Standby的状态是正常的,数据也在同步状态。同时将现有master(原有的standy)和原有的master再做切换,恢复原状。

1 检查集群gpstate -f

[gpadmin@mdw ~]$ gpstate -f
20200420:00:23:47:010679 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -f
20200420:00:23:47:010679 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.10.2 build commit:b3c02f3acd880e2d676dacea36be015e4a3826d4'
20200420:00:23:47:010679 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.3.23 (Greenplum Database 5.10.2 build commit:b3c02f3acd880e2d676dacea36be015e4a3826d4) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 6.2.0, 64-bit compiled on Aug 10 2018 07:30:24'
20200420:00:23:47:010679 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-Standby master details
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-----------------------
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-   Standby address          = smdw
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-   Standby data directory   = /greenplum/gpdata/master/gpseg-1
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-   Standby port             = 5432
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-   Standby PID              = 7593
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:-   Standby status           = Standby host passive
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--pg_stat_replication
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--WAL Sender State: streaming
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--Sync state: sync
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--Sent Location: 0/CADFDD8
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--Flush Location: 0/CADFDD8
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--Replay Location: 0/CADFDD8
20200420:00:23:48:010679 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

2 模拟standby 故障

mdw 
cat .bash_profile 
export PATH
export MASTER_DATA_DIRECTORY=/greenplum/gpdata/master/gpseg-1
source /usr/local/greenplum-db/greenplum_path.sh
export PGPORT=5432
export PGDATABASE=archdata
​
sdw3 and smdw
vi .bash_profile
​
export MASTER_DATA_DIRECTORY=/greenplum/gpdata/master/gpseg-1
source /usr/local/greenplum-db/greenplum_path.sh
export PGPORT=5432
export PGDATABASE=archdata
​
vi .bashr
export MASTER_DATA_DIRECTORY=/greenplum/gpdata/master/gpseg-1
source /usr/local/greenplum-db/greenplum_path.sh
export PGPORT=5432
export PGDATABASE=archdata
​
smdw:
pg_ctl stop -D $MASTER_DATA_DIRECTORY
[gpadmin@sdw3 ~]$ pg_ctl stop -D $MASTER_DATA_DIRECTORY
waiting for server to shut down.... done
server stopped
[gpadmin@sdw3 ~]$

3 mdw上检查集群状态

gpstate -f

[gpadmin@mdw ~]$ gpstate -f
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -f
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.10.2 build commit:b3c02f3acd880e2d676dacea36be015e4a3826d4'
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.3.23 (Greenplum Database 5.10.2 build commit:b3c02f3acd880e2d676dacea36be015e4a3826d4) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 6.2.0, 64-bit compiled on Aug 10 2018 07:30:24'
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-Standby master details
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-----------------------
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-   Standby address          = smdw
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-   Standby data directory   = /greenplum/gpdata/master/gpseg-1
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-   Standby port             = 5432
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[WARNING]:-Standby PID              = 0                                  <<<<<<<<
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[WARNING]:-Standby status           = Standby process not running        <<<<<<<<
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:--pg_stat_replication
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:-No entries found.
20200420:01:03:58:011908 gpstate:mdw:gpadmin-[INFO]:----------------------
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值