GreenPlum删除节点 – 记忆角落

GreenPlum删除节点

/ 0评 / 2

查看数据库当前状态

[gpadmin@jtnew59 ~]$ gpstate 

关闭当前数据库

[gpadmin@jtnew59 greenplum]$ gpstop -M fast

以管理模式启动数据库

[gpadmin@jtnew59 greenplum]$ gpstart -m

登录管理数据库并且获得修改权限

#进入utility
PGOPTIONS="-c gp_session_role=utility" psql -d postgres

#获得修改权限
set allow_system_table_mods='dml';

查看部分表信息

postgres=# select * from gp_segment_configuration order by 1;
 dbid | content | role | preferred_role | mode | status | port  | hostname  |  address  | replication_port | san_mounts 
------+---------+------+----------------+------+--------+-------+-----------+-----------+------------------+------------
    1 |      -1 | p    | p              | s    | u      |  5432 | huaxing00 | huaxing00 |                  | 
    2 |       0 | p    | p              | c    | u      | 40000 | huaxing00 | huaxing00 |            41000 | 
    3 |       1 | p    | p              | c    | u      | 40001 | huaxing00 | huaxing00 |            41001 | 
    4 |       2 | p    | p              | c    | u      | 40002 | huaxing00 | huaxing00 |            41002 | 
    5 |       3 | p    | p              | c    | u      | 40003 | huaxing00 | huaxing00 |            41003 | 
    6 |       4 | p    | p              | c    | u      | 40004 | huaxing00 | huaxing00 |            41004 | 
    7 |       5 | p    | p              | c    | u      | 40005 | huaxing00 | huaxing00 |            41005 | 
    8 |       6 | m    | p              | s    | d      | 40000 | huaxing01 | huaxing01 |            41000 | 
    9 |       7 | m    | p              | s    | d      | 40001 | huaxing01 | huaxing01 |            41001 | 
   10 |       8 | m    | p              | s    | d      | 40002 | huaxing01 | huaxing01 |            41002 | 
   11 |       9 | m    | p              | s    | d      | 40003 | huaxing01 | huaxing01 |            41003 | 
   12 |      10 | m    | p              | s    | d      | 40004 | huaxing01 | huaxing01 |            41004 | 
   13 |      11 | m    | p              | s    | d      | 40005 | huaxing01 | huaxing01 |            41005 | 
   14 |      12 | p    | p              | s    | u      | 40000 | huaxing02 | huaxing02 |            41000 | 
   15 |      13 | p    | p              | s    | u      | 40001 | huaxing02 | huaxing02 |            41001 | 
   16 |      14 | p    | p              | s    | u      | 40002 | huaxing02 | huaxing02 |            41002 | 
   17 |      15 | p    | p              | s    | u      | 40003 | huaxing02 | huaxing02 |            41003 | 
   18 |      16 | p    | p              | s    | u      | 40004 | huaxing02 | huaxing02 |            41004 | 
   19 |      17 | p    | p              | s    | u      | 40005 | huaxing02 | huaxing02 |            41005 | 
   20 |      18 | p    | p              | s    | u      | 40000 | huaxing03 | huaxing03 |            41000 | 
   21 |      19 | p    | p              | s    | u      | 40001 | huaxing03 | huaxing03 |            41001 | 
   22 |      20 | p    | p              | s    | u      | 40002 | huaxing03 | huaxing03 |            41002 | 
   23 |      21 | p    | p              | s    | u      | 40003 | huaxing03 | huaxing03 |            41003 | 
   24 |      22 | p    | p              | s    | u      | 40004 | huaxing03 | huaxing03 |            41004 | 
   25 |      23 | p    | p              | s    | u      | 40005 | huaxing03 | huaxing03 |            41005 | 
   26 |      24 | p    | p              | s    | u      | 40000 | huaxing04 | huaxing04 |            41000 | 
   27 |      25 | p    | p              | s    | u      | 40001 | huaxing04 | huaxing04 |            41001 | 
   28 |      26 | p    | p              | s    | u      | 40002 | huaxing04 | huaxing04 |            41002 | 
   29 |      27 | p    | p              | s    | u      | 40003 | huaxing04 | huaxing04 |            41003 | 
   30 |      28 | p    | p              | s    | u      | 40004 | huaxing04 | huaxing04 |            41004 | 
   31 |      29 | p    | p              | s    | u      | 40005 | huaxing04 | huaxing04 |            41005 | 
   32 |      30 | p    | p              | s    | u      | 40000 | huaxing05 | huaxing05 |            41000 | 
   33 |      31 | p    | p              | s    | u      | 40001 | huaxing05 | huaxing05 |            41001 | 
   34 |      32 | p    | p              | s    | u      | 40002 | huaxing05 | huaxing05 |            41002 | 
   35 |      33 | p    | p              | s    | u      | 40003 | huaxing05 | huaxing05 |            41003 | 
   36 |      34 | p    | p              | s    | u      | 40004 | huaxing05 | huaxing05 |            41004 | 
   37 |      35 | p    | p              | s    | u      | 40005 | huaxing05 | huaxing05 |            41005 | 
   38 |       0 | m    | m              | s    | d      | 50000 | huaxing01 | huaxing01 |            51000 | 
   39 |       1 | m    | m              | s    | d      | 50001 | huaxing01 | huaxing01 |            51001 | 
   40 |       2 | m    | m              | s    | d      | 50002 | huaxing01 | huaxing01 |            51002 | 
   41 |       3 | m    | m              | s    | d      | 50003 | huaxing01 | huaxing01 |            51003 | 
   42 |       4 | m    | m              | s    | d      | 50004 | huaxing01 | huaxing01 |            51004 | 
   43 |       5 | m    | m              | s    | d      | 50005 | huaxing01 | huaxing01 |            51005 | 
   44 |       6 | p    | m              | c    | u      | 50000 | huaxing02 | huaxing02 |            51000 | 
   45 |       7 | p    | m              | c    | u      | 50001 | huaxing02 | huaxing02 |            51001 | 
   46 |       8 | p    | m              | c    | u      | 50002 | huaxing02 | huaxing02 |            51002 | 
   47 |       9 | p    | m              | c    | u      | 50003 | huaxing02 | huaxing02 |            51003 | 
   48 |      10 | p    | m              | c    | u      | 50004 | huaxing02 | huaxing02 |            51004 | 
   49 |      11 | p    | m              | c    | u      | 50005 | huaxing02 | huaxing02 |            51005 | 
   50 |      12 | m    | m              | s    | u      | 50000 | huaxing03 | huaxing03 |            51000 | 
   51 |      13 | m    | m              | s    | u      | 50001 | huaxing03 | huaxing03 |            51001 | 
   52 |      14 | m    | m              | s    | u      | 50002 | huaxing03 | huaxing03 |            51002 | 
   53 |      15 | m    | m              | s    | u      | 50003 | huaxing03 | huaxing03 |            51003 | 
   54 |      16 | m    | m              | s    | u      | 50004 | huaxing03 | huaxing03 |            51004 | 
   55 |      17 | m    | m              | s    | u      | 50005 | huaxing03 | huaxing03 |            51005 | 
   56 |      18 | m    | m              | s    | u      | 50000 | huaxing04 | huaxing04 |            51000 | 
   57 |      19 | m    | m              | s    | u      | 50001 | huaxing04 | huaxing04 |            51001 | 
   58 |      20 | m    | m              | s    | u      | 50002 | huaxing04 | huaxing04 |            51002 | 
   59 |      21 | m    | m              | s    | u      | 50003 | huaxing04 | huaxing04 |            51003 | 
   60 |      22 | m    | m              | s    | u      | 50004 | huaxing04 | huaxing04 |            51004 | 
   61 |      23 | m    | m              | s    | u      | 50005 | huaxing04 | huaxing04 |            51005 | 
   62 |      24 | m    | m              | s    | u      | 50000 | huaxing05 | huaxing05 |            51000 | 
   63 |      25 | m    | m              | s    | u      | 50001 | huaxing05 | huaxing05 |            51001 | 
   64 |      26 | m    | m              | s    | u      | 50002 | huaxing05 | huaxing05 |            51002 | 
   65 |      27 | m    | m              | s    | u      | 50003 | huaxing05 | huaxing05 |            51003 | 
   66 |      28 | m    | m              | s    | u      | 50004 | huaxing05 | huaxing05 |            51004 | 
   67 |      29 | m    | m              | s    | u      | 50005 | huaxing05 | huaxing05 |            51005 | 
   68 |      30 | m    | m              | s    | u      | 50000 | huaxing00 | huaxing00 |            51000 | 
   69 |      31 | m    | m              | s    | u      | 50001 | huaxing00 | huaxing00 |            51001 | 
   70 |      32 | m    | m              | s    | u      | 50002 | huaxing00 | huaxing00 |            51002 | 
   71 |      33 | m    | m              | s    | u      | 50003 | huaxing00 | huaxing00 |            51003 | 
   72 |      34 | m    | m              | s    | u      | 50004 | huaxing00 | huaxing00 |            51004 | 
   73 |      35 | m    | m              | s    | u      | 50005 | huaxing00 | huaxing00 |            51005 | 
(73 rows)


postgres=# select * from pg_filespace_entry order by 2;
 fsefsoid | fsedbid |      fselocation       
----------+---------+------------------------
     3052 |       1 | /data03/master/gpseg-1
     3052 |       2 | /data01/gp/p/gpseg0
     3052 |       3 | /data02/gp/p/gpseg1
     3052 |       4 | /data03/gp/p/gpseg2
     3052 |       5 | /data04/gp/p/gpseg3
     3052 |       6 | /data05/gp/p/gpseg4
     3052 |       7 | /data06/gp/p/gpseg5
     3052 |       8 | /data01/gp/p/gpseg6
     3052 |       9 | /data02/gp/p/gpseg7
     3052 |      10 | /data03/gp/p/gpseg8
     3052 |      11 | /data04/gp/p/gpseg9
     3052 |      12 | /data05/gp/p/gpseg10
     3052 |      13 | /data06/gp/p/gpseg11
     3052 |      14 | /data01/gp/p/gpseg12
     3052 |      15 | /data02/gp/p/gpseg13
     3052 |      16 | /data03/gp/p/gpseg14
     3052 |      17 | /data04/gp/p/gpseg15
     3052 |      18 | /data05/gp/p/gpseg16
     3052 |      19 | /data06/gp/p/gpseg17
     3052 |      20 | /data01/gp/p/gpseg18
     3052 |      21 | /data02/gp/p/gpseg19
     3052 |      22 | /data03/gp/p/gpseg20
     3052 |      23 | /data04/gp/p/gpseg21
     3052 |      24 | /data05/gp/p/gpseg22
     3052 |      25 | /data06/gp/p/gpseg23
     3052 |      26 | /data01/gp/p/gpseg24
     3052 |      27 | /data02/gp/p/gpseg25
     3052 |      28 | /data03/gp/p/gpseg26
     3052 |      29 | /data04/gp/p/gpseg27
     3052 |      30 | /data05/gp/p/gpseg28
     3052 |      31 | /data06/gp/p/gpseg29
     3052 |      32 | /data01/gp/p/gpseg30
     3052 |      33 | /data02/gp/p/gpseg31
     3052 |      34 | /data03/gp/p/gpseg32
     3052 |      35 | /data04/gp/p/gpseg33
     3052 |      36 | /data05/gp/p/gpseg34
     3052 |      37 | /data06/gp/p/gpseg35
     3052 |      38 | /data07/gp/m/gpseg0
     3052 |      39 | /data08/gp/m/gpseg1
     3052 |      40 | /data09/gp/m/gpseg2
     3052 |      41 | /data10/gp/m/gpseg3
     3052 |      42 | /data11/gp/m/gpseg4
     3052 |      43 | /data12/gp/m/gpseg5
     3052 |      44 | /data07/gp/m/gpseg6
     3052 |      45 | /data08/gp/m/gpseg7
     3052 |      46 | /data09/gp/m/gpseg8
     3052 |      47 | /data10/gp/m/gpseg9
     3052 |      48 | /data11/gp/m/gpseg10
     3052 |      49 | /data12/gp/m/gpseg11
     3052 |      50 | /data07/gp/m/gpseg12
     3052 |      51 | /data08/gp/m/gpseg13
     3052 |      52 | /data09/gp/m/gpseg14
     3052 |      53 | /data10/gp/m/gpseg15
     3052 |      54 | /data11/gp/m/gpseg16
     3052 |      55 | /data12/gp/m/gpseg17
     3052 |      56 | /data07/gp/m/gpseg18
     3052 |      57 | /data08/gp/m/gpseg19
     3052 |      58 | /data09/gp/m/gpseg20
     3052 |      59 | /data10/gp/m/gpseg21
     3052 |      60 | /data11/gp/m/gpseg22
     3052 |      61 | /data12/gp/m/gpseg23
     3052 |      62 | /data07/gp/m/gpseg24
     3052 |      63 | /data08/gp/m/gpseg25
     3052 |      64 | /data09/gp/m/gpseg26
     3052 |      65 | /data10/gp/m/gpseg27
     3052 |      66 | /data11/gp/m/gpseg28
     3052 |      67 | /data12/gp/m/gpseg29
     3052 |      68 | /data07/gp/m/gpseg30
     3052 |      69 | /data08/gp/m/gpseg31
     3052 |      70 | /data09/gp/m/gpseg32
     3052 |      71 | /data10/gp/m/gpseg33
     3052 |      72 | /data11/gp/m/gpseg34
     3052 |      73 | /data12/gp/m/gpseg35
(73 rows)

删除节点

因需要移除 huaxing01节点

从gp_segment_configuration表,根据preferred_role = p,hostname = huaxing01 可知content是:6,7,8,9,10,11

delete from gp_segment_configuration where content  in (6,7,8,9,10,11);

#删除后 mir需要闭环,因为需要更新
update gp_segment_configuration set hostname='huaxing02',address  ='huaxing02' where hostname='huaxing01';


#删除后的信息,看完就会懂了
postgres=# select * from gp_segment_configuration order by 1;
 dbid | content | role | preferred_role | mode | status | port  | hostname  |  address  | replication_port | san_mounts 
------+---------+------+----------------+------+--------+-------+-----------+-----------+------------------+------------
    1 |      -1 | p    | p              | s    | u      |  5432 | huaxing00 | huaxing00 |                  | 
    2 |       0 | p    | p              | c    | u      | 40000 | huaxing00 | huaxing00 |            41000 | 
    3 |       1 | p    | p              | c    | u      | 40001 | huaxing00 | huaxing00 |            41001 | 
    4 |       2 | p    | p              | c    | u      | 40002 | huaxing00 | huaxing00 |            41002 | 
    5 |       3 | p    | p              | c    | u      | 40003 | huaxing00 | huaxing00 |            41003 | 
    6 |       4 | p    | p              | c    | u      | 40004 | huaxing00 | huaxing00 |            41004 | 
    7 |       5 | p    | p              | c    | u      | 40005 | huaxing00 | huaxing00 |            41005 | 
   14 |      12 | p    | p              | s    | u      | 40000 | huaxing02 | huaxing02 |            41000 | 
   15 |      13 | p    | p              | s    | u      | 40001 | huaxing02 | huaxing02 |            41001 | 
   16 |      14 | p    | p              | s    | u      | 40002 | huaxing02 | huaxing02 |            41002 | 
   17 |      15 | p    | p              | s    | u      | 40003 | huaxing02 | huaxing02 |            41003 | 
   18 |      16 | p    | p              | s    | u      | 40004 | huaxing02 | huaxing02 |            41004 | 
   19 |      17 | p    | p              | s    | u      | 40005 | huaxing02 | huaxing02 |            41005 | 
   20 |      18 | p    | p              | s    | u      | 40000 | huaxing03 | huaxing03 |            41000 | 
   21 |      19 | p    | p              | s    | u      | 40001 | huaxing03 | huaxing03 |            41001 | 
   22 |      20 | p    | p              | s    | u      | 40002 | huaxing03 | huaxing03 |            41002 | 
   23 |      21 | p    | p              | s    | u      | 40003 | huaxing03 | huaxing03 |            41003 | 
   24 |      22 | p    | p              | s    | u      | 40004 | huaxing03 | huaxing03 |            41004 | 
   25 |      23 | p    | p              | s    | u      | 40005 | huaxing03 | huaxing03 |            41005 | 
   26 |      24 | p    | p              | s    | u      | 40000 | huaxing04 | huaxing04 |            41000 | 
   27 |      25 | p    | p              | s    | u      | 40001 | huaxing04 | huaxing04 |            41001 | 
   28 |      26 | p    | p              | s    | u      | 40002 | huaxing04 | huaxing04 |            41002 | 
   29 |      27 | p    | p              | s    | u      | 40003 | huaxing04 | huaxing04 |            41003 | 
   30 |      28 | p    | p              | s    | u      | 40004 | huaxing04 | huaxing04 |            41004 | 
   31 |      29 | p    | p              | s    | u      | 40005 | huaxing04 | huaxing04 |            41005 | 
   32 |      30 | p    | p              | s    | u      | 40000 | huaxing05 | huaxing05 |            41000 | 
   33 |      31 | p    | p              | s    | u      | 40001 | huaxing05 | huaxing05 |            41001 | 
   34 |      32 | p    | p              | s    | u      | 40002 | huaxing05 | huaxing05 |            41002 | 
   35 |      33 | p    | p              | s    | u      | 40003 | huaxing05 | huaxing05 |            41003 | 
   36 |      34 | p    | p              | s    | u      | 40004 | huaxing05 | huaxing05 |            41004 | 
   37 |      35 | p    | p              | s    | u      | 40005 | huaxing05 | huaxing05 |            41005 | 
   38 |       0 | m    | m              | s    | d      | 50000 | huaxing01 | huaxing01 |            51000 | 
   39 |       1 | m    | m              | s    | d      | 50001 | huaxing01 | huaxing01 |            51001 | 
   40 |       2 | m    | m              | s    | d      | 50002 | huaxing01 | huaxing01 |            51002 | 
   41 |       3 | m    | m              | s    | d      | 50003 | huaxing01 | huaxing01 |            51003 | 
   42 |       4 | m    | m              | s    | d      | 50004 | huaxing01 | huaxing01 |            51004 | 
   43 |       5 | m    | m              | s    | d      | 50005 | huaxing01 | huaxing01 |            51005 | 
   50 |      12 | m    | m              | s    | u      | 50000 | huaxing03 | huaxing03 |            51000 | 
   51 |      13 | m    | m              | s    | u      | 50001 | huaxing03 | huaxing03 |            51001 | 
   52 |      14 | m    | m              | s    | u      | 50002 | huaxing03 | huaxing03 |            51002 | 
   53 |      15 | m    | m              | s    | u      | 50003 | huaxing03 | huaxing03 |            51003 | 
   54 |      16 | m    | m              | s    | u      | 50004 | huaxing03 | huaxing03 |            51004 | 
   55 |      17 | m    | m              | s    | u      | 50005 | huaxing03 | huaxing03 |            51005 | 
   56 |      18 | m    | m              | s    | u      | 50000 | huaxing04 | huaxing04 |            51000 | 
   57 |      19 | m    | m              | s    | u      | 50001 | huaxing04 | huaxing04 |            51001 | 
   58 |      20 | m    | m              | s    | u      | 50002 | huaxing04 | huaxing04 |            51002 | 
   59 |      21 | m    | m              | s    | u      | 50003 | huaxing04 | huaxing04 |            51003 | 
   60 |      22 | m    | m              | s    | u      | 50004 | huaxing04 | huaxing04 |            51004 | 
   61 |      23 | m    | m              | s    | u      | 50005 | huaxing04 | huaxing04 |            51005 | 
   62 |      24 | m    | m              | s    | u      | 50000 | huaxing05 | huaxing05 |            51000 | 
   63 |      25 | m    | m              | s    | u      | 50001 | huaxing05 | huaxing05 |            51001 | 
   64 |      26 | m    | m              | s    | u      | 50002 | huaxing05 | huaxing05 |            51002 | 
   65 |      27 | m    | m              | s    | u      | 50003 | huaxing05 | huaxing05 |            51003 | 
   66 |      28 | m    | m              | s    | u      | 50004 | huaxing05 | huaxing05 |            51004 | 
   67 |      29 | m    | m              | s    | u      | 50005 | huaxing05 | huaxing05 |            51005 | 
   68 |      30 | m    | m              | s    | u      | 50000 | huaxing00 | huaxing00 |            51000 | 
   69 |      31 | m    | m              | s    | u      | 50001 | huaxing00 | huaxing00 |            51001 | 
   70 |      32 | m    | m              | s    | u      | 50002 | huaxing00 | huaxing00 |            51002 | 
   71 |      33 | m    | m              | s    | u      | 50003 | huaxing00 | huaxing00 |            51003 | 
   72 |      34 | m    | m              | s    | u      | 50004 | huaxing00 | huaxing00 |            51004 | 
   73 |      35 | m    | m              | s    | u      | 50005 | huaxing00 | huaxing00 |            51005 | 
   

注意:如遇到content中断不连续,需要重新连接,不然启动的时候会报错误:

postgres=# update gp_segment_configuration set content=content-6 where content>5;
ERROR:  duplicate key value violates unique constraint "gp_segment_config_content_preferred_role_index"
DETAIL:  Key (content, preferred_role)=(25, p) already exists.

手动一个一个更新:
update gp_segment_configuration set content=content-6 where content=12;
...
update gp_segment_configuration set content=content-6 where content=35;

根据gp_segment_configuration表的dbid可知 pg_filespace_entry表fsedbid为:8,9,10,11,12,13,44,45,46,47,48,49

delete from pg_filespace_entry where fsedbid in (8,9,10,11,12,13,44,45,46,47,48,49);

原来73个节点 包含master 刨除master就是72个 删掉了两台服务器12个 那就是60个了

postgres=# select * from gp_id;
gpname   | numsegments | dbid | content 
-----------+-------------+------+---------
 Greenplum |          -1 |   -1 |      -1
 
 #更新
update gp_id set numsegments=60;
update gp_id set dbid=1;
 
 postgres=# select * from gp_id;
  gpname   | numsegments | dbid | content 
-----------+-------------+------+---------
 Greenplum |          60 |    1 |      -1
(1 row)

退出管理模式,正常启动数据库

文件夹也需要闭环处理--->到huaxing02的mirror下 分别 :

mv gpseg6 gpseg0
mv gpseg7 gpseg1
mv gpseg8 gpseg2
mv gpseg9 gpseg3
mv gpseg10 gpseg4
mv gpseg11 gpseg5

退出维护模式,请启动数据库:

gpstop -m
gpstart -a

重启数据库会节点异常报错,需要进行异常同步:

[gpadmin@huaxing00 ~]$ gpstart -a
20210225:22:37:13:036328 gpstart:huaxing00:gpadmin-[INFO]:-Starting gpstart with args: -a
20210225:22:37:13:036328 gpstart:huaxing00:gpadmin-[INFO]:-Gathering information and validating the environment...
20210225:22:37:14:036328 gpstart:huaxing00:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 4.3.11.3 build 1'
20210225:22:37:14:036328 gpstart:huaxing00:gpadmin-[INFO]:-Greenplum Catalog Version: '201310150'
20210225:22:37:14:036328 gpstart:huaxing00:gpadmin-[INFO]:-Starting Master instance in admin mode
20210225:22:37:15:036328 gpstart:huaxing00:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20210225:22:37:15:036328 gpstart:huaxing00:gpadmin-[INFO]:-Obtaining Segment details from master...
20210225:22:37:15:036328 gpstart:huaxing00:gpadmin-[INFO]:-Setting new master era
20210225:22:37:15:036328 gpstart:huaxing00:gpadmin-[INFO]:-Master Started...
20210225:22:37:15:036328 gpstart:huaxing00:gpadmin-[INFO]:-Shutting down master
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipping startup of segment marked down in configuration: on huaxing02 directory /data07/gp/m/gpseg0 <<<<<
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipping startup of segment marked down in configuration: on huaxing02 directory /data08/gp/m/gpseg1 <<<<<
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipping startup of segment marked down in configuration: on huaxing02 directory /data09/gp/m/gpseg2 <<<<<
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipping startup of segment marked down in configuration: on huaxing02 directory /data10/gp/m/gpseg3 <<<<<
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipping startup of segment marked down in configuration: on huaxing02 directory /data11/gp/m/gpseg4 <<<<<
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipping startup of segment marked down in configuration: on huaxing02 directory /data12/gp/m/gpseg5 <<<<<
20210225:22:37:16:036328 gpstart:huaxing00:gpadmin-[INFO]:-Commencing parallel primary and mirror segment instance startup, please wait...
...................................................... 
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-Process results...
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-----------------------------------------------------
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-   Successful segment starts                                            = 54
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-   Failed segment starts                                                = 0
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Skipped segment starts (segments are marked down in configuration)   = 6    <<<<<<<<
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-----------------------------------------------------
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-Successfully started 54 of 54 segment instances, skipped 6 other segments 
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-----------------------------------------------------
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[WARNING]:-****************************************************************************
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[WARNING]:-There are 6 segment(s) marked down in the database
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[WARNING]:-To recover from this current state, review usage of the gprecoverseg
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[WARNING]:-management utility which will recover failed segment instance databases.
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[WARNING]:-****************************************************************************
20210225:22:38:10:036328 gpstart:huaxing00:gpadmin-[INFO]:-Starting Master instance huaxing00 directory /data03/master/gpseg-1 
20210225:22:38:11:036328 gpstart:huaxing00:gpadmin-[INFO]:-Command pg_ctl reports Master huaxing00 instance active
20210225:22:38:14:036328 gpstart:huaxing00:gpadmin-[INFO]:-No standby master configured.  skipping...
20210225:22:38:14:036328 gpstart:huaxing00:gpadmin-[WARNING]:-Number of segments not attempted to start: 6
20210225:22:38:14:036328 gpstart:huaxing00:gpadmin-[INFO]:-Check status of database with gpstate utility

[gpadmin@huaxing00 ~]$ gpstate -m
20210225:22:38:19:037332 gpstate:huaxing00:gpadmin-[INFO]:-Starting gpstate with args: -m
20210225:22:38:19:037332 gpstate:huaxing00:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.11.3 build 1'
20210225:22:38:19:037332 gpstate:huaxing00:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.11.3 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jan 24 2017 20:28:18'
20210225:22:38:19:037332 gpstate:huaxing00:gpadmin-[INFO]:-Obtaining Segment details from master...
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:--------------------------------------------------------------
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:--Current GPDB mirror list and status
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:--Type = Group
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:--------------------------------------------------------------
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   Mirror      Datadir                Port    Status    Data Status    
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-huaxing02   /data07/gp/m/gpseg0    50000   Failed                   <<<<<<<<
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-huaxing02   /data08/gp/m/gpseg1    50001   Failed                   <<<<<<<<
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-huaxing02   /data09/gp/m/gpseg2    50002   Failed                   <<<<<<<<
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-huaxing02   /data10/gp/m/gpseg3    50003   Failed                   <<<<<<<<
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-huaxing02   /data11/gp/m/gpseg4    50004   Failed                   <<<<<<<<
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-huaxing02   /data12/gp/m/gpseg5    50005   Failed                   <<<<<<<<
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing03   /data07/gp/m/gpseg12   50000   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing03   /data08/gp/m/gpseg13   50001   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing03   /data09/gp/m/gpseg14   50002   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing03   /data10/gp/m/gpseg15   50003   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing03   /data11/gp/m/gpseg16   50004   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing03   /data12/gp/m/gpseg17   50005   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing04   /data07/gp/m/gpseg18   50000   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing04   /data08/gp/m/gpseg19   50001   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing04   /data09/gp/m/gpseg20   50002   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing04   /data10/gp/m/gpseg21   50003   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing04   /data11/gp/m/gpseg22   50004   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing04   /data12/gp/m/gpseg23   50005   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing05   /data07/gp/m/gpseg24   50000   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing05   /data08/gp/m/gpseg25   50001   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing05   /data09/gp/m/gpseg26   50002   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing05   /data10/gp/m/gpseg27   50003   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing05   /data11/gp/m/gpseg28   50004   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing05   /data12/gp/m/gpseg29   50005   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing00   /data07/gp/m/gpseg30   50000   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing00   /data08/gp/m/gpseg31   50001   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing00   /data09/gp/m/gpseg32   50002   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing00   /data10/gp/m/gpseg33   50003   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing00   /data11/gp/m/gpseg34   50004   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:-   huaxing00   /data12/gp/m/gpseg35   50005   Passive   Synchronized
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[INFO]:--------------------------------------------------------------
20210225:22:38:20:037332 gpstate:huaxing00:gpadmin-[WARNING]:-6 segment(s) configured as mirror(s) have failed
#产生一个恢复的配置文件
[gpadmin@huaxing00 ~]$ gprecoverseg -o ./recov

#查看恢复的配置文件-可以知道哪些segment需要恢复
[gpadmin@huaxing00 ~]$ cat recov 
filespaceOrder=
huaxing02:50000:/data07/gp/m/gpseg0
huaxing02:50001:/data08/gp/m/gpseg1
huaxing02:50002:/data09/gp/m/gpseg2
huaxing02:50003:/data10/gp/m/gpseg3
huaxing02:50004:/data11/gp/m/gpseg4
huaxing02:50005:/data12/gp/m/gpseg5

#使用配置文件进行恢复
[gpadmin@huaxing00 ~]$ gprecoverseg -i ./recov

#查看恢复状态
[gpadmin@huaxing00 ~]$ gpstate -m

primary mirror角色对调:

数据库的主备就恢复了,但是还有一步,是可选的。要不要把primary mirror角色对调一下,因为现在mirror和primary和优先角色是相反的。 如果要对调,使用以下命令,会停库来处理:

gprecoverseg -r

参考:

https://blog.51cto.com/dengshuangfu/2395692?source=dra

https://blog.csdn.net/Explorren/article/details/103636269

发表评论

您的电子邮箱地址不会被公开。