Greenplum 添加mirror步骤
原文链接:https://yq.aliyun.com/articles/695864
[TOC]
概述
新安装的greenplum集群只有primary节点,没有mirror。高可用性没得到保证。所以就需要为集群添加mirror节点
注意:数据量过大时添加mirror,会有较大的磁盘压力,因为后台会一直同步数据,这一点线上系统需要注意
添加前情况
初始化的时候只有primary
gpstate -b
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-Greenplum Primary Segment Configuration
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:—————————————-
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg0 40000 2 0
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg1 40001 3 1
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg2 40002 4 2
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg3 40003 5 3
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg4 40000 6 4
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg5 40001 7 5
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg6 40002 8 6
-
20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg7 40003 9 7
-
Continue with Greenplum creation Yy/Nn>
查看系统配置表,发现只有primary节点
-
postgres=# SELECT * from gp_segment_configuration ;
-
dbid | content | role | preferred_role | mode | status | port | hostname | address | replication_port | san_mounts
-
——+———+——+—————-+——+——–+——-+———-+———+——————+————
-
1 | -1 | p | p | s | u | 5432 | gw_mdw1 | gw_mdw1 | |
-
2 | 0 | p | p | s | u | 40000 | gw_sdw1 | gw_sdw1 | |
-
6 | 4 | p | p | s | u | 40000 | gw_sdw2 | gw_sdw2 | |
-
3 | 1 | p | p | s | u | 40001 | gw_sdw1 | gw_sdw1 | |
-
7 | 5 | p | p | s | u | 40001 | gw_sdw2 | gw_sdw2 | |
-
4 | 2 | p | p | s | u | 40002 | gw_sdw1 | gw_sdw1 | |
-
8 | 6 | p | p | s | u | 40002 | gw_sdw2 | gw_sdw2 | |
-
5 | 3 | p | p | s | u | 40003 | gw_sdw1 | gw_sdw1 | |
-
9 | 7 | p | p | s | u | 40003 | gw_sdw2 | gw_sdw2 | |
-
(9 rows)
添加步骤
在所有需要添加mirror的主机,创建存放mirror的数据目录
可以使用gpssh命令
gpssh -f seg_hosts -e \'mkdir -p /data/mirror\'
生成addmirror文件
执行gpaddmirrors 命令,键入存放mirror节点的日志,生成配置文件
-
[gpadmin@gw_mdw1 ~]$ gpaddmirrors -o ./addmirror
-
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Starting gpaddmirrors with args: -o ./addmirror
-
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: \’postgres (Greenplum Database) 4.3.1.0 build 6\’
-
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-master Greenplum Version: \’PostgreSQL 8.2.15 (Greenplum Database 4.3.1.0 build 6) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jun 11 2014 17:23:40\’
-
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Obtaining Segment details from master…
-
Enter mirror segment data directory location 1 of 4 >
-
/data/mirror
-
Enter mirror segment data directory location 2 of 4 >
-
/data/mirror
-
Enter mirror segment data directory location 3 of 4 >
-
/data/mirror
-
Enter mirror segment data directory location 4 of 4 >
-
/data/mirror
-
20190326:00:57:15:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Configuration file output to ./addmirror successfully.
查看文件内容如下
-
[gpadmin@gw_mdw1 ~]$ cat addmirror
-
filespaceOrder=
-
mirror0=0:gw_sdw2:41000:42000:43000:/data/mirror/gpseg0
-
mirror1=1:gw_sdw2:41001:42001:43001:/data/mirror/gpseg1
-
mirror2=2:gw_sdw2:41002:42002:43002:/data/mirror/gpseg2
-
mirror3=3:gw_sdw2:41003:42003:43003:/data/mirror/gpseg3
-
mirror4=4:gw_sdw1:41000:42000:43000:/data/mirror/gpseg4
-
mirror5=5:gw_sdw1:41001:42001:43001:/data/mirror/gpseg5
-
mirror6=6:gw_sdw1:41002:42002:43002:/data/mirror/gpseg6
-
mirror7=7:gw_sdw1:41003:42003:43003:/data/mirror/gpseg7
执行添加命令
-
[gpadmin@gw_mdw1 ~]$ gpaddmirrors -i addmirror
-
20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Starting gpaddmirrors with args: -i addmirror
-
20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: \’postgres (Greenplum Database) 4.3.1.0 build 6\’
-
20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-master Greenplum Version: \’PostgreSQL 8.2.15 (Greenplum Database 4.3.1.0 build 6) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jun 11 2014 17:23:40\’
命令没有报错,查看mirror节点的情况
使用gpstate -m查看,发现所有的mirror正在同步数据,因为我的集群新建,很快就同步完成了,此时再执行gpstate -m就可以看到Data Status的状态是Synchronized(已同步的)
-
[gpadmin@gw_mdw1 ~]$ gpstate -m
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-Starting gpstate with args: -m
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: \’postgres (Greenplum Database) 4.3.1.0 build 6\’
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-master Greenplum Version: \’PostgreSQL 8.2.15 (Greenplum Database 4.3.1.0 build 6) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jun 11 2014 17:23:40\’
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-Obtaining Segment details from master…
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:————————————————————–
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:–Current GPDB mirror list and status
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:–Type = Group
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:————————————————————–
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- Mirror Datadir Port Status Data Status
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg0 41000 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg1 41001 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg2 41002 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg3 41003 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg4 41000 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg5 41001 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg6 41002 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg7 41003 Passive Resynchronizing
-
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:————————————————————–
查看节点状态
发现所有的mirror已经启动
-
postgres=# SELECT * from gp_segment_configuration ;
-
dbid | content | role | preferred_role | mode | status | port | hostname | address | replication_port | san_mounts
-
——+———+——+—————-+——+——–+——-+———-+———+——————+————
-
1 | -1 | p | p | s | u | 5432 | gw_mdw1 | gw_mdw1 | |
-
2 | 0 | p | p | s | u | 40000 | gw_sdw1 | gw_sdw1 | 43000 |
-
10 | 0 | m | m | s | u | 41000 | gw_sdw2 | gw_sdw2 | 42000 |
-
3 | 1 | p | p | s | u | 40001 | gw_sdw1 | gw_sdw1 | 43001 |
-
11 | 1 | m | m | s | u | 41001 | gw_sdw2 | gw_sdw2 | 42001 |
-
4 | 2 | p | p | s | u | 40002 | gw_sdw1 | gw_sdw1 | 43002 |
-
12 | 2 | m | m | s | u | 41002 | gw_sdw2 | gw_sdw2 | 42002 |
-
5 | 3 | p | p | s | u | 40003 | gw_sdw1 | gw_sdw1 | 43003 |
-
13 | 3 | m | m | s | u | 41003 | gw_sdw2 | gw_sdw2 | 42003 |
-
6 | 4 | p | p | s | u | 40000 | gw_sdw2 | gw_sdw2 | 43000 |
-
14 | 4 | m | m | s | u | 41000 | gw_sdw1 | gw_sdw1 | 42000 |
-
7 | 5 | p | p | s | u | 40001 | gw_sdw2 | gw_sdw2 | 43001 |
-
15 | 5 | m | m | s | u | 41001 | gw_sdw1 | gw_sdw1 | 42001 |
-
8 | 6 | p | p | s | u | 40002 | gw_sdw2 | gw_sdw2 | 43002 |
-
16 | 6 | m | m | s | u | 41002 | gw_sdw1 | gw_sdw1 | 42002 |
-
9 | 7 | p | p | s | u | 40003 | gw_sdw2 | gw_sdw2 | 43003 |
-
17 | 7 | m | m | s | u | 41003 | gw_sdw1 | gw_sdw1 | 42003 |
-
(17 rows)