greenplum一次节点迁移
http://blog.csdn.net/wxc20062006/article/details/53321484
版本信息:
OS:CentOS release 6.5 (Final)
GP:greenplum4.3.8
1. 场景:其中一台服务器的所有节点信息需要迁移到新的服务器上,原始节点信息如下:
dbid | content | role | preferred_role | mode | status | port | hostname | address | replication_port | san_mounts
------+---------+------+----------------+------+--------+-------+----------+---------+------------------+------------
1 | -1 | p | p | s | u | 5432 | ETL | gmdw | |
2 | 0 | p | p | s | u | 40000 | ETL | gmdw | 41000 |
3 | 1 | p | p | s | u | 40001 | ETL | gmdw | 41001 |
4 | 2 | p | p | s | u | 40002 | ETL | gmdw | 41002 |
5 | 3 | p | p | s | u | 40003 | ETL | gmdw | 41003 |
6 | 4 | p | p | s | u | 40000 | storm1 | gsdw1 | 41000 |
7 | 5 | p | p | s | u | 40001 | storm1 | gsdw1 | 41001 |
8 | 6 | p | p | s | u | 40002 | storm1 | gsdw1 | 41002 |
9 | 7 | p | p | s | u | 40003 | storm1 | gsdw1 | 41003 |
10 | 8 | p | p | s | u | 40000 | storm2 | gsdw2 | 41000 |
11 | 9 | p | p | s | u | 40001 | storm2 | gsdw2 | 41001 |
12 | 10 | p | p | s | u | 40002 | storm2 | gsdw2 | 41002 |
13 | 11 | p | p | s | u | 40003 | storm2 | gsdw2 | 41003 |
14 | 12 | p | p | s | u | 40000 | storm3 | gsdw3 | 41000 |
15 | 13 | p | p | s | u | 40001 | storm3 | gsdw3 | 41001 |
16 | 14 | p | p | s | u | 40002 | storm3 | gsdw3 | 41002 |
17 | 15 | p | p | s | u | 40003 | storm3 | gsdw3 | 41003 |
18 | 0 | m | m | s | u | 50000 | storm1 | gsdw1 | 51000 |
19 | 1 | m | m | s | u | 50001 | storm1 | gsdw1 | 51001 |
20 | 2 | m | m | s | u | 50002 | storm1 | gsdw1 | 51002 |
21 | 3 | m | m | s | u | 50003 | storm1 | gsdw1 | 51003 |
22 | 4 | m | m | s | u | 50000 | storm2 | gsdw2 | 51000 |
23 | 5 | m | m | s | u | 50001 | storm2 | gsdw2 | 51001 |
24 | 6 | m | m | s | u | 50002 | storm2 | gsdw2 | 51002 |
25 | 7 | m | m | s | u | 50003 | storm2 | gsdw2 | 51003 |
26 | 8 | m | m | s | u | 50000 | storm3 | gsdw3 | 51000 |
27 | 9 | m | m | s | u | 50001 | storm3 | gsdw3 | 51001 |
28 | 10 | m | m | s | u | 50002 | storm3 | gsdw3 | 51002 |
29 | 11 | m | m | s | u | 50003 | storm3 | gsdw3 | 51003 |
30 | 12 | m | m | s | u | 50000 | ETL | gmdw | 51000 |
31 | 13 | m | m | s | u | 50001 | ETL | gmdw | 51001 |
32 | 14 | m | m | s | u | 50002 | ETL | gmdw | 51002 |
33 | 15 | m | m | s | u | 50003 | ETL | gmdw | 51003 |
需要把ETL上的所有primary和mirror数据全部迁移到新的服务器GP-Segment之上;
2.操作步骤:
(1) 停止当前greenplum集群
gpstop -a
(2) 只启动master节点
gpstart -m
(3) 修改集群的节点信息:此处对于primary和mirror节点的修改是有一些差别的,哪下:
mirror节点的修改语句:
PGOPTIONS='-c gp_session_role=utility' psql
set allow_system_table_mods='dml';
update gp_segment_configuration set hostname='GP-Segment',address='gsdw4',status='d' where (content in(12,13,14,15) and role='m');
update gp_segment_configuration set mode='c' where (content in (12,13,14,15) and role ='p');
primary节点的修改语句:除status和mode需要修改之外,还需要把主节点的角色先切换为mirror角色,而把mirror节点的角色切换为primary节点,恢复完成后再切换回来
PGOPTIONS='-c gp_session_role=utility' psql
set allow_system_table_mods='dml';
update gp_segment_configuration set hostname='GP-Segment',address='gsdw4',status='d' where (content in(0,1,2,3) and role='p');
update gp_segment_configuration set role = CASE WHEN preferred_role='p' then 'm' ELSE 'p' END where content in(0,1,2,3);
update gp_segment_configuration set mode='c' where (content in (0,1,2,3) and role ='p');
修改完成后的节点信息如下:一共16条记录需要做出一定的修改,请注意比较
dbid | content | role | preferred_role | mode | status | port | hostname | address | replication_port | san_mounts
------+---------+------+----------------+------+--------+-------+------------+---------+------------------+------------
1 | -1 | p | p | s | u | 5432 | ETL | gmdw | |
2 | 0 | m | p | s | d | 40000 | GP-Segment | gsdw4 | 41000 |
3 | 1 | m | p | s | d | 40001 | GP-Segment | gsdw4 | 41001 |
4 | 2 | m | p | s | d | 40002 | GP-Segment | gsdw4 | 41002 |
5 | 3 | m | p | s | d | 40003 | GP-Segment | gsdw4 | 41003 |
6 | 4 | p | p | s | u | 40000 | storm1 | gsdw1 | 41000 |
7 | 5 | p | p | s | u | 40001 | storm1 | gsdw1 | 41001 |
8 | 6 | p | p | s | u | 40002 | storm1 | gsdw1 | 41002 |
9 | 7 | p | p | s | u | 40003 | storm1 | gsdw1 | 41003 |
10 | 8 | p | p | s | u | 40000 | storm2 | gsdw2 | 41000 |
11 | 9 | p | p | s | u | 40001 | storm2 | gsdw2 | 41001 |
12 | 10 | p | p | s | u | 40002 | storm2 | gsdw2 | 41002 |
13 | 11 | p | p | s | u | 40003 | storm2 | gsdw2 | 41003 |
14 | 12 | p | p | c | u | 40000 | storm3 | gsdw3 | 41000 |
15 | 13 | p | p | c | u | 40001 | storm3 | gsdw3 | 41001 |
16 | 14 | p | p | c | u | 40002 | storm3 | gsdw3 | 41002 |
17 | 15 | p | p | c | u | 40003 | storm3 | gsdw3 | 41003 |
18 | 0 | p | m | c | u | 50000 | storm1 | gsdw1 | 51000 |
19 | 1 | p | m | c | u | 50001 | storm1 | gsdw1 | 51001 |
20 | 2 | p | m | c | u | 50002 | storm1 | gsdw1 | 51002 |
21 | 3 | p | m | c | u | 50003 | storm1 | gsdw1 | 51003 |
22 | 4 | m | m | s | u | 50000 | storm2 | gsdw2 | 51000 |
23 | 5 | m | m | s | u | 50001 | storm2 | gsdw2 | 51001 |
24 | 6 | m | m | s | u | 50002 | storm2 | gsdw2 | 51002 |
25 | 7 | m | m | s | u | 50003 | storm2 | gsdw2 | 51003 |
26 | 8 | m | m | s | u | 50000 | storm3 | gsdw3 | 51000 |
27 | 9 | m | m | s | u | 50001 | storm3 | gsdw3 | 51001 |
28 | 10 | m | m | s | u | 50002 | storm3 | gsdw3 | 51002 |
29 | 11 | m | m | s | u | 50003 | storm3 | gsdw3 | 51003 |
30 | 12 | m | m | s | d | 50000 | GP-Segment | gsdw4 | 51000 |
31 | 13 | m | m | s | d | 50001 | GP-Segment | gsdw4 | 51001 |
32 | 14 | m | m | s | d | 50002 | GP-Segment | gsdw4 | 51002 |
33 | 15 | m | m | s | d | 50003 | GP-Segment | gsdw4 | 51003 |
(4) 停止master节点:
gpstop -m
(5) 启动集群:
gpstart -a
启动过程能成功,但是提示4个mirror节点切换为primary角色,4个mirror节点失败,还有4个mirror节点需要恢复
20161124:15:57:48:010890 gpstate:ETL:gpadmin-[INFO]:--------------------------------------------------------------
20161124:15:57:48:010890 gpstate:ETL:gpadmin-[WARNING]:-4 segment(s) configured as mirror(s) are acting as primaries
20161124:15:57:48:010890 gpstate:ETL:gpadmin-[WARNING]:-4 segment(s) configured as mirror(s) have failed
20161124:15:57:48:010890 gpstate:ETL:gpadmin-[WARNING]:-4 mirror segment(s) acting as primaries are in change tracking
(5) 执行完全恢复操作:
gprecoverseg -F
(6) 对集群再次进行检查,发现有4个mirror节点目前还是primary角色,也就是再迁移过程中做为primary的4个primary节点
gpstate -m
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:--------------------------------------------------------------
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- Mirror Datadir Port Status Data Status
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam1/gpseg0 50000 Acting as Primary Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam2/gpseg1 50001 Acting as Primary Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam3/gpseg2 50002 Acting as Primary Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam4/gpseg3 50003 Acting as Primary Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam1/gpseg4 50000 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam2/gpseg5 50001 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam3/gpseg6 50002 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam4/gpseg7 50003 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam1/gpseg8 50000 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam2/gpseg9 50001 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam3/gpseg10 50002 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam4/gpseg11 50003 Passive Synchronized
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam1/gpseg12 50000 Passive Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam2/gpseg13 50001 Passive Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam3/gpseg14 50002 Passive Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam4/gpseg15 50003 Passive Resynchronizing
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[INFO]:--------------------------------------------------------------
20161124:15:58:49:011176 gpstate:ETL:gpadmin-[WARNING]:-4 segment(s) configured as mirror(s) are acting as primaries
(7) 进行角色切换:
gprecoverseg -r
(8) 再次检查,最后检查时,发现所有角色已经正常归位,如下所示:
gpstate -m
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:-Obtaining Segment details from master...
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:--------------------------------------------------------------
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:--Current GPDB mirror list and status
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:--Type = Group
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:--------------------------------------------------------------
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- Mirror Datadir Port Status Data Status
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam1/gpseg0 50000 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam2/gpseg1 50001 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam3/gpseg2 50002 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw1 /export/gpdata/gpdatam4/gpseg3 50003 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam1/gpseg4 50000 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam2/gpseg5 50001 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam3/gpseg6 50002 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw2 /export/gpdata/gpdatam4/gpseg7 50003 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam1/gpseg8 50000 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam2/gpseg9 50001 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam3/gpseg10 50002 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw3 /export/gpdata/gpdatam4/gpseg11 50003 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam1/gpseg12 50000 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam2/gpseg13 50001 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam3/gpseg14 50002 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:- gsdw4 /export/gpdata/gpdatam4/gpseg15 50003 Passive Synchronized
20161124:16:17:29:012172 gpstate:ETL:gpadmin-[INFO]:--------------------------------------------------------------
注意:恢复过程,数据越大,时间越长,需要注意使用gpstate -m检查时,如果出现Resynchronizing字样,一定不能执行下一步操作,需要等状态变为Synchronized之后,才能继续下一步操作。