原文链接: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)

Greenplum 添加mirror步骤的更多相关文章

  1. Deepgreen/Greenplum 删除节点步骤

    Deepgreen/Greenplum删除节点步骤 Greenplum和Deepgreen官方都没有给出删除节点的方法和建议,但实际上,我们可以对节点进行删除.由于不确定性,删除节点极有可能导致其他的 ...

  2. pytest文档38-allure.setp添加测试用例步骤

    前言 一般流程性的测试用例,写成自动化用例时,步骤较多写起来会比较长.在测试用例里面添加详细的步骤有助于更好的阅读,也方便报错后快速的定位到问题. 举个常见的测试场景用例:从登陆开始,到浏览商品添加购 ...

  3. 01 Mybatis框架添加英雄步骤

    客户端发出请求的几种方式 通过浏览器的地址栏中发出请求 通过html页面中的超链接发出请求 通过html页面中的form表单发出请求 通过前端框架发出请求 工程中使用数据库需要做的几件事: 在pom. ...

  4. oneThink后台添加插件步骤详解

    内容管理框架:oneThink 版本:V1.1.141212 (注:v1.1也有很多版本,一不小心就下到V1.1.140202 去了,还有其他版本,建议去代码托管平台下载最新版本) 我也不偷懒,把每一 ...

  5. 【转】Hadoop集群添加磁盘步骤

    转自:http://blog.csdn.net/huyuxiang999/article/details/17691405 一.实验环境 : 1.硬件:3台DELL服务器,CPU:2.27GHz*16 ...

  6. ASP.NET Core 添加区域步骤(详细)

    1 前言 早就想总结一下,但是没时间,这次有时间了,就详细的把步骤写出来. 2 步骤 2.1 添加区域 右键项目->添加->区域,如图1: 区域名称:Ceshi 添加完之后解决方案管理器会 ...

  7. linux操作系统不重启添加raid0步骤

    1.限制:本步骤仅适用于LSI芯片的raid卡,可以通过以下蓝色指令判断是否LSI芯片 [root@HKC-Lab-CDN ~]# lspci | grep -i lsi 03:00.0 RAID b ...

  8. 阿里云移动推送 ios项目添加SDK步骤

    添加阿里云Pods仓库和各产品SDK Pod依赖,配置步骤如下: 1. CocoaPods集成添加阿里云Pods仓库,Podfile添加: source 'https://github.com/ali ...

  9. 阿里云移动推送 安卓项目添加SDK步骤

    Gradle的Emas服务插件会加载您下载的 aliyun-emas-services.json 文件.请修改工程的build.gradle使用该插件.配置步骤如下: 1. 修改项目级目录下build ...

随机推荐

  1. django中的media

    我们用Django写一个网站,可能会需要将用户注册时的头像展示到页面上,当然一开始学的用户上传头像文件都是在项目目录下的,那我们在网页上获取这个头像文件是获取不到的,此时我们需要配置一下media,才 ...

  2. doDBA工具使用详解

    目录 1.简介 2.下载 3.使用帮助 4.配置 4.1.模板 4.2.启动命令 5.部署流程 5.1.下载 5.2.选定被监控主机 5.3.在被监控主机上添加Linux用户.MySQL 用户 5.4 ...

  3. vue --- axios拦截器+form格式请求体

    在vue2.x中使用CLI生成的模板有很大改变,需要自己手动在main.ts同级目录下新建interceptors.ts interceptors.ts import axios from 'axio ...

  4. JDK8-lambda表达式以及接口可以定义默认方法

    一.Lambda表达式 1.Lamdba Lambda 允许把函数作为一个方法的参数,使用Lamdba可以让开发的代码更加简洁,但是易读性差,新人不了解Lamdba表达式或者代码功底有点差,不容易读懂 ...

  5. Harbor 企业级私有仓库 Ubuntu16.04 搭建及使用

    一.Harbor简介 1.1.什么是Harbor 几个VMware中国的人搞了一个容器镜像仓库.Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器. 1.2.Harbor架 ...

  6. JDBC使用8.0驱动包连接mysql设置时区serverTimezone

    驱动包用的是新版 mysql-connector-java-8.0.16.jar新版的驱动类改成了com.mysql.cj.jdbc.Driver新版驱动连接url也有所改动I.指定时区 如果不设置时 ...

  7. CORS讲解

    跨域资源共享(CORS) 是一种机制,它使用额外的 HTTP 头来告诉浏览器  让运行在一个 origin (domain) 上的Web应用被准许访问来自不同源服务器上的指定的资源.当一个资源从与该资 ...

  8. Java Swing 资料(转载学习)

    Swing图像界面简介:https://blog.csdn.net/xietansheng/article/details/72814531 Swing实用经验总结篇:https://blog.csd ...

  9. 封装的PKPM BimView的方法

    封装的方法 var ObvApiWrapper; if (!ObvApiWrapper) { ObvApiWrapper = {}; } ObvApiWrapper = function(build, ...

  10. 进入恢复模式(Recovery HD)

    进入恢复模式(Recovery HD) 1,选中要启动的虚拟机,随后点击VM菜单的启动按钮后面向下箭头,随后点击菜单项”打开电源时进入固件“. 2,在虚拟机里面,用上下键移动到”Enter setup ...