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. Spring Cloud--Hystrix服务熔断(线程隔离/服务降级)代码实现

    一旦服务阻塞就进行服务降级或线程隔离.要不然就会导致大面积服务的瘫痪,Hystrix就是干这个的,一出现不健康的服务就进行熔断,不阻塞后面线程的执行. 引入依赖: 加注解: 这三个注解可以用一个注解搞 ...

  2. Pycharm配置文档教程

    1 桌面找到快捷方式 双击打开 2 3 4 需要自行注册 5 看自己喜欢选择 喜欢白色 选择左边 喜欢黑色 选择右边 6 7 可选 如果你对 Markdown 感兴趣:或者会用 就点击 install ...

  3. diverta 2019 Programming Contest 2

    A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...

  4. idea多级目录不展开的问题

    遇见了一个坑,idea新建的包,和它的上级包重叠在了一起,无法形成树状结构 原因呢,还是因为自己的不细心了,解决方案很简单,下面的是原情况 解决方案,点击左侧栏右上角的设置图表,注意看红框内 把第一行 ...

  5. 阿里企业邮箱smtp设置

    阿里的邮箱没有SMTP授权码信息 SMTP服务器:smtp.mxhichina.com

  6. jmeter进行压测的步骤

    1)安装jmeter和Badboy. 2)用badboy录制脚本,保存之后直接导出. 3)用jmeter打开badboy录制的脚本,假如是有参数的话,需要写一个csv的参数化文件,在jmeter中添加 ...

  7. HTML5的常用的标签

    HTML5对比HTML4新增了很多元素,也删除了部分元素(可以用css样式表方式替代)所以我只列出HTML5最常用的几个标签. head标签中: <meta http-equiv="X ...

  8. JAVA基础之ServletContext对象

    个人理解:  ServletContext类似字节码文件对象,在web创建的时候就自动生成了,并且是唯一的,跟随着项目和服务器共存亡了.通过这个对象,我们可以向里面存数据(键值对),也可以通过别的Se ...

  9. PHP 中使用ajax时一些常见错误总结整理

    这篇文章主要介绍了PHP 中使用ajax时一些常见错误总结整理的相关资料,需要的朋友可以参考下 PHP作为后端时,前端js使用ajax技术进行相互信息传送时,经常会出错误,对于新手来说有些手足无措.总 ...

  10. Android 常用开源库总结(持续更新)

    前言 收集了一些比较常见的开源库,特此记录(已收录350+).另外,本文将持续更新,大家有关于Android 优秀的开源库,也可以在下面留言. 一 .基本控件 TextView HTextView 一 ...