• GreenPlum failover,primary和mirror切换实验 -- 重要


    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。

  • 相关阅读:
    Redis系列八 使用Jedis
    Redis系列七 主从复制(Master/Slave)
    Redis系列六 Redis事务
    Redis系列五 Redis持久化
    Android7.0 应用内升级
    Redis系列四 Redis常见配置
    06方法
    python协程--yield和yield from
    Python2 生成器 简介
    使用virtualenv使得Python2和Python3并存
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/11327620.html
Copyright © 2020-2023  润新知