greenplum 单独添加 standby

本文主要介绍如何为没有做Standby的Master节点添加Standby。(快速整理版)

旧版本gp集群需要注意!!!!

在为Master节点搭建Standby的过程中,GreenPlum会自动关闭数据库,并以utility模式打开Master节点,然后修改gp_segment_configuration字典中增加Standby的信息,然后再关闭Master节点,将Master的数据拷贝到Standby节点,最后启动数据库,所以,在为Master节点添加Standby时,需要在空闲时段进行,否则会影响业务。

添加新节点需要完成如下工作:

参考信息:
https://blog.51cto.com/michaelkang/2167195

1:新建gp 用户,用户id 与集群节点保持一直;
2:新建数据目录,chown gpadmin.gpadmin $DIR;
3:集群所有主机(Master节点和所有Segment节点)的hosts文件均需要添加Standby主机的信息。
4:完成系统初始化(关闭防火墙,selinux ,sysctl.conf ,limits.conf ...),具体参考greenplum 集群安装初始化安装步骤;
5:直接打通master节点 ssh 免密登陆新添加standby ;
6:standby节点 ssh 免密登陆集群其它节点,通过gpssh工具测试;
7:安装greenplum 软件包
8:检查新添加standby 节点安装目录权限,chown gpadmin.gpadmin $DIR
9:设置standby 节点gpadmin账户的环境变量,使之生效;

以上确认配置没问题后:

10.在Master节点通过gpinitstandby命令添加Standby。 (gpadmin 用户执行)

[gpadmin@mdw config]$ gpinitstandby -s standby-node

操作实例:

[gpadmin@kangjianhua-6-16 ~]$ gpinitstandby -s kangjianhua-6-15.ptmind.com

gpadmin-[INFO]:-Validating environment and parameters for standby initialization...
gpadmin-[INFO]:-Checking for filespace directory /usr/local/gpdata/gpmaster/gpseg-1 on kangjianhua-6-15.ptmind.com
gpadmin-[INFO]:------------------------------------------------------
gpadmin-[INFO]:-Greenplum standby master initialization parameters
gpadmin-[INFO]:------------------------------------------------------
gpadmin-[INFO]:-Greenplum master hostname = kangjianhua-6-16.ptmind.com
gpadmin-[INFO]:-Greenplum master data directory = /usr/local/gpdata/gpmaster/gpseg-1
gpadmin-[INFO]:-Greenplum master port = 5432
gpadmin-[INFO]:-Greenplum standby master hostname = kangjianhua-6-15.ptmind.com
gpadmin-[INFO]:-Greenplum standby master port = 5432
gpadmin-[INFO]:-Greenplum standby master data directory = /usr/local/gpdata/gpmaster/gpseg-1
gpadmin-[INFO]:-Greenplum update system catalog = On
gpadmin-[INFO]:------------------------------------------------------
gpadmin-[INFO]:- Filespace locations
gpadmin-[INFO]:------------------------------------------------------
gpadmin-[INFO]:-pg_system -> /usr/local/gpdata/gpmaster/gpseg-1

Do you want to continue with standby master initialization? Yy|Nn (default=N):
> y
gpadmin-[INFO]:-Syncing Greenplum Database extensions to standby
gpadmin-[INFO]:-The packages on kangjianhua-6-15.ptmind.com are consistent.
gpadmin-[INFO]:-Adding standby master to catalog...
gpadmin-[INFO]:-Database catalog updated successfully.
gpadmin-[INFO]:-Updating pg_hba.conf file...
gpadmin-[INFO]:-pg_hba.conf files updated successfully.
gpadmin-[INFO]:-Updating filespace flat files...
gpadmin-[INFO]:-Filespace flat file updated successfully.
gpadmin-[INFO]:-Starting standby master
gpadmin-[INFO]:-Checking if standby master is running on host: kangjianhua-6-15.ptmind.com in directory: /usr/local/gpdata/gpmaster/gpseg-1
20181115:18:06:06:176421 gpinitstandby:kangjianhua-6-16:gpadmin-[WARNING]:-Unable to cleanup previously started standby: 
20181115:18:06:07:176421 gpinitstandby:kangjianhua-6-16:gpadmin-[INFO]:-Cleaning up pg_hba.conf backup files...
20181115:18:06:08:176421 gpinitstandby:kangjianhua-6-16:gpadmin-[INFO]:-Backup files of pg_hba.conf cleaned up successfully.
20181115:18:06:08:176421 gpinitstandby:kangjianhua-6-16:gpadmin-[INFO]:-Successfully created standby master on kangjianhua-6-15.ptmind.com

gpcc 问题处理:

greenplum master 节点迁移后,gpcc节点的配置要需要修改gpcc 连接节点的指向新的master地址:

gp 集群master切换后,需要修改:

/usr/local/gpcc/greenplum-cc-web-4.3.1/conf
cp app.conf app.conf.bak
vim app.conf

[gpadmin@kangjianhua-6-16 conf]$ more app.conf
appname = gpccws
listentcp4 = true
runmode = prod
session = true
enablexsrf = true
xsrfexpire = 2592000
xsrfkey = 61oETzKXQAGaYdkLxxxxxxxxxxxxxx
rendertype = json
printallsqls = false
master_port = 5432
path = /usr/local/gpcc
display_name = gpcc
enable_kerberos = false
EnableHTTPS = false
EnableHTTP = true
httpport = 28080
rpc_port = 8899
master_host = kangjianhua-6-15.ptmind.com ==> kangjianhua-6-16.ptmind.com (新master) 《《《===修改内容

查看状态:
gpcc status

启动服务:
gpcc start

#查看服务进程:

ps  -ef|grep ccagent

/usr/local/gpcc/greenplum-cc-web-4.3.1/bin/ccagent -udpport 9898 -rpcaddr kangjianhua-6-15.ptmind.com:8899

安装参考:
https://blog.51cto.com/michaelkang/2170631