GreenPlum数据库对于数据的冗余,也支持类似Oracle数据库物理DataGuard的数据冗余机制,Master的数据库镜像称为Standby,Segment节点的数据库镜像称之为Mirror,本文主要介绍如何为没有做Standby的Master节点添加Standby。
需要注意,在为Master节点搭建Standby的过程中,GreenPlum会自动关闭数据库,并以utility模式打开Master节点,然后修改gp_segment_configuration字典中增加Standby的信息,然后再关闭Master节点,将Master的数据拷贝到Standby节点,最后启动数据库,所以,在为Master节点添加Standby时,需要在空闲时段进行,否则会影响业务。
在搭建Standby的时候,Standby主机需要先安装GreenPlum数据库软件,这和正常安装GreenPlum数据库软件没有区别,从规范化考虑,尽量使用和Master主机同样的安装路径,下面简单结束安装过程。
1.创建gpadmin用户及安装目录
---------增加master的mirror----------
在smdw上root执行
mkdir -p /greenplum/gpdata/master
chown gpadmin:gpadmin /greenplum/gpdata/master
2.配置hosts文件,添加所有主机的信息
修改hosts文件
10.102.254.24 sdw1
10.102.254.25 sdw2
10.102.254.26 sdw3 smdw
10.102.254.27 mdw
除Standby主机外,其他所有主机(Master节点和所有Segment节点)的hosts文件均需要添加Standby主机的信息,也就是所有GreenPlum数据库包含的主机的hosts文件都需要包含以上hosts文件中的所有主机信息。
- 上传安装文件及解压
省略,因为我的standby和 sdw3一起的
4 创建
在mdw上gpadmin执行
gpinitstandby -s smdw
[gpadmin@mdw ~]$ gpinitstandby -s smdw
20200419:00:58:17:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Validating environment and parameters for standby initialization...
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Checking for filespace directory /greenplum/gpdata/master/gpseg-1 on smdw
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:------------------------------------------------------
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master initialization parameters
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:------------------------------------------------------
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum master hostname = mdw
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum master data directory = /greenplum/gpdata/master/gpseg-1
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum master port = 5432
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master hostname = smdw
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master port = 5432
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master data directory = /greenplum/gpdata/master/gpseg-1
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum update system catalog = On
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:------------------------------------------------------
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:- Filespace locations
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:------------------------------------------------------
20200419:00:58:18:002040 gpinitstandby:mdw:gpadmin-[INFO]:-pg_system -> /greenplum/gpdata/master/gpseg-1
Do you want to continue with standby master initialization? Yy|Nn (default=N):
> y
20200419:00:58:34:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Syncing Greenplum Database extensions to standby
20200419:00:58:35:002040 gpinitstandby:mdw:gpadmin-[INFO]:-The packages on smdw are consistent.
20200419:00:58:35:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Adding standby master to catalog...
20200419:00:58:35:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Database catalog updated successfully.
20200419:00:58:35:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Updating pg_hba.conf file...
20200419:00:58:36:002040 gpinitstandby:mdw:gpadmin-[INFO]:-pg_hba.conf files updated successfully.
20200419:00:58:38:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Updating filespace flat files...
20200419:00:58:38:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Filespace flat file updated successfully.
20200419:00:58:38:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Starting standby master
20200419:00:58:38:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Checking if standby master is running on host: smdw in directory: /greenplum/gpdata/master/gpseg-1
20200419:00:58:38:002040 gpinitstandby:mdw:gpadmin-[WARNING]:-Unable to cleanup previously started standby: 'Warning: the ECDSA host key for 'smdw' differs from the key for the IP address '10.102.254.26'
Offending key for IP in /home/gpadmin/.ssh/known_hosts:1
Matching host key in /home/gpadmin/.ssh/known_hosts:9
'
20200419:00:58:40:002040 gpinitstandby:mdw:gpadmin-[INFO]:-Cleaning up pg_hba.conf backup files...
同时:有一个blog写的详细过程比较好