Greenplum添加mirror步骤

简介: 为只有primary的greenplum添加mirror节点

[TOC]

概述

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

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

添加前情况

初始化的时候只有primary

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

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

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 | gw_mdw1  | gw_mdw1 |                  | 
    2 |       0 | p    | p              | s    | u      | 40000 | gw_sdw1  | gw_sdw1 |                  | 
    6 |       4 | p    | p              | s    | u      | 40000 | gw_sdw2  | gw_sdw2 |                  | 
    3 |       1 | p    | p              | s    | u      | 40001 | gw_sdw1  | gw_sdw1 |                  | 
    7 |       5 | p    | p              | s    | u      | 40001 | gw_sdw2  | gw_sdw2 |                  | 
    4 |       2 | p    | p              | s    | u      | 40002 | gw_sdw1  | gw_sdw1 |                  | 
    8 |       6 | p    | p              | s    | u      | 40002 | gw_sdw2  | gw_sdw2 |                  | 
    5 |       3 | p    | p              | s    | u      | 40003 | gw_sdw1  | gw_sdw1 |                  | 
    9 |       7 | p    | p              | s    | u      | 40003 | gw_sdw2  | gw_sdw2 |                  | 
(9 rows)

添加步骤

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

可以使用gpssh命令

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

生成addmirror文件

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

[gpadmin@gw_mdw1 ~]$ gpaddmirrors -o ./addmirror
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Starting gpaddmirrors with args: -o ./addmirror
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.1.0 build 6'
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'
20190326:00:56:21:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Obtaining Segment details from master...
Enter mirror segment data directory location 1 of 4 >
/data/mirror
Enter mirror segment data directory location 2 of 4 >
/data/mirror
Enter mirror segment data directory location 3 of 4 >
/data/mirror
Enter mirror segment data directory location 4 of 4 >
/data/mirror
20190326:00:57:15:030831 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Configuration file output to ./addmirror successfully.

查看文件内容如下

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

执行添加命令

[gpadmin@gw_mdw1 ~]$ gpaddmirrors -i addmirror 
20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-Starting gpaddmirrors with args: -i addmirror
20190326:01:08:45:031106 gpaddmirrors:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.1.0 build 6'
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(已同步的)

[gpadmin@gw_mdw1 ~]$ gpstate -m
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-Starting gpstate with args: -m
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.3.1.0 build 6'
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'
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-Obtaining Segment details from master...
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--------------------------------------------------------------
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--Current GPDB mirror list and status
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--Type = Group
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--------------------------------------------------------------
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   Mirror    Datadir               Port    Status    Data Status       
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw2   /data/mirror/gpseg0   41000   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw2   /data/mirror/gpseg1   41001   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw2   /data/mirror/gpseg2   41002   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw2   /data/mirror/gpseg3   41003   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw1   /data/mirror/gpseg4   41000   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw1   /data/mirror/gpseg5   41001   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw1   /data/mirror/gpseg6   41002   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:-   gw_sdw1   /data/mirror/gpseg7   41003   Passive   Resynchronizing
20190326:01:09:51:031359 gpstate:gw_mdw1:gpadmin-[INFO]:--------------------------------------------------------------

查看节点状态

发现所有的mirror已经启动

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 | gw_mdw1  | gw_mdw1 |                  | 
    2 |       0 | p    | p              | s    | u      | 40000 | gw_sdw1  | gw_sdw1 |            43000 | 
   10 |       0 | m    | m              | s    | u      | 41000 | gw_sdw2  | gw_sdw2 |            42000 | 
    3 |       1 | p    | p              | s    | u      | 40001 | gw_sdw1  | gw_sdw1 |            43001 | 
   11 |       1 | m    | m              | s    | u      | 41001 | gw_sdw2  | gw_sdw2 |            42001 | 
    4 |       2 | p    | p              | s    | u      | 40002 | gw_sdw1  | gw_sdw1 |            43002 | 
   12 |       2 | m    | m              | s    | u      | 41002 | gw_sdw2  | gw_sdw2 |            42002 | 
    5 |       3 | p    | p              | s    | u      | 40003 | gw_sdw1  | gw_sdw1 |            43003 | 
   13 |       3 | m    | m              | s    | u      | 41003 | gw_sdw2  | gw_sdw2 |            42003 | 
    6 |       4 | p    | p              | s    | u      | 40000 | gw_sdw2  | gw_sdw2 |            43000 | 
   14 |       4 | m    | m              | s    | u      | 41000 | gw_sdw1  | gw_sdw1 |            42000 | 
    7 |       5 | p    | p              | s    | u      | 40001 | gw_sdw2  | gw_sdw2 |            43001 | 
   15 |       5 | m    | m              | s    | u      | 41001 | gw_sdw1  | gw_sdw1 |            42001 | 
    8 |       6 | p    | p              | s    | u      | 40002 | gw_sdw2  | gw_sdw2 |            43002 | 
   16 |       6 | m    | m              | s    | u      | 41002 | gw_sdw1  | gw_sdw1 |            42002 | 
    9 |       7 | p    | p              | s    | u      | 40003 | gw_sdw2  | gw_sdw2 |            43003 | 
   17 |       7 | m    | m              | s    | u      | 41003 | gw_sdw1  | gw_sdw1 |            42003 | 
(17 rows)
相关文章
|
4月前
|
SQL 关系型数据库 Linux
搭建 PostgreSQL 流复制主从指南(适用于 CentOS 7.x)
搭建 PostgreSQL 流复制主从指南(适用于 CentOS 7.x)
132 7
|
5月前
|
关系型数据库 分布式数据库 PolarDB
PolarDB产品使用问题之在安装GMS时遇到Docker,该如何解决
PolarDB产品使用合集涵盖了从创建与管理、数据管理、性能优化与诊断、安全与合规到生态与集成、运维与支持等全方位的功能和服务,旨在帮助企业轻松构建高可用、高性能且易于管理的数据库环境,满足不同业务场景的需求。用户可以通过阿里云控制台、API、SDK等方式便捷地使用这些功能,实现数据库的高效运维与持续优化。
|
6月前
|
监控 关系型数据库 数据库
PostgreSQL和greenplum的copy命令如何使用?
【6月更文挑战第5天】PostgreSQL和greenplum的copy命令如何使用?
174 2
|
7月前
|
关系型数据库 分布式数据库 PolarDB
PolarDB常见问题之安装gms时出现docker如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
7月前
|
存储 Kubernetes 分布式数据库
利用Helm在K8S上部署 PolarDB-X 集群(详细步骤--亲测!!!)
利用Helm在K8S上部署 PolarDB-X 集群(详细步骤--亲测!!!)
281 0
|
7月前
|
关系型数据库 分布式数据库 PolarDB
PolarDB for PostgreSQL下载问题之客户端 X-Paxos下载失败如何解决
PolarDB for PostgreSQL是基于PostgreSQL开发的一款云原生关系型数据库服务,它提供了高性能、高可用性和弹性扩展的特性;本合集将围绕PolarDB(pg)的部署、管理和优化提供指导,以及常见问题的排查和解决办法。
|
7月前
|
关系型数据库 MySQL 数据库
MySQL【部署 03】8.0.25离线部署(下载+安装+配置)Failed dependencies 问题处理及8.0配置参数说明
MySQL【部署 03】8.0.25离线部署(下载+安装+配置)Failed dependencies 问题处理及8.0配置参数说明
922 0
|
canal 监控 关系型数据库
Elastic实战:通过logstash-input-jdbc实现mysql8.0全量/增量同步至ES7.x
上一期我们讲解了如何通过canal实现增量/全量同步但因为canal本身基于binlog。所以在binlog开启之前的历史数据是不会同步的。 因此要实现真正的全量同步,还需要针对binlog开启之前的历史数据进行全量同步。
1023 2
Elastic实战:通过logstash-input-jdbc实现mysql8.0全量/增量同步至ES7.x
|
存储 关系型数据库 Linux
PolarDB-CEPH 部署 最新版 | 学习笔记
快速学习 PolarDB-CEPH 部署 最新版,介绍了 PolarDB-CEPH 部署 最新版系统机制, 以及在实际应用过程中如何使用。
PolarDB-CEPH 部署 最新版 | 学习笔记
|
存储 关系型数据库 Linux
在Centos7环境下进行搭建postgresql-xl集群环境
在Centos7环境下进行搭建postgresql-xl集群环境
149 0
在Centos7环境下进行搭建postgresql-xl集群环境