当前位置: 首页 > GreenPlum > 正文

GreenPlum数据库为Segment增加Mirror节点

本文档主要演示GreenPlum数据库非Mirror模式为Segment节点增加Mirror。以下是当前数据库的节点信息。

dbdream=# select dbid,content,role,port,hostname,address from gp_segment_configuration order by dbid;
 dbid | content | role | port  | hostname | address |
------+---------+------+-------+----------+---------+
    1 |      -1 | p    |  5432 | mdw-std  | mdw-std |
    2 |       0 | p    | 40000 | sdw1     | sdw1    |
    3 |       1 | p    | 40000 | sdw2     | sdw2    |
    4 |       2 | p    | 40000 | sdw3     | sdw3    |
    5 |       3 | p    | 40000 | sdw4     | sdw4    |

(5 rows)

如上所示,当前数据库有4个Segment节点,下面为每个个Segment节点增加一个Mirror,也Segment增加Mirror也分两种情况,一种是在现有的服务器上添加,一种是在新增的机器添加。两种方式的区别就是在新服务器上添加比在现有服务器上安装多软件安装部分,软件安装部分参考GreenPlum数据库安装系列第一篇:非mirror模式Master软件安装,本文主要演示在现有服务器上添加Mirror。

GreenPlum数据库提供了gpaddmirrors脚本来添加Mirror,非常方便。下面在所有Segment主机上创建Mirror的数据存放目录和文件空间所需的目录。

[gpadmin@sdw1 gpdata]$ mkdir /gpdb/gpdata/mirror
[gpadmin@sdw4 ~]$ mkdir /gpdb/gpdata/fspc_mirror
[gpadmin@sdw2 gpdata]$ ll
total 16
drwxrwxr-x 2 gpadmin gpadmin 4096 Mar  4 14:51 fspc_mirror
drwxrwxr-x 3 gpadmin gpadmin 4096 Jan 16 11:29 fspc_segment
drwxrwxr-x 2 gpadmin gpadmin 4096 Mar  4 14:45 mirror
drwxrwxr-x 3 gpadmin gpadmin 4096 Jan 14 10:31 primary

然后使用gpaddmirrors –o参数生成添加Mirror的参数文件。

[gpadmin@mdw-std ~]$ gpaddmirrors -o add_mirror
20160304:14:50:11:004574 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting gpaddmirrors with args: -o add_mirror
20160304:14:50:11:004574 gpaddmirrors:mdw-std:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.6.2 build 1'
20160304:14:50:11:004574 gpaddmirrors:mdw-std:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28'
20160304:14:50:11:004574 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Obtaining Segment details from master...
Enter mirror segment data directory location 1 of 1 >

输入Mirror存放数据的目录。

/gpdb/gpdata/mirror
Enter mirror filespace 'fspc1' directory location 1 of 1 >

输入Mirror的文件空间目录。

/gpdb/gpdata/fspc_mirror
20160304:14:52:44:004574 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Configuration file output to add_mirror successfully.

这样就生成了添加Mirror时使用的参数文件,Mirror是Segment节点的镜像,主要用来防止Segment节点故障,Mirror可以直接接替Segment,在4.3版本这个过程对用户来说是透明的,不会影响数据库的正常使用,在4.3版本之前,一旦Segment发生故障,数据库就会变成只读模式。那么如果Mirror和Segment放在同一台服务器上,如果Segment所在的主机出现故障,Segment和Mirror就会同时出现故障,那么数据库就不能正常工作,所以Mirror和Segment尽量不要放在同一台服务器上gpaddmirrors脚本生成的参数文件就自动处理了这个问题,下面看下刚才生成的参数文件内容。

[gpadmin@mdw-std ~]$ cat add_mirror 
filespaceOrder=fspc1
mirror0=0:sdw2:41000:42000:43000:/gpdb/gpdata/mirror/gpseg0:/gpdb/gpdata/fspc_mirror/gpseg0
mirror1=1:sdw3:41000:42000:43000:/gpdb/gpdata/mirror/gpseg1:/gpdb/gpdata/fspc_mirror/gpseg1
mirror2=2:sdw4:41000:42000:43000:/gpdb/gpdata/mirror/gpseg2:/gpdb/gpdata/fspc_mirror/gpseg2
mirror3=3:sdw1:41000:42000:43000:/gpdb/gpdata/mirror/gpseg3:/gpdb/gpdata/fspc_mirror/gpseg3

从上面的参数文件可以看出,编号为0也就是第一个Segment(sdw1)的Mirror放到了第二个Segment(sdw2)的主机上,编号为1的Segment(sdw2)的Mirror放到了第三个Segment(sdw3)的主机上,编号为2的Segment(sdw3)的Mirror放到了第四个Segment(sdw4)的主机上,编号为3的Segment(sdw4)的Mirror放到了第一个Segment(sdw1)的主机上,这样就交叉存放,如果其中一台主机出现故障,比如说sdw1主机出现了故障,sdw1的Segment的Mirror在sdw2上,可以直接接管 sdw1的Segment,而sdw1服务器上的sdw4 的Mirror出现故障对数据库的运行是没有影响的,也就是随便一台服务器出现故障,并不会影响数据库的正常工作。

上面生产的参数文件可以手工更改,可以参数数据库中各节点的信息来修改这个参数文件的信息。

dbdream=# SELECT dbid, content, address as host_address, port, 
dbdream-#    replication_port, fselocation as datadir 
dbdream-#    FROM gp_segment_configuration, pg_filespace_entry 
dbdream-#    WHERE dbid=fsedbid 
dbdream-#    ORDER BY dbid;
 dbid | content | host_address | port  | replication_port |             datadir              
------+---------+--------------+-------+------------------+----------------------------------
    1 |      -1 | mdw-std      |  5432 |                  | /gpdb/gpdata/master/gpseg-1
    1 |      -1 | mdw-std      |  5432 |                  | /gpdb/gpdata/fspc_master/gpseg-1
    2 |       0 | sdw1         | 40000 |                  | /gpdb/gpdata/primary/gpseg0
    2 |       0 | sdw1         | 40000 |                  | /gpdb/gpdata/fspc_segment/gpseg0
    3 |       1 | sdw2         | 40000 |                  | /gpdb/gpdata/primary/gpseg1
    3 |       1 | sdw2         | 40000 |                  | /gpdb/gpdata/fspc_segment/gpseg1
    4 |       2 | sdw3         | 40000 |                  | /gpdb/gpdata/primary/gpseg2
    4 |       2 | sdw3         | 40000 |                  | /gpdb/gpdata/fspc_segment/gpseg2
    5 |       3 | sdw4         | 40000 |                  | /gpdb/gpdata/primary/gpseg3
    5 |       3 | sdw4         | 40000 |                  | /gpdb/gpdata/fspc_segment/gpseg3
(10 rows)

经对比数据库中各节点的分布情况及文件空间情况,这个参数文件直接就可以使用,各Mirror的分布也很正确,下面开始正式添加Mirror。

[gpadmin@mdw-std ~]$ gpaddmirrors -i add_mirror 
20160304:14:58:25:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting gpaddmirrors with args: -i add_mirror
20160304:14:58:25:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.6.2 build 1'
20160304:14:58:25:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28'
20160304:14:58:25:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Obtaining Segment details from master...
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Greenplum Add Mirrors Parameters
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Greenplum master data directory          = /gpdb/gpdata/master/gpseg-1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Greenplum master port                    = 5432
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Parallel batch limit                     = 16
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Mirror 1 of 4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance host               = sdw1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance address            = sdw1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance directory          = /gpdb/gpdata/primary/gpseg0
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance port               = 40000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance replication port   = 43000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance fspc1 directory    = /gpdb/gpdata/fspc_segment/gpseg0
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance host                = sdw2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance address             = sdw2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance directory           = /gpdb/gpdata/mirror/gpseg0
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance port                = 41000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance replication port    = 42000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance fspc1 directory     = /gpdb/gpdata/fspc_mirror/gpseg0
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Mirror 2 of 4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance host               = sdw2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance address            = sdw2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance directory          = /gpdb/gpdata/primary/gpseg1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance port               = 40000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance replication port   = 43000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance fspc1 directory    = /gpdb/gpdata/fspc_segment/gpseg1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance host                = sdw3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance address             = sdw3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance directory           = /gpdb/gpdata/mirror/gpseg1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance port                = 41000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance replication port    = 42000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance fspc1 directory     = /gpdb/gpdata/fspc_mirror/gpseg1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Mirror 3 of 4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance host               = sdw3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance address            = sdw3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance directory          = /gpdb/gpdata/primary/gpseg2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance port               = 40000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance replication port   = 43000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance fspc1 directory    = /gpdb/gpdata/fspc_segment/gpseg2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance host                = sdw4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance address             = sdw4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance directory           = /gpdb/gpdata/mirror/gpseg2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance port                = 41000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance replication port    = 42000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance fspc1 directory     = /gpdb/gpdata/fspc_mirror/gpseg2
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Mirror 4 of 4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-------------------
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance host               = sdw4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance address            = sdw4
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance directory          = /gpdb/gpdata/primary/gpseg3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance port               = 40000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance replication port   = 43000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Primary instance fspc1 directory    = /gpdb/gpdata/fspc_segment/gpseg3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance host                = sdw1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance address             = sdw1
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance directory           = /gpdb/gpdata/mirror/gpseg3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance port                = 41000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance replication port    = 42000
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-   Mirror instance fspc1 directory     = /gpdb/gpdata/fspc_mirror/gpseg3
20160304:14:58:26:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:----------------------

Continue with add mirrors procedure Yy|Nn (default=N):

输入Y确认添加Mirror。

> y
20160304:14:58:54:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-4 segment(s) to add
20160304:14:58:54:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Building template directory
20160304:14:58:55:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Validating remote directories
. 
20160304:14:58:56:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Copying template directory file
. 
20160304:14:58:57:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Configuring new segments
. 
20160304:14:58:58:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Cleaning files
. 
20160304:14:58:59:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting file move procedure for sdw2:/gpdb/gpdata/mirror/gpseg0:content=0:dbid=6:mode=r:status=u
20160304:14:58:59:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting file move procedure for sdw3:/gpdb/gpdata/mirror/gpseg1:content=1:dbid=7:mode=r:status=u
20160304:14:58:59:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting file move procedure for sdw4:/gpdb/gpdata/mirror/gpseg2:content=2:dbid=8:mode=r:status=u
20160304:14:58:59:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting file move procedure for sdw1:/gpdb/gpdata/mirror/gpseg3:content=3:dbid=9:mode=r:status=u
20160304:14:58:59:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Updating configuration with new mirrors
20160304:14:58:59:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Updating mirrors
. 
20160304:14:59:00:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Starting mirrors
20160304:14:59:00:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Commencing parallel primary and mirror segment instance startup, please wait...
.. 
20160304:14:59:02:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Process results...
20160304:14:59:02:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Updating configuration to mark mirrors up
20160304:14:59:02:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Updating primaries
20160304:14:59:02:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Commencing parallel primary conversion of 4 segments, please wait...
. 
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Process results...
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Done updating primaries
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-*********************
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Mirror segments have been added; data synchronization is in progress.
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Data synchronization will continue in the background.
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-Use  gpstate -s  to check the resynchronization progress.
20160304:14:59:03:004767 gpaddmirrors:mdw-std:gpadmin-[INFO]:-**********************

在添加完节点时,GreenPlum会提示通过gpstate –s命令来查看Mirror的状态,Use  gpstate -s  to check the resynchronization progress。

[gpadmin@mdw-std ~]$ gpstate -s
20160304:14:59:34:004964 gpstate:mdw-std:gpadmin-[INFO]:-Starting gpstate with args: -s
20160304:14:59:34:004964 gpstate:mdw-std:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.6.2 build 1'
20160304:14:59:34:004964 gpstate:mdw-std:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28'
20160304:14:59:34:004964 gpstate:mdw-std:gpadmin-[INFO]:-Obtaining Segment details from master...
20160304:14:59:34:004964 gpstate:mdw-std:gpadmin-[INFO]:-Gathering data from segments...
. 
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:--Master Configuration & Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Master host                    = mdw-std
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Master postgres process ID     = 5350
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Master data directory          = /gpdb/gpdata/master/gpseg-1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Master port                    = 5432
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Master current role            = dispatch
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Greenplum initsystem version   = 4.3.6.2 build 1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Greenplum current version      = PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Postgres version               = 8.2.15
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Master standby                 = No master standby configured
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-Segment Instance Status Report
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/primary/gpseg0
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 40000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Change Tracking Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Change tracking data size               = 10.0 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Resynchronization Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Resynchronization mode                  = Full
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Data synchronized                       = 88.3 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated total data to synchronize     = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync progress with mirror   = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Total resync objects                    = 915
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Objects to resync                       = 0
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync end time               = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 3359
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Database status                         = Suspended
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw2
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw2
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/mirror/gpseg0
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 41000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 4416
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Segment status                          = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw2
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw2
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/primary/gpseg1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 40000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Change Tracking Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Change tracking data size               = 9.75 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Resynchronization Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Resynchronization mode                  = Full
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Data synchronized                       = 88.3 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated total data to synchronize     = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync progress with mirror   = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Total resync objects                    = 915
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Objects to resync                       = 0
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync end time               = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 3079
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Database status                         = Suspended
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw3
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw3
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/mirror/gpseg1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 41000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 4726
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Segment status                          = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw3
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw3
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/primary/gpseg2
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 40000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Change Tracking Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Change tracking data size               = 10.0 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Resynchronization Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Resynchronization mode                  = Full
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Data synchronized                       = 88.3 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated total data to synchronize     = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync progress with mirror   = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Total resync objects                    = 915
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Objects to resync                       = 0
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync end time               = Not Available
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 5094
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Database status                         = Suspended
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw4
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw4
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/mirror/gpseg2
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 41000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 10578
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Segment status                          = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw4
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw4
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/primary/gpseg3
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 40000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Primary
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Change Tracking Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Change tracking data size               = 10.0 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Resynchronization Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Resynchronization mode                  = Full
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Data synchronized                       = 89.0 MB
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated total data to synchronize     = Sync complete; awaiting config change
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync progress with mirror   = 100%
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Total resync objects                    = 915
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Objects to resync                       = 0
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Estimated resync end time               = 
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 8249
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Database status                         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-----------------------------------------------------
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Segment Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Hostname                                = sdw1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Address                                 = sdw1
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Datadir                                 = /gpdb/gpdata/mirror/gpseg3
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Port                                    = 41000
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Mirroring Info
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Current role                            = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Preferred role                          = Mirror
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Mirror status                           = Resynchronizing
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-   Status
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      PID                                     = 4739
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Configuration reports status as         = Up
20160304:14:59:35:004964 gpstate:mdw-std:gpadmin-[INFO]:-      Segment status                          = Up

也可以用gpstate –m来查看Mirror的信息。

[gpadmin@mdw-std ~]$ gpstate -m
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-Starting gpstate with args: -m
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.6.2 build 1'
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28'
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-Obtaining Segment details from master...
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:------------------------
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:--Current GPDB mirror list and status
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:--Type = Spread
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:------------------------
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-   Mirror   Datadir                      Port    Status    Data Status    
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-   sdw2     /gpdb/gpdata/mirror/gpseg0   41000   Passive   Synchronized
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-   sdw3     /gpdb/gpdata/mirror/gpseg1   41000   Passive   Synchronized
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-   sdw4     /gpdb/gpdata/mirror/gpseg2   41000   Passive   Synchronized
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-   sdw1     /gpdb/gpdata/mirror/gpseg3   41000   Passive   Synchronized
20160304:15:03:05:005126 gpstate:mdw-std:gpadmin-[INFO]:-------------------------

在数据库中也可以查询到Mirror的信息。

dbdream=# select * from gp_segment_configuration order by dbid;
 dbid | content | role | preferred_role | mode | status | port  | hostname | address | replication_port | san_mounts 
------+---------+------+----------------+------+--------+-------+----------+---------+------------------+--------
    1 |      -1 | p    | p              | s    | u      |  5432 | mdw-std  | mdw-std |                  | 
    2 |       0 | p    | p              | s    | u      | 40000 | sdw1     | sdw1    |            43000 | 
    3 |       1 | p    | p              | s    | u      | 40000 | sdw2     | sdw2    |            43000 | 
    4 |       2 | p    | p              | s    | u      | 40000 | sdw3     | sdw3    |            43000 | 
    5 |       3 | p    | p              | s    | u      | 40000 | sdw4     | sdw4    |            43000 | 
    6 |       0 | m    | m              | s    | u      | 41000 | sdw2     | sdw2    |            42000 | 
    7 |       1 | m    | m              | s    | u      | 41000 | sdw3     | sdw3    |            42000 | 
    8 |       2 | m    | m              | s    | u      | 41000 | sdw4     | sdw4    |            42000 | 
    9 |       3 | m    | m              | s    | u      | 41000 | sdw1     | sdw1    |            42000 | 
(9 rows)

从上面的信息可以看出,当前数据库的所有Segment都已经创建了Mirror,而且随便一台Segment服务器出现问题,都不会影响数据库的正常使用,可以当前Master节点并没有创建Standby,如果Master节点的主机出现故障,数据库就不能正常使用啦,还需要给Master节点添加Standby,详细信息参考GreenPlum数据库Master节点搭建Standby。这里只记录添加部分。

[gpadmin@mdw-std ~]$ gpinitstandby -s mdw

The filespace locations on the master must be mapped to
locations on the standby.  These locations must be empty on the
standby master host.  The default provided is the location of
the filespace on the master (except if the master and the
standby are hosted on the same node or host). In most cases the
defaults can be used.

Enter standby filespace location for filespace fspc1 (default: /gpdb/gpdata/fspc_master/gpseg-1):
> 
20160304:15:06:56:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Validating environment and parameters for standby initialization...
20160304:15:06:56:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Checking for filespace directory /gpdb/gpdata/master/gpseg-1 on mdw
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Checking for filespace directory /gpdb/gpdata/fspc_master/gpseg-1 on mdw
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:---------------------
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum standby master initialization parameters
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:---------------------
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum master hostname               = mdw-std
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum master data directory         = /gpdb/gpdata/master/gpseg-1
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum master port                   = 5432
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum standby master hostname       = mdw
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum standby master port           = 5432
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum standby master data directory = /gpdb/gpdata/master/gpseg-1
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Greenplum update system catalog         = On
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:----------------------
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:- Filespace locations
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:----------------------- 20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-pg_system -> /gpdb/gpdata/master/gpseg-1
20160304:15:06:57:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-fspc1 -> /gpdb/gpdata/fspc_master/gpseg-1
Do you want to continue with standby master initialization? Yy|Nn (default=N):

输入Y确认为Master添加Standby。

> y
20160304:15:07:10:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Syncing Greenplum Database extensions to standby
20160304:15:07:10:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-The packages on mdw are consistent.
20160304:15:07:10:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Adding standby master to catalog...
20160304:15:07:10:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Database catalog updated successfully.
20160304:15:07:10:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Updating pg_hba.conf file...
20160304:15:07:16:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-pg_hba.conf files updated successfully.
20160304:15:07:17:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Updating filespace flat files...
20160304:15:07:17:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Filespace flat file updated successfully.
20160304:15:07:17:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Starting standby master
20160304:15:07:17:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Checking if standby master is running on host: mdw  in directory: /gpdb/gpdata/master/gpseg-1
20160304:15:07:17:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Cleaning up pg_hba.conf backup files...
20160304:15:07:23:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Backup files of pg_hba.conf cleaned up successfully.
20160304:15:07:23:005254 gpinitstandby:mdw-std:gpadmin-[INFO]:-Successfully created standby master on mdw

添加完成后,可以通过gpstate –f命令查看Standby的信息。

[gpadmin@mdw-std ~]$ gpstate -f
20160305:11:04:46:027714 gpstate:mdw-std:gpadmin-[INFO]:-Starting gpstate with args: -f
20160305:11:04:46:027714 gpstate:mdw-std:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.6.2 build 1'
20160305:11:04:46:027714 gpstate:mdw-std:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28'
20160305:11:04:46:027714 gpstate:mdw-std:gpadmin-[INFO]:-Obtaining Segment details from master...
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-Standby master details
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-----------------------
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-   Standby address          = mdw
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-   Standby data directory   = /gpdb/gpdata/master/gpseg-1
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-   Standby port             = 5432
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-   Standby PID              = 28969
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:-   Standby status           = Standby host passive
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--------------------
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--pg_stat_replication
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--------------------
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--WAL Sender State: streaming
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--Sync state: sync
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--Sent Location: 0/140008D8
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--Flush Location: 0/140008D8
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:--Replay Location: 0/140008D8
20160305:11:04:47:027714 gpstate:mdw-std:gpadmin-[INFO]:---------------------

在数据库中也可以查询到相关信息。

dbdream=# select dbid,content,role,port,hostname,address,replication_port from gp_segment_configuration order by dbid;
 dbid | content | role | port  | hostname | address | replication_port 
------+---------+------+-------+----------+---------+------------------
    1 |      -1 | p    |  5432 | mdw-std  | mdw-std |                 
    2 |       0 | p    | 40000 | sdw1     | sdw1    |            43000
    3 |       1 | p    | 40000 | sdw2     | sdw2    |            43000
    4 |       2 | p    | 40000 | sdw3     | sdw3    |            43000
    5 |       3 | p    | 40000 | sdw4     | sdw4    |            43000
    6 |       0 | m    | 41000 | sdw2     | sdw2    |            42000
    7 |       1 | m    | 41000 | sdw3     | sdw3    |            42000
    8 |       2 | m    | 41000 | sdw4     | sdw4    |            42000
    9 |       3 | m    | 41000 | sdw1     | sdw1    |            42000
   10 |      -1 | m    |  5432 | mdw      | mdw     |                 
(10 rows)

对于GreenPlum数据库,应该在初始化安装的时候,直接为Master安装Standby及对Segment安装Mirror,这样才能最大程度保护数据库,我之所以之前没有创建Mirror及Standby,是要一步一步学习及测试安装的过程,这对初学者来说,很有必要。

本文固定链接: https://www.dbdream.com.cn/2016/03/greenplum%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%basegment%e5%a2%9e%e5%8a%a0mirror%e8%8a%82%e7%82%b9/ | 信春哥,系统稳,闭眼上线不回滚!

该日志由 dbdream 于2016年03月04日发表在 GreenPlum 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: GreenPlum数据库为Segment增加Mirror节点 | 信春哥,系统稳,闭眼上线不回滚!
关键字: , ,

GreenPlum数据库为Segment增加Mirror节点:等您坐沙发呢!

发表评论

快捷键:Ctrl+Enter