GP failover,primary和mirror切换实验

http://blog.sina.com.cn/s/blog_9869114e0101k1nc.html

一、恢复失败的segment
出现segment节点down,恢复GP的思路:
if
"segment down" then
case "determine case(errer,message,log,gpstate and so on)"
when "data error[missing or corrupted data directory]"
then
 if "mirror segment是否可用" then
 "gprecoverseg --从mirror segment中恢复primary segment丢失的部分"
 else
 "rebuild gp database system from backup file"
 end if
when "进程错误--postmaster process not is running"
then
 if "mirror segment是否可用" then
 "gprecoverseg --从mirror segment中恢复primary segment丢失的部分"
 else
 "重启GP数据库--gpstop gpstart"
 end if
when "主机出现故障--dns,network,host down and so on"
then
 if "主机故障是否恢复" then
 "故障恢复,切换主机在线"
  if "mirror segment是否可用" then
  "gprecoverseg --从mirror segment中恢复primary segment丢失的部分"
  else
  "重启GP数据库--gpstop gpstart"
  end if
 elsif "mirror segment是否可用"
 then
 "从备机上恢复primary segment丢失的数据 --gprecoverseg -p | -s"
 else
 "rebuild gp database system from backup file"
 end if
end case
end if
a、当发生主机出现故障,主机所有的primary和mirror节点都会标注为down,并踢出集群。如果GP集群没有部署mirror segment,那么整个GP集群将会宕机。
b、通过gprecoverseg 工具恢复segment丢失的数据部分,恢复期间,数据库写的操作将暂时的延缓。
c、gpreceverseg完成之后,数据库将进行重新同步模式,并开始复制改变的文件。这些操作都都是通过后台进程来完成,在这个阶段数据库是可以进行正常的服务。
d、当重新同步完成,系统编程同步化状态,可以通过gpstate -m查询
e、主备切换--切换segment到预设角色(primary,mirror)。当出现segment故障时,mirror segment会替换故障的primary segment,成为primary segment,之前故障的primary segment在使用gprecoverseg恢复后,之前的primary不会切回primary segment,而是变为mirror segment。
二、Preferred role和current role的概念
当配置了mirror segment时,存在Preferred role和current role的概念,当primary segment节点down了,mirror segment节点会接管primary的位置,成为新的primary segment,之前down掉的primary segment在online后会成为mirror segment。那么预设角色是指正常情况下primary segment各种的位置,当前角色是只出现failover后,mirror取代之前的primary,当前的segment的角色。
# 显示primary、mirror segment存在的问题
gpstate -e
#显示mirror segment实例的当前角色,同步状态等信息
gpstate -m
#可以通过gprecover -r将处于当前角色的segment切回预设角色。
gprecoverseg -r
# 显示primary、mirror segment存在的问题
gpstate -e
案例1:
3个primary segment+3个mirror segment+ 1个master server模拟一个主机宕机的情况。
分析可能出现的问题:
一个主机host2宕机,上面相应的1个primary segment和1个mirror segment都
会down掉。由于做了mirror,host2 primary对于的mirror在host1上,会被激活,成为新的primary节点,当前的角色也从mirror切换成primary。故障的primary节点在online后,会成功新的mirror节点,当前角色从primary角色切换成mirror角色。
模拟故障前的信息确认:
$ gpstate  --查看gp数据库的总体状态
-   Master instance                                           = Active    --master状态                 
-   Master standby                                            = No master standby configured
-   Total segment instance count from metadata                = 6      --segment节点数               
-----------------------------------------------------                                  
-   Primary Segment Status                                                             
-----------------------------------------------------                                  
-   Total primary segments                                    = 3    
-   Total primary segment valid (at master)                   = 3                    
-   Total primary segment failures (at master)                = 0                      
-   Total number of postmaster.pid files missing              = 0                      
-   Total number of postmaster.pid files found                = 3                      
-   Total number of postmaster.pid PIDs missing               = 0                      
-   Total number of postmaster.pid PIDs found                 = 3                      
-   Total number of /tmp lock files missing                   = 0                      
-   Total number of /tmp lock files found                     = 3                      
-   Total number postmaster processes missing                 = 0                      
-   Total number postmaster processes found                   = 3                        
-----------------------------------------------------                                  
-   Mirror Segment Status                                                              
-----------------------------------------------------                                  
-   Total mirror segments                                     = 3                      
-   Total mirror segment valid (at master)                    = 3                      
-   Total mirror segment failures (at master)                 = 0                      
-   Total number of postmaster.pid files missing              = 0                      
-   Total number of postmaster.pid files found                = 3                      
-   Total number of postmaster.pid PIDs missing               = 0                      
-   Total number of postmaster.pid PIDs found                 = 3                      
-   Total number of /tmp lock files missing                   = 0  
$ gpstate -m   --查看mirror节点情况
-Obtaining Segment details from master...                       
--------------------------------------------------------------  
--Current GPDB mirror list and status                           
--Type = Spread                                                 
--------------------------------------------------------------  
-   Mirror   Datadir              Port    Status    Data Status 
-   gp02     /gpsegment2/gpseg0   50000   Passive   Synchronized
-   gp03     /gpsegment2/gpseg1   50000   Passive   Synchronized
-   gp01     /gpsegment2/gpseg2   50000   Passive   Synchronized
-------------------------------------------------------------- 
$ gpstate -e --显示primary、mirror segment存在的问题
-Gathering data from segments...                                                          -----------------------------------------------------                                     -Segment Mirroring Status Report                                                          -----------------------------------------------------                                     -All segments are running normally
模拟gp02的主机故障:
[gp02]# killall -u gpadmin --杀掉gp02的gpadmin下所有的进程
[root@gp02 ~]# killall -u gpadmin
[root@gp02 ~]# ps -ef | grep gpadmin
root      6733  3155  0 03:26 pts/0    00:00:00 grep gpadmin
查询故障后,gp数据库的状态:
$ gpstate -e
-----------------------------------------------------              
-Segment Mirroring Status Report                                   
-----------------------------------------------------              
-Segments with Primary and Mirror Roles Switched                   
-   Current Primary   Port    Mirror   Port                        
-   gp03              50000   gp02     40000                       
-----------------------------------------------------              
-Primaries in Change Tracking                                      
-   Current Primary   Port    Change tracking size   Mirror   Port 
-   gp01              40000   100 MB                 gp02     50000
-   gp03              50000   100 MB                 gp02     40000
--gp02的primary segment对于的mirror segment的位置:gp03的/gpsegment2/gpseg1。
显示mirror segment实例的当前角色,同步状态等信息
$ gpstate -m
[INFO]:--------------------------------------------------------------                     [INFO]:--Current GPDB mirror list and status                                              [INFO]:--Type = Spread                       
  [INFO]:--------------------------------------------------------------                     [INFO]:-   Mirror   Datadir              Port    Status              Data Status          [WARNING]:-gp02     /gpsegment2/gpseg0   50000   Failed                              
  [INFO]:-   gp03     /gpsegment2/gpseg1   50000   Acting as Primary   Change Tracking      [INFO]:-   gp01     /gpsegment2/gpseg2   50000   Passive             Synchronized         [INFO]:--------------------------------------------------------------                     [WARNING]:-1 segment(s) configured as mirror(s) are acting as primaries                   [WARNING]:-1 segment(s) configured as mirror(s) have failed                               [WARNING]:-1 mirror segment(s) acting as primaries are in change tracking
  查询结果gpseg0 的mirror segment 状态为failed,gpseg1的mirror成为了primary节点。
  [INFO]:-----------------------------------------------------                              [INFO]:-   Segment Info                                                                   [INFO]:-      Hostname                          = gp02                                    [INFO]:-      Address                           = gp02                                    [INFO]:-      Datadir                           = /gpsegment2/gpseg0                      [INFO]:-      Port                              = 50000                                   [INFO]:-   Mirroring Info                                                                 [INFO]:-      Current role                      = Mirror                                  [INFO]:-      Preferred role                    = Mirror                                  [WARNING]:-   Mirror status                     = Out of Sync             <<<<<<<<        [INFO]:-   Status                                                                         [WARNING]:-   PID                               = Not found               <<<<<<<<        [WARNING]:-   Configuration reports status as   = Down                    <<<<<<<<        [WARNING]:-   Segment status                    = Down in configuration   <<<<<<<<        [INFO]:-----------------------------------------------------                              [INFO]:-   Segment Info                                                                   [INFO]:-      Hostname                          = gp03                                    [INFO]:-      Address                           = gp03                                    [INFO]:-      Datadir                           = /gpsegment2/gpseg1                      [INFO]:-      Port                              = 50000                                   [INFO]:-   Mirroring Info                                                                 [INFO]:-      Current role                      = Primary                                 [INFO]:-      Preferred role                    = Mirror                                  [INFO]:-      Mirror status                     = Change Tracking                         [INFO]:-   Change Tracking Info                                                           [INFO]:-      Change tracking data size         = 100 MB                                  [INFO]:-   Status                                                                         [INFO]:-      PID                               = 5901                                    [INFO]:-      Configuration reports status as   = Up                                      [INFO]:-      Database status                   = Up                                      [INFO]:-----------------------------------------------------                              [INFO]:-   Segment Info                                                                   [INFO]:-      Hostname                          = gp02                                    [INFO]:-      Address                           = gp02                                    [INFO]:-      Datadir                           = /gpsegment1/gpseg1                      [INFO]:-      Port                              = 40000                                   [INFO]:-   Mirroring Info                                                                 [INFO]:-      Current role                      = Mirror                                  [INFO]:-      Preferred role                    = Primary                                 [WARNING]:-   Mirror status                     = Out of Sync             <<<<<<<<        [INFO]:-   Status                                                                         [WARNING]:-   PID                               = Not found               <<<<<<<<        [WARNING]:-   Configuration reports status as   = Down                    <<<<<<<<        [WARNING]:-   Segment status                    = Down in configuration   <<<<<<<<        [INFO]:-----------------------------------------------------   
确定主机无故障后,恢复丢失的数据:
[gpadmin@gp01 gpsegment2]$ gprecoverseg
20140310:04:09:19:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Starting gprecoverseg with args:
20140310:04:09:19:021098 gprecoverseg:gp01:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.2.2.4 build 1 Community Edition'
20140310:04:09:19:021098 gprecoverseg:gp01:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.2.2.4 build 1 Community Edition) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Oct 17 2012 11:52:28'
20140310:04:09:19:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Obtaining Segment details from master...
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Greenplum instance recovery parameters
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Recovery type              = Standard
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Recovery 1 of 2
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Synchronization mode                        = Incremental
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance host                        = gp02
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance address                     = gp02
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance directory                   = /gpsegment2/gpseg0
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance port                        = 50000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance replication port            = 51000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance host               = gp01
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance address            = gp01
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance directory          = /gpsegment1/gpseg0
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance port               = 40000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance replication port   = 41000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Target                             = in-place
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Recovery 2 of 2
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Synchronization mode                        = Incremental
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance host                        = gp02
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance address                     = gp02
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance directory                   = /gpsegment1/gpseg1
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance port                        = 40000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Failed instance replication port            = 41000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance host               = gp03
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance address            = gp03
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance directory          = /gpsegment2/gpseg1
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance port               = 50000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Source instance replication port   = 51000
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:-   Recovery Target                             = in-place
20140310:04:09:20:021098 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
Continue with segment recovery procedure Yy|Nn (default=N):
> y
20140310:04:09:23:021098 gprecoverseg:gp01:gpadmin-[INFO]:-2 segment(s) to recover
20140310:04:09:23:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Ensuring 2 failed segment(s) are stopped
 
updating flat files
20140310:04:09:26:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Updating configuration with new mirrors
20140310:04:09:27:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Updating mirrors
.
20140310:04:09:28:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Starting mirrors
20140310:04:09:28:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Commencing parallel primary and mirror segment instance startup, please wait...
...
20140310:04:09:31:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Process results...
20140310:04:09:31:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Updating configuration to mark mirrors up
20140310:04:09:31:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Updating primaries
20140310:04:09:31:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Commencing parallel primary conversion of 2 segments, please wait...
..
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Process results...
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Done updating primaries
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-******************************************************************
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Updating segments for resynchronization is completed.
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-For segments updated successfully, resynchronization will continue in the background.
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-Use  gpstate -s  to check the resynchronization progress.
20140310:04:09:33:021098 gprecoverseg:gp01:gpadmin-[INFO]:-******************************************************************
a、gprecoverseg才用 Synchronization mode恢复gp02的segment节点丢失的数据。
b、采用增量同步的方式恢复/gpsegment1/gpseg1丢失的数据。--gp02 primary
c、采用增量同步的方式恢复/gpsegment2/gpseg0丢失的数据。--gp01 primary的mirror
恢复后查询gp数据库的状态:
$ gpstate -e --查询mirror存在的错误,查询显示gp02的primary节点被mirror替换掉,目前的primary的位置在gp03上。
[INFO]:-----------------------------------------------------
[INFO]:-Segment Mirroring Status Report                     
[INFO]:-----------------------------------------------------
[INFO]:-Segments with Primary and Mirror Roles Switched     
[INFO]:-   Current Primary   Port    Mirror   Port          
[INFO]:-   gp03              50000   gp02     40000
$ gpstate -m
[INFO]:-Obtaining Segment details from master..
[INFO]:--------------------------------------------------------------
[INFO]:--Current GPDB mirror list and status
[INFO]:--Type = Spread
[INFO]:--------------------------------------------------------------
[INFO]:-   Mirror   Datadir              Port    Status              Data Status
[INFO]:-   gp02     /gpsegment2/gpseg0   50000   Passive             Synchronized
[INFO]:-   gp03     /gpsegment2/gpseg1   50000   Acting as Primary   Synchronized
[INFO]:-   gp01     /gpsegment2/gpseg2   50000   Passive             Synchronized
[INFO]:--------------------------------------------------------------
[WARNING]:-1 segment(s) configured as mirror(s) are acting as primaries
切换current role到prefered role
[gpadmin@gp01 gpsegment2]$ gprecoverseg -r
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Starting gprecoverseg with args: -r
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.2.2.4 build 1 Community Edition'
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.2.2.4 build 1 Community Edition) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Oct 17 2012 11:52:28'
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Obtaining Segment details from master...
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Greenplum instance recovery parameters
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Recovery type              = Rebalance
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Unbalanced segment 1 of 2
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance host               = gp03
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance address            = gp03
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance directory          = /gpsegment2/gpseg1
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance port               = 50000
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance replication port   = 51000
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Balanced role                          = Mirror
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Current role                           = Primary
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Unbalanced segment 2 of 2
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance host               = gp02
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance address            = gp02
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance directory          = /gpsegment1/gpseg1
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance port               = 40000
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Unbalanced instance replication port   = 41000
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Balanced role                          = Primary
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:-   Current role                           = Mirror
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[INFO]:----------------------------------------------------------
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[WARNING]:-This operation will cancel queries that are currently executing.
20140310:04:35:51:021852 gprecoverseg:gp01:gpadmin-[WARNING]:-Connections to the database however will not be interrupted.
Continue with segment rebalance procedure Yy|Nn (default=N):
> y
20140310:04:36:01:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Getting unbalanced segments
20140310:04:36:01:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Stopping unbalanced primary segments...
..
20140310:04:36:03:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Triggering segment reconfiguration
20140310:04:36:07:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Starting segment synchronization
............
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-******************************************************************
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-The rebalance operation has completed successfully.
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-There is a resynchronization running in the background to bring all
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-segments in sync.
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-Use gpstate -s to check the resynchronization progress.
20140310:04:36:20:021852 gprecoverseg:gp01:gpadmin-[INFO]:-******************************************************************
查询切换后的状态:
$ gpstate -e
[INFO]:-Starting gpstate with args: -e  
[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.2.2.4 build 1 Community Edition'  
[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.2.2.4 build 1 Community Edition) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Oct 17 2012 11:52:28'
[INFO]:-Obtaining Segment details from master...    
[INFO]:-Gathering data from segments...
[INFO]:-----------------------------------------------------    
[INFO]:-Segment Mirroring Status Report 
[INFO]:-----------------------------------------------------
[INFO]:-Segment Pairs in Resynchronization
[INFO]:-   Current Primary   Port    Resync mode   Est. resync progress   Data synced   Est. total to sync    Est. resync end time   Change tracking size   Mirror   Port   
[INFO]:-   gp02  40000   Incremental   100% 224 kB  Sync complete; awaiting config change  100 MB     gp03     50000  
再次查询gp状态:
$ gpstate -e
[INFO]:-Starting gpstate with args: -e   
[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.2.2.4 build 1 Community Edition'   
[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.2.2.4 build 1 Community Edition) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Oct 17 2012 11:52:28' 
[INFO]:-Obtaining Segment details from master...
[INFO]:-Gathering data from segments...  
[INFO]:-----------------------------------------------------
[INFO]:-Segment Mirroring Status Report  
[INFO]:-----------------------------------------------------
[INFO]:-All segments are running normally
查询prefer role和current role:
[INFO]:-----------------------------------------------------
[INFO]:--Master Configuration & Status   
[INFO]:-----------------------------------------------------
[INFO]:-   Master host  = gp01
[INFO]:-   Master postgres process ID     = 12423    
[INFO]:-   Master data directory    = /gpmaster/gpseg-1    
[INFO]:-   Master port  = 5432
[INFO]:-   Master current role= dispatch 
[INFO]:-   Greenplum initsystem version   = 4.2.2.4 build 1 Community Edition
[INFO]:-   Greenplum current version= PostgreSQL 8.2.15 (Greenplum Database 4.2.2.4 build 1 Community Edition) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Oct 17 2012 11:52:28
[INFO]:-   Postgres version   = 8.2.15   
[INFO]:-   Master standby     = No master standby configured
[INFO]:-----------------------------------------------------
[INFO]:-Segment Instance Status Report   
[INFO]:-----------------------------------------------------
[INFO]:-   Segment Info
[INFO]:-Hostname  = gp01
[INFO]:-Address   = gp01
[INFO]:-Datadir   = /gpsegment1/gpseg0   
[INFO]:-Port= 40000    
[INFO]:-   Mirroring Info    
[INFO]:-Current role    = Primary  
[INFO]:-Preferred role  = Primary  
[INFO]:-Mirror status   = Synchronized   
[INFO]:-   Status
[INFO]:-PID = 12390    
[INFO]:-Configuration reports status as   = Up 
[INFO]:-Database status = Up 
[INFO]:-----------------------------------------------------
[INFO]:-   Segment Info
[INFO]:-Hostname  = gp02
[INFO]:-Address   = gp02
[INFO]:-Datadir   = /gpsegment2/gpseg0   
[INFO]:-Port= 50000    
[INFO]:-   Mirroring Info    
[INFO]:-Current role    = Mirror   
[INFO]:-Preferred role  = Mirror   
[INFO]:-Mirror status   = Synchronized   
[INFO]:-   Status
[INFO]:-PID = 10689    
[INFO]:-Configuration reports status as   = Up 
[INFO]:-Segment status  = Up 
[INFO]:-----------------------------------------------------
[INFO]:-   Segment Info
[INFO]:-Hostname  = gp02
[INFO]:-Address   = gp02
[INFO]:-Datadir   = /gpsegment1/gpseg1   
[INFO]:-Port= 40000    
[INFO]:-   Mirroring Info    
[INFO]:-Current role    = Primary  
[INFO]:-Preferred role  = Primary  
[INFO]:-Mirror status   = Synchronized   
[INFO]:-   Status
[INFO]:-PID = 10695    
[INFO]:-Configuration reports status as   = Up 
[INFO]:-Database status = Up 
[INFO]:-----------------------------------------------------
[INFO]:-   Segment Info
[INFO]:-Hostname  = gp03
[INFO]:-Address   = gp03
[INFO]:-Datadir   = /gpsegment2/gpseg1   
[INFO]:-Port= 50000    
[INFO]:-   Mirroring Info    
[INFO]:-Current role    = Mirror   
[INFO]:-Preferred role  = Mirror   
[INFO]:-Mirror status   = Synchronized   
[INFO]:-   Status
[INFO]:-PID = 10946    
[INFO]:-Configuration reports status as   = Up 
[INFO]:-Segment status  = Up 
[INFO]:-----------------------------------------------------
[INFO]:-   Segment Info
[INFO]:-Hostname  = gp03
[INFO]:-Address   = gp03
[INFO]:-Datadir   = /gpsegment1/gpseg2   
[INFO]:-Port= 40000    
[INFO]:-   Mirroring Info    
[INFO]:-Current role    = Primary  
[INFO]:-Preferred role  = Primary  
[INFO]:-Mirror status   = Synchronized   
[INFO]:-   Status
[INFO]:-PID = 5907
[INFO]:-Configuration reports status as   = Up 
[INFO]:-Database status = Up 
[INFO]:-----------------------------------------------------
[INFO]:-   Segment Info
[INFO]:-Hostname  = gp01
[INFO]:-Address   = gp01
[INFO]:-Datadir   = /gpsegment2/gpseg2   
[INFO]:-Port= 50000    
[INFO]:-   Mirroring Info    
[INFO]:-Current role    = Mirror   
[INFO]:-Preferred role  = Mirror   
[INFO]:-Mirror status   = Synchronized   
[INFO]:-   Status
[INFO]:-PID = 14134    
[INFO]:-Configuration reports status as   = Up 
[INFO]:-Segment status  = Up 
current role切换回prefered role。

GreenPlum failover,primary和mirror切换实验 -- 重要的更多相关文章

  1. GreenPlum的Primary和Mirro切换恢复

    gp节点出现了acting as primary change tracking错误,判断是节点primary和mirror发生了切换 1.没有配置gp的日志,无法获取为什么切换了,待会儿看看默认日志 ...

  2. Greenplum failed segment的恢复方法--primary与mirror都可修复

    当在使用greenplum过程中有不当的操作时,可能会出现segment节点宕掉的情况(比如在greenplum运行的过程中停掉其中几台segment节点的服务器),通过下面的方法可以恢复segmen ...

  3. DataGuard failover dg role自动切换模式测试

    1,在脚本中代入create db flash backup point for recover dg 2,测试前主备库状态(备库现角色验证,主库监听状态-->有意stop) 主要验证思路, 脚 ...

  4. DG_Oracle DataGuard Failover主备节点切换(案例)

    2014-03-09 Created By BaoXinjian Thanks and Regards

  5. GreenPlum 数据库创建用户、文件空间、表空间、数据库

    前几篇文章介绍了GreenPlum数据库的安装.启动.关闭.状态检查.登录等操作,数据库已经创建好了,接下来介绍如何使用数据库.按照习惯,需要先创建测试用户.表空间.数据库.先创建测试用户dbdrea ...

  6. Greenplum 表空间和filespace的用法

    转载:https://yq.aliyun.com/articles/190 Greenplum支持表空间,创建表空间时,需要指定filespace.postgres=# \h create table ...

  7. Greeplum 系列(三) 基本用法

    Greeplum 系列(三) 基本用法 <PostgreSQL 教程>:https://www.yiibai.com/postgresql 一.Greeplum 登陆与创建 1.1 登陆 ...

  8. Greenplum 在Linux下的安装

    1.实验环境 1.1.硬件环境 Oracle VM VirtualBox虚拟机软件:三台Linux虚拟机:Centos 6.5:数据库:greenplum-db-4.3.9.1-build-1-rhe ...

  9. Greenplum failed segment的恢复方法

    [前记] Segment检测及故障切换机制GP Master首先会检测Primary状态,如果Primary不可连通,那么将会检测Mirror状态,Primary/Mirror状态总共有4种:1. P ...

随机推荐

  1. Linux 进程间通信(管道、共享内存、消息队列、信号量)

           进程通信 : 不同进程之间传播或交换信息    为什么要进程通信呢? 协同运行,项目模块化 通信原理 : 给多个进程提供一个都能访问到的缓冲区. 根据使用场景,我们能划分为以下几种通信 ...

  2. REST-framework之频率组件

    REST-framework之频率控制 一 频率简介 为了控制用户对某个url请求的频率,比如,一分钟以内,只能访问三次 二 自定义频率类,自定义频率规则 自定义的逻辑 ""&qu ...

  3. logrus 剖析之 formatter

    使用 logrus 通过 formatter 来定义输出日志的格式,具体例子如下: package main import ( log "github.com/Sirupsen/logrus ...

  4. AS3灰色图像

    一开始觉得AS3的滤镜很难使用,尤其是那些矩阵,让人望而生畏.最近写一个聊天模块,要用到离线状态下的灰色头像,于是认真研究了ColorMatrixFilter,发现其实也没有那么难.所谓的矩阵其实就是 ...

  5. pdfplumber模块初始用

    import pdfplumber import re def pdf_read(): pdf=pdfplumber.open('文件路径'")#文件路径,读取文件 page0=pdf.pa ...

  6. tkinter学习笔记_05

    10.菜单 menuber import tkinter as tk root = tk.Tk() root.title("xxx") root.geometry('200x100 ...

  7. vue3 父组件给子组件传值 provide & inject

    介绍 provide() 和 inject() 可以实现嵌套组件之间的数据传递. 这两个函数只能在 setup() 函数中使用. 父级组件中使用 provide() 函数向下传递数据. 子级组件中使用 ...

  8. zookeeper集群搭建及ZAB协议

    zookeeper集群搭建非常简单,准备三台安装好zookeeper服务器,在其zoo.cfg配置中分表添加如下配置 initLimit 10 集群中的follower与leader之间完成初始化同步 ...

  9. 在safari下input的placeholder设置行高失效

    在项目中遇到input的placeholder在safari下设置行高失效的问题,亲测 input{ width:250px; height:30px; line-height:30px; font- ...

  10. springmvc集成cxf的方法

    最近需要在项目中增加webservice接口,供三方调用,下面就把集成的方法展示如下,供大家参考: 第一步:服务端的发布; 1:配置web.xml文件,添加cxf的servlet <servle ...