• Greenplum 添加mirror步骤


    原文链接:https://yq.aliyun.com/articles/695864

    [TOC]

    概述

    新安装的greenplum集群只有primary节点,没有mirror。高可用性没得到保证。所以就需要为集群添加mirror节点

    注意:数据量过大时添加mirror,会有较大的磁盘压力,因为后台会一直同步数据,这一点线上系统需要注意

    添加前情况

    初始化的时候只有primary 

            gpstate -b

    1.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-Greenplum Primary Segment Configuration
    2.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:----------------------------------------
    3.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg0 40000 2 0
    4.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg1 40001 3 1
    5.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg2 40002 4 2
    6.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw1 /data/primary/gpseg3 40003 5 3
    7.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg4 40000 6 4
    8.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg5 40001 7 5
    9.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg6 40002 8 6
    10.  
      20190326:00:48:33:005423 gpinitsystem:gw_mdw1:gpadmin-[INFO]:-gw_sdw2 /data/primary/gpseg7 40003 9 7
    11.  
      Continue with Greenplum creation Yy/Nn>

    查看系统配置表,发现只有primary节点

    1.  
      postgres=# SELECT * from gp_segment_configuration ;
    2.  
      dbid | content | role | preferred_role | mode | status | port | hostname | address | replication_port | san_mounts
    3.  
      ------+---------+------+----------------+------+--------+-------+----------+---------+------------------+------------
    4.  
      1 | -1 | p | p | s | u | 5432 | gw_mdw1 | gw_mdw1 | |
    5.  
      2 | 0 | p | p | s | u | 40000 | gw_sdw1 | gw_sdw1 | |
    6.  
      6 | 4 | p | p | s | u | 40000 | gw_sdw2 | gw_sdw2 | |
    7.  
      3 | 1 | p | p | s | u | 40001 | gw_sdw1 | gw_sdw1 | |
    8.  
      7 | 5 | p | p | s | u | 40001 | gw_sdw2 | gw_sdw2 | |
    9.  
      4 | 2 | p | p | s | u | 40002 | gw_sdw1 | gw_sdw1 | |
    10.  
      8 | 6 | p | p | s | u | 40002 | gw_sdw2 | gw_sdw2 | |
    11.  
      5 | 3 | p | p | s | u | 40003 | gw_sdw1 | gw_sdw1 | |
    12.  
      9 | 7 | p | p | s | u | 40003 | gw_sdw2 | gw_sdw2 | |
    13.  
      (9 rows)

    添加步骤

    在所有需要添加mirror的主机,创建存放mirror的数据目录

    可以使用gpssh命令

    gpssh -f seg_hosts -e 'mkdir -p /data/mirror'
     

    生成addmirror文件

    执行gpaddmirrors 命令,键入存放mirror节点的日志,生成配置文件

    1.  
      [gpadmin@gw_mdw1 ~]$ gpaddmirrors -o ./addmirror
    2.  
      20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Starting gpaddmirrors with args: -o ./addmirror
    3.  
      20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.1.0 build 6'
    4.  
      20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.1.0 build 6) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jun 11 2014 17:23:40'
    5.  
      20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Obtaining Segment details from master...
    6.  
      Enter mirror segment data directory location 1 of 4 >
    7.  
      /data/mirror
    8.  
      Enter mirror segment data directory location 2 of 4 >
    9.  
      /data/mirror
    10.  
      Enter mirror segment data directory location 3 of 4 >
    11.  
      /data/mirror
    12.  
      Enter mirror segment data directory location 4 of 4 >
    13.  
      /data/mirror
    14.  
      20190326:00:57:15:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Configuration file output to ./addmirror successfully.

    查看文件内容如下

    1.  
      [gpadmin@gw_mdw1 ~]$ cat addmirror
    2.  
      filespaceOrder=
    3.  
      mirror0=0:gw_sdw2:41000:42000:43000:/data/mirror/gpseg0
    4.  
      mirror1=1:gw_sdw2:41001:42001:43001:/data/mirror/gpseg1
    5.  
      mirror2=2:gw_sdw2:41002:42002:43002:/data/mirror/gpseg2
    6.  
      mirror3=3:gw_sdw2:41003:42003:43003:/data/mirror/gpseg3
    7.  
      mirror4=4:gw_sdw1:41000:42000:43000:/data/mirror/gpseg4
    8.  
      mirror5=5:gw_sdw1:41001:42001:43001:/data/mirror/gpseg5
    9.  
      mirror6=6:gw_sdw1:41002:42002:43002:/data/mirror/gpseg6
    10.  
      mirror7=7:gw_sdw1:41003:42003:43003:/data/mirror/gpseg7

    执行添加命令

    1.  
      [gpadmin@gw_mdw1 ~]$ gpaddmirrors -i addmirror
    2.  
      20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Starting gpaddmirrors with args: -i addmirror
    3.  
      20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.1.0 build 6'
    4.  
      20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.1.0 build 6) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jun 11 2014 17:23:40'

    命令没有报错,查看mirror节点的情况

    使用gpstate -m查看,发现所有的mirror正在同步数据,因为我的集群新建,很快就同步完成了,此时再执行gpstate -m就可以看到Data Status的状态是Synchronized(已同步的)

    1.  
      [gpadmin@gw_mdw1 ~]$ gpstate -m
    2.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-Starting gpstate with args: -m
    3.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.1.0 build 6'
    4.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.2.15 (Greenplum Database 4.3.1.0 build 6) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jun 11 2014 17:23:40'
    5.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-Obtaining Segment details from master...
    6.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--------------------------------------------------------------
    7.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--Current GPDB mirror list and status
    8.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--Type = Group
    9.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--------------------------------------------------------------
    10.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- Mirror Datadir Port Status Data Status
    11.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg0 41000 Passive Resynchronizing
    12.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg1 41001 Passive Resynchronizing
    13.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg2 41002 Passive Resynchronizing
    14.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw2 /data/mirror/gpseg3 41003 Passive Resynchronizing
    15.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg4 41000 Passive Resynchronizing
    16.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg5 41001 Passive Resynchronizing
    17.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg6 41002 Passive Resynchronizing
    18.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:- gw_sdw1 /data/mirror/gpseg7 41003 Passive Resynchronizing
    19.  
      20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--------------------------------------------------------------

    查看节点状态

    发现所有的mirror已经启动

    1.  
      postgres=# SELECT * from gp_segment_configuration ;
    2.  
      dbid | content | role | preferred_role | mode | status | port | hostname | address | replication_port | san_mounts
    3.  
      ------+---------+------+----------------+------+--------+-------+----------+---------+------------------+------------
    4.  
      1 | -1 | p | p | s | u | 5432 | gw_mdw1 | gw_mdw1 | |
    5.  
      2 | 0 | p | p | s | u | 40000 | gw_sdw1 | gw_sdw1 | 43000 |
    6.  
      10 | 0 | m | m | s | u | 41000 | gw_sdw2 | gw_sdw2 | 42000 |
    7.  
      3 | 1 | p | p | s | u | 40001 | gw_sdw1 | gw_sdw1 | 43001 |
    8.  
      11 | 1 | m | m | s | u | 41001 | gw_sdw2 | gw_sdw2 | 42001 |
    9.  
      4 | 2 | p | p | s | u | 40002 | gw_sdw1 | gw_sdw1 | 43002 |
    10.  
      12 | 2 | m | m | s | u | 41002 | gw_sdw2 | gw_sdw2 | 42002 |
    11.  
      5 | 3 | p | p | s | u | 40003 | gw_sdw1 | gw_sdw1 | 43003 |
    12.  
      13 | 3 | m | m | s | u | 41003 | gw_sdw2 | gw_sdw2 | 42003 |
    13.  
      6 | 4 | p | p | s | u | 40000 | gw_sdw2 | gw_sdw2 | 43000 |
    14.  
      14 | 4 | m | m | s | u | 41000 | gw_sdw1 | gw_sdw1 | 42000 |
    15.  
      7 | 5 | p | p | s | u | 40001 | gw_sdw2 | gw_sdw2 | 43001 |
    16.  
      15 | 5 | m | m | s | u | 41001 | gw_sdw1 | gw_sdw1 | 42001 |
    17.  
      8 | 6 | p | p | s | u | 40002 | gw_sdw2 | gw_sdw2 | 43002 |
    18.  
      16 | 6 | m | m | s | u | 41002 | gw_sdw1 | gw_sdw1 | 42002 |
    19.  
      9 | 7 | p | p | s | u | 40003 | gw_sdw2 | gw_sdw2 | 43003 |
    20.  
      17 | 7 | m | m | s | u | 41003 | gw_sdw1 | gw_sdw1 | 42003 |
    21.  
      (17 rows)
  • 相关阅读:
    从1到n整数中1出现的次数
    从上往下打印二叉树
    二叉搜索树的后序遍历序列
    顺时针打印矩阵
    平衡二叉树
    反转链表
    链表中倒数第k个节点
    深入研究 Java Synchronize 和 Lock 的区别与用法
    旋转数组的最小数字
    互联网接入支付功能测试
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/11327217.html
Copyright © 2020-2023  润新知