Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2875973
  • 博文数量: 200
  • 博客积分: 2413
  • 博客等级: 大尉
  • 技术积分: 3067
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-01 22:07
文章分类

全部博文(200)

文章存档

2018年(2)

2017年(8)

2016年(35)

2015年(14)

2014年(20)

2013年(24)

2012年(53)

2011年(44)

分类: Mysql/postgreSQL

2015-12-02 16:44:44


###############################
##gpmovemirrors :移动mirror ###
###############################

mirrors是Greenplum中segment的primary节点的镜像节点,一旦primary节点出现问题,mirror将接替primary的位置继续提供服务。

场景:
由于添加mirror时,配置文件mirror列表顺序错误,造成Primary和mirror在一台服务器上;
为了纠正错误,采用gpmovemirrors命令将mirrors移到其他服务器上,实现交叉镜像。

修正前:
20151202:01:58:18:002818 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------
20151202:01:58:18:002818 gpstate:gp-m:gpadmin-[INFO]:-   Status                             Data State     Primary   Datadir                        Port    Mirror   Datadir                Port
20151202:01:58:18:002818 gpstate:gp-m:gpadmin-[INFO]:-   Primary Active, Mirror Available   Synchronized   gp-s1     /home/gpadmin/primary/gpseg0   40000   gp-s1    /home/gpadmin/mirror   52001
20151202:01:58:18:002818 gpstate:gp-m:gpadmin-[INFO]:-   Primary Active, Mirror Available   Synchronized   gp-s2     /home/gpadmin/primary/gpseg1   40000   gp-s2    /home/gpadmin/mirror   52002
20151202:01:58:18:002818 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------


修正:
1、修正mirror1
$ cat remove_mirror_config_file
filespaceOrder=
gp-s1:52001:/home/gpadmin/mirror gp-s2:52001:53001:/home/gpadmin/mirror2

格式:
filespaceOrder=[filespace1_fsname[:filespace2_fsname:...]
old_address:port:fselocation \ 
[new_address:port:replication_port:fselocation[:fselocation:...]]

filespaceOrder=
老主机名:port:路径 新主机名:port:replication_port:路径

$ gpmovemirrors -i remove_mirror_config_file 
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-Checking if MASTER_DATA_DIRECTORY env variable is set.
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-Invocation of gpmovemirrors mirrors
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-Option values for this invocation of gpmovemirrors are:
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --input                 = remove_mirror_config_file
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --master-data-directory = /home/gpadmin/master/gpseg-1
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --batch-size            = 16
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --verbose               = False
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-Connecting to dbname=testDB
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-remove_mirror_config_file:1
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-remove_mirror_config_file:2
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=oldAddress                     delimiter=':' value=gp-s1
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=oldPort                        delimiter=':' value=52001
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=oldDataDirectory               delimiter=' ' value=/home/gpadmin/mirror
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newAddress                     delimiter=':' value=gp-s2
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newPort                        delimiter=':' value=52001
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newReplicationPort             delimiter=':' value=53001
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newDataDirectory               delimiter=':' value=/home/gpadmin/mirror2
20151202:02:42:05:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-About to run gprecoverseg with options: -i remove_mirror_config_file -v -a -d /home/gpadmin/master/gpseg-1
20151202:02:43:02:003755 gpmovemirrors:gp-m:gpadmin-[INFO]:-About to remove old mirror segment directory: /home/gpadmin/mirror
20151202:02:43:02:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-Adding cmd to work_queue: /bin/rm -rf /home/gpadmin/mirror
20151202:02:43:02:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-[worker0] got cmd: /bin/rm -rf /home/gpadmin/mirror
20151202:02:43:02:003755 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-[worker0] finished cmd: remove old mirror segment directories cmdStr='ssh -o 'StrictHostKeyChecking no' gp-s1 ". /opt/greenplum/greenplum-db/./greenplum_path.sh; /bin/rm -rf /home/gpadmin/mirror"'  had result: cmd had rc=0 completed=True halted=False
 
mirror1已经跑到了segment2的Primary服务器上 
$ gpstate -c
20151202:02:45:47:004450 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------
20151202:02:45:47:004450 gpstate:gp-m:gpadmin-[INFO]:-   Status                             Data State     Primary   Datadir                        Port    Mirror   Datadir                 Port
20151202:02:45:47:004450 gpstate:gp-m:gpadmin-[INFO]:-   Primary Active, Mirror Available   Synchronized   gp-s1     /home/gpadmin/primary/gpseg0   40000   gp-s2    /home/gpadmin/mirror2   52001
20151202:02:45:47:004450 gpstate:gp-m:gpadmin-[INFO]:-   Primary Active, Mirror Available   Synchronized   gp-s2     /home/gpadmin/primary/gpseg1   40000   gp-s2    /home/gpadmin/mirror    52002
20151202:02:45:47:004450 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------
 
2、修正mirror2
$ cat remove_mirror_config_file
filespaceOrder=
gp-s2:52002:/home/gpadmin/mirror gp-s1:52002:53002:/home/gpadmin/mirror2

$ gpmovemirrors -i remove_mirror_config_file
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-Checking if MASTER_DATA_DIRECTORY env variable is set.
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-Invocation of gpmovemirrors mirrors
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-Option values for this invocation of gpmovemirrors are:
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --input                 = remove_mirror_config_file
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --master-data-directory = /home/gpadmin/master/gpseg-1
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --batch-size            = 16
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-  --verbose               = False
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-Connecting to dbname=testDB
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-remove_mirror_config_file:1
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-remove_mirror_config_file:2
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=oldAddress                     delimiter=':' value=gp-s2
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=oldPort                        delimiter=':' value=52002
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=oldDataDirectory               delimiter=' ' value=/home/gpadmin/mirror
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newAddress                     delimiter=':' value=gp-s1
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newPort                        delimiter=':' value=52002
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newReplicationPort             delimiter=':' value=53002
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-  name=newDataDirectory               delimiter=':' value=/home/gpadmin/mirror2
20151202:03:23:36:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-About to run gprecoverseg with options: -i remove_mirror_config_file -v -a -d /home/gpadmin/master/gpseg-1
20151202:03:24:04:005593 gpmovemirrors:gp-m:gpadmin-[INFO]:-About to remove old mirror segment directory: /home/gpadmin/mirror
20151202:03:24:04:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-Adding cmd to work_queue: /bin/rm -rf /home/gpadmin/mirror
20151202:03:24:04:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-[worker0] got cmd: /bin/rm -rf /home/gpadmin/mirror
20151202:03:24:06:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-[worker0] finished cmd: remove old mirror segment directories cmdStr='ssh -o 'StrictHostKeyChecking no' gp-s2 ". /opt/greenplum/greenplum-db/./greenplum_path.sh; /bin/rm -rf /home/gpadmin/mirror"'  had result: cmd had rc=0 completed=True halted=False
  stdout=''
  stderr=''
20151202:03:24:06:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-WorkerPool haltWork()
20151202:03:24:06:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-[worker0] haltWork
20151202:03:24:11:005593 gpmovemirrors:gp-m:gpadmin-[DEBUG]:-[worker0] stopping

[gpadmin@gp-m ~]$ gpstate -c                   
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-Starting gpstate with args: -c
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.6.2 build 1'
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.6.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Nov 12 2015 23:50:28'
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-Obtaining Segment details from master...
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:--Current GPDB mirror list and status
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:--Type = Spread
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-   Status                             Data State        Primary   Datadir                        Port    Mirror   Datadir                 Port
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-   Primary Active, Mirror Available   Synchronized      gp-s1     /home/gpadmin/primary/gpseg0   40000   gp-s2    /home/gpadmin/mirror2   52001
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:-   Primary Active, Mirror Available   Resynchronizing   gp-s2     /home/gpadmin/primary/gpseg1   40000   gp-s1    /home/gpadmin/mirror2   52002
20151202:03:24:17:005777 gpstate:gp-m:gpadmin-[INFO]:--------------------------------------------------------------

postgres=# select * from gp_segment_configuration;
 dbid | content | role | preferred_role | mode | status | port  | hostname | address | replication_port | san_mounts 
------+---------+------+----------------+------+--------+-------+----------+---------+------------------+------------
    1 |      -1 | p    | p              | s    | u      |  5432 | gp-m     | gp-m    |                  | 
    2 |       0 | p    | p              | s    | u      | 40000 | gp-s1    | gp-s1   |            54001 | 
    4 |       0 | m    | m              | s    | u      | 52001 | gp-s2    | gp-s2   |            53001 | 
    3 |       1 | p    | p              | s    | u      | 40000 | gp-s2    | gp-s2   |            54002 | 
    5 |       1 | m    | m              | s    | u      | 52002 | gp-s1    | gp-s1   |            53002 | 
(5 rows)

到这里,已经把mirror1和2都移到了正确的位置。
 
转载请注明:
十字螺丝钉
http://blog.chinaunix.net/uid/23284114.html

QQ:463725310
E-MAIL:houora#gmail.com(#请自行替换为@)

阅读(3439) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~