博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
greenplum(5.10)生产系统主备节点切换
阅读量:5979 次
发布时间:2019-06-20

本文共 8267 字,大约阅读时间需要 27 分钟。

集群安装信息参考:

系统初始化:
集群安装配置:

本文对敏感信息进行了替换!!!!

集群主备节点

master  => gpnode615.kjh.comstandby => gpnode616.kjh.com

状态查看工具 gpstate

命令     参数   作用 gpstate -b =》 显示简要状态gpstate -c =》 显示主镜像映射gpstart -d =》 指定数据目录(默认值:$MASTER_DATA_DIRECTORY)gpstate -e =》 显示具有镜像状态问题的片段gpstate -f =》 显示备用主机详细信息gpstate -i =》 显示GRIPLUM数据库版本gpstate -m =》 显示镜像实例同步状态gpstate -p =》 显示使用端口gpstate -Q =》 快速检查主机状态gpstate -s =》 显示集群详细信息gpstate -v =》 显示详细信息

查看集群备用节点状态

gpstate -f=>]:-Standby master details=>]:-----------------------=>]:-   Standby address          = gpnode616.kjh.com=>]:-   Standby data directory   = /usr/local/gpdata/gpmaster/gpseg-1=>]:-   Standby port             = 5432=>]:-   Standby PID              = 45634=>]:-   Standby status           = Standby host passive=>]:--------------------------------------------------------------=>]:--pg_stat_replication=>]:--------------------------------------------------------------=>]:--WAL Sender State: streaming=>]:--Sync state: sync=>]:--Sent Location: 0/C0006C0=>]:--Flush Location: 0/C0006C0=>]:--Replay Location: 0/C0006C0=>]:--------------------------------------------------------------以上信息显示standby状态正常!

切换步骤如下:

定义:

master => gpnode615.kjh.com (server1)
standby => gpnode616.kjh.com (server2)

MASTER_DATA_DIRECTORY => /usr/local/gpdata/gpmaster/gpseg-1

模拟master节点故障 (master节点执行)

pg_ctl stop -D $(MASTER_DATA_DIRECTORY)

or
pg_ctl stop -D /usr/local/gpdata/gpmaster/gpseg-1

再次查看standby节点状态

(master节点执行)

$ gpstate -f=> gpadmin-[INFO]:-Starting gpstate with args: -f=> gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.10.2 build => '=> gpadmin-[CRITICAL]:-gpstate failed. (Reason='could not connect to server: Connection refused        Is the server running on host "localhost" (::1) and accepting        TCP/IP connections on port 5432?could not connect to server: Connection refused        Is the server running on host "localhost" (127.0.0.1) and accepting        TCP/IP connections on port 5432?') exiting...集群进入异常状态,无法获取信息;

激活备用节点

设置gpadmin账户的环境并使之生效

(standby节点,gpadmin账户操作)

修改.bashrc
su - gpadmin cat >>/home/gpadmin/.bashrc<<-EOFsource /usr/local/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/usr/local/gpdata/gpmaster/gpseg-1 export PGPORT=5432EOF
修改.bash_profile
su - gpadmin cat >>/home/gpadmin/.bash_profile<<-EOFsource /usr/local/greenplum-db/greenplum_path.shexport MASTER_DATA_DIRECTORY=/usr/local/gpdata/gpmaster/gpseg-1export PGPORT=5432EOF
使之生效
source ~/.bashrcsource ~/.bash_profile

激活standby节点

(standby节点,gpadmin账户操作)

gpactivatestandby -d /usr/local/gpdata/gpmaster/gpseg-1

=》]:------------------------------------------------------=》]:-Standby data directory    = /usr/local/gpdata/gpmaster/gpseg-1=》]:-Standby port              = 5432=》]:-Standby running           = yes=》]:-Force standby activation  = no=》]:------------------------------------------------------

确认切换:

Do you want to continue with standby master activation? Yy|Nn (default=N):> y    <== !!!

初始化输出信息如下:

=》]:-found standby postmaster process。。。。。。。。。。。。。。。。。=》]:-Writing the gp_dbid file - /usr/local/gpdata/gpmaster/gpseg-1/gp_dbid...=》]:-But found an already existing file.=》]:-Hence removed that existing file.=》]:-Creating a new file...=》]:-Wrote dbid: 1 to the file.=》]:-Now marking it as read only...=》]:-Verifying the file...=》]:------------------------------------------------------=》]:-The activation of the standby master has completed successfully.=》]:-cndh1322-6-16 is now the new primary master.=》]:-You will need to update your user access mechanism to reflect=》]:-the change of master hostname.=》]:-operational, this could result in database corruption!=》]:-MASTER_DATA_DIRECTORY is now /usr/local/gpdata/gpmaster/gpseg-1 if=》]:-this has changed as a result of the standby master activation, remember=》]:-to change this in any startup scripts etc, that may be configured=》]:-to set this value.=》]:-MASTER_PORT is now 5432, if this has changed, you=》]:-Do not re-start the failed master while the fail-over master is=》]:-may need to make additional configuration changes to allow access=》]:-to the Greenplum instance.。。。。。。。。。。。。

再次查看standby节点状态

(standby节点,gpadmin账户操作)

gpstate -f =>]:-Starting gpstate with args: -f=>]:-local Greenplum Version: 'postgres (Greenplum Database) 5.10.2 build =>=>]:-Obtaining Segment details from master...=>]:-Standby master instance not configured=>]:--------------------------------------------------------------=>]:--pg_stat_replication=>]:--------------------------------------------------------------=>]:-No entries found.=>]:--------------------------------------------------------------集群可以查看状态,无法获取信息备用节点信息,此时集群可以访问;

将原有主节点添加为standby (master节点,gpadmin账户操作)

注意这里添加的时候,会check master的数据库目录,要把原master节点的的目录删除或者重命名

mv /usr/local/gpdata/gpmaster/gpseg-1 /usr/local/gpdata/gpmaster/gpseg-1.bak

将原有主节点先添加为standby 节点

(standby节点,gpadmin账户操作)

gpinitstandby -s gpnode615.kjh.com =>]:-Validating environment and parameters for standby initialization...=>]:-Checking for filespace directory /usr/local/gpdata/gpmaster/gpseg-1 on gpnode615.kjh.com=>]:------------------------------------------------------=>]:-Greenplum standby master initialization parameters=>]:------------------------------------------------------=>]:-Greenplum master hostname               = gpnode616.kjh.com=>]:-Greenplum master data directory         = /usr/local/gpdata/gpmaster/gpseg-1=>]:-Greenplum master port                   = 5432=>]:-Greenplum standby master hostname       = gpnode615.kjh.com=>]:-Greenplum standby master port           = 5432=>]:-Greenplum standby master data directory = /usr/local/gpdata/gpmaster/gpseg-1=>]:-Greenplum update system catalog         = On=>]:------------------------------------------------------=>]:- Filespace locations=>]:------------------------------------------------------=>]:-pg_system -> /usr/local/gpdata/gpmaster/gpseg-1#确认添加从节点Do you want to continue with standby master initialization? Yy|Nn (default=N):> y=>]:-Syncing Greenplum Database extensions to standby=>]:-The packages on gpnode615.kjh.com are consistent.=>]:-Adding standby master to catalog...=>]:-Database catalog updated successfully.=>]:-Updating pg_hba.conf file...=>]:-pg_hba.conf files updated successfully.=>]:-Updating filespace flat files...=>]:-Filespace flat file updated successfully.=>]:-Starting standby master=>]:-Checking if standby master is running on host: gpnode615.kjh.com  in directory: /usr/local/gpdata/gpmaster/gpseg-1=>:-Cleaning up pg_hba.conf backup files...=>:-Backup files of pg_hba.conf cleaned up successfully.=>:-Successfully created standby master on gpnode615.kjh.com

查看集群备用节点状态

gpstate -f=》]:-Obtaining Segment details from master...=》]:-Standby master details=》]:-----------------------=》]:-   Standby address          = gpnode615.kjh.com=》]:-   Standby data directory   = /usr/local/gpdata/gpmaster/gpseg-1=》]:-   Standby port             = 5432=》]:-   Standby PID              = 29968=》]:-   Standby status           = Standby host passive=》]:--------------------------------------------------------------=》]:--pg_stat_replication=》]:--------------------------------------------------------------=》]:--WAL Sender State: streaming=》]:--Sync state: sync=》]:--Sent Location: 0/140000A8=》]:--Flush Location: 0/140000A8=》]:--Replay Location: 0/140000A8=》]:--------------------------------------------------------------以上信息显示新添加 gpnode615.kjh.com standby状态正常!

将master 切换至原节点

gpnode615.kjh.com

操作方法按照主备切换方法反向操作即可;#### 现集群状态:standby => gpnode615.kjh.com     master  => gpnode616.kjh.com      以下操作,按照现集群角色配置!!!#### 模拟master节点故障 (gpnode616.kjh.com  节点执行)pg_ctl stop -D /usr/local/gpdata/gpmaster/gpseg-1     #### 激活standby节点 (gpnode615.kjh.com 节点,gpadmin账户操作)gpactivatestandby -d /usr/local/gpdata/gpmaster/gpseg-1     #### 添加standby (gpnode616.kjh.com节点,gpadmin账户操作)注意这里添加的时候,会check master的数据库目录,要把原master节点的的目录删除或者重命名mv /usr/local/gpdata/gpmaster/gpseg-1 /usr/local/gpdata/gpmaster/gpseg-1.bak#### 将原有主节点先添加为standby 节点,(gpnode615.kjh.com节点,gpadmin账户操作)gpinitstandby -s gpnode616.kjh.com #### 验证gpstate -fStandby address          = Standby data directory   = /usr/local/gpdata/gpmaster/gpseg-1Standby port             = 5432Standby PID              = 136489Standby status           = Standby host passive

转载于:https://blog.51cto.com/michaelkang/2170637

你可能感兴趣的文章
c++ STL unique , unique_copy函数
查看>>
http://miicaa.yopwork.com/help/overall/
查看>>
浅谈关于特征选择算法与Relief的实现
查看>>
mybatis-spring 项目简介
查看>>
Wireshark抓取RTP包,还原语音
查看>>
Behavioral模式之Memento模式
查看>>
Work Management Service application in SharePoint 2016
查看>>
Dos 改动IP 地址
查看>>
Laravel 源码解读:php artisan make:auth
查看>>
【转】ionic run android 成功launch success,但是genymotion虚拟机没有显示
查看>>
苹果在GitHub上正式开源iOS内核源码
查看>>
测试人员面临的测试挑战和必备技能
查看>>
使用Flutter之后,我们的CPU占用率降了50%
查看>>
同事反馈环:为什么度量和会议还不够充分
查看>>
[转]十问 Linux 虚拟内存管理 (glibc)
查看>>
老司机带你深入浅出 Collection
查看>>
查询系统-vba
查看>>
[译]Spring Session 与 Spring Security
查看>>
python学习笔记(05)
查看>>
路由器NAT网络地址转换
查看>>