CentOS安装Greenplum教程-由单机master到集群
LiuSw Lv6

CentOS安装Greenplum教程-由单机master到集群

Greenplum的数据库是一个大规模并行处理(MPP)数据库服务器架构,该架构是专为管理大规模的数据仓库和商业智能设计的。Greenplum数据存储和处理大数据量,是通过跨多个服务器和主机分配数据和负载。Greenplum数据库是基于PostgreSQL8.2单个数据库的阵列,这些数据库像单个数据库一样共同工作。master主机是Greenplum数据库系统的入口点,它是客户端连接并提交SQL语句的接口数据库实例。Master协调系统中其他数据库实例(称为Segment)的工作负载,处理数据和存储。分段通过互连,Greenplum数据库的网络层互相通信和主控

greenplum组件

Greenplum数据库系统的主要组件以及与每个组件关联的硬件注意事项和概念:Greenplum Master,Segments和Interconnect。此外,系统可能具有用于数据加载的可选ETL主机和用于监视查询工作负载和性能的Greenplum性能监视器。

1、基于postgresql

greenplum的数据库基于postgresql的开源技术,它本质上是几个postgresql数据库实例一起协作当做一个有凝聚力数据库管理系统(dbms)使用。postgresql的内部一杯修改和补充,以支持Greenplum数据库的并行架构。例如,该系统目录,优化器,查询执行器,和事务管理器组件以被修改和改进,以支持能够在所有并行的postgresql数据库实例同事执行查询。

2、Interconnnect

Greenplum Interconnect可使不同的Postgresql实例之间进行通信,并且是系统表现为一个逻辑数据库

3、greenplum master

3.1. master功能作用

  • master是greenplu数据库系统的入口,数据库服务器进程接收客户端连接并处理系统用户发出的sql命令。
  • master维护系统目录(一组包含有关greenplum数据库系统本身的元数据的系统表,但是master不包含任何用户数据。数据只保存在segment主机上。
  • master验证客户端连接,处理传入的sql命令,在每个segment主机之间分配工作负载,协调每个segment返回的结果。并将结果返回客户端。

3.2. standby

  • standby通过事务日志复制进程保持最新状态,该进程在standby上运行,并同步master和standby主机之间的数据。如果master主机失败,日志复制关闭;当standby处于活动状态时,日志复制重建上次成功提交事务时的master的状态。
  • 由于Master不包含任何用户数据,因此只需要在Master和Standby之间同步系统目录表。当这些表被更新时,更改会自动复制到Standby,以便始终与主站同步

4、greenplum segment

4.1、segment主要作用

  • segment主要是存储数据及数据查询处理。
  • 用户自定义的表(非系统表,master存储系统表)及索引分布在可用的segment;每个segment包含数据的不同。用户不能直接与grenplum数据系统的segment交互,而是通过master进行交互。
  • 在参考Greenplum数据库硬件配置中,每个segment主机的segment实例数由有效的CPU或CPU内核的数量决定。 例如,如果你的segment主机有两个双核处理器,则每个主机可能有两个或四个主要segment。 如果你的segment主机有三个四核处理器,则每个主机可能有三个,六个或十二个segment。性能测试将有助于确定所选硬件平台的最佳segment。

4.2、segment冗余 (mirror)镜像

  • 配置mirror,当你的primary segment不可用时则mirror segment允许数据查询故障切换到镜像segment。
  • mirror segment必须始终位于与primary 不同的主机上

4.3、性能

  • Segment主机执行大部分数据库处理,因此配置好Segment主机服务器,以便从你的Greenplum数据库系统获得最佳性能。Greenplum数据库的性能将与数组中最慢的Segment服务器一样快,也就是性能以最慢的Segment为准

4.4、网络

  • 网络互连是greenplum 数据系统的网络层,当用户连接到数据库并发查询时,会在每个segment上创建进程处理该查询的工作。网络互连是指的segment 之间的进程通信所依赖的网络基础设施。
    默认情况下,greenplum数据库互连具有流量控制的UDP(用户数据报协议)协议发送消息。greenplum做了附加分组和检查不由UDP协议执行,性能和可扩展行超过TCP。

5、 ETL主机加载数据

  • greenplum支持使用其外部表功能可以快速并行的数据加载。通过使用外部表与greenplum数据库的并行文件服务器(gpfdist)结合使用,管理员可以从其greenplum数据库系统实现最大的并行度和负载带宽。
  • 使用gpfdist文件服务器程序的一个优点是,它可以确保在从外部表数据文件读取时,您的Greenplum数据库系统中的所有Segment都被充分利用。

6、Greenplum性能监视器

  • Greenplum还提供可选的监控和管理工具,管理员可以安装并启用Greenplum数据库。 要使用Greenplum性能监视器,您的Greenplum数据库阵列中的每个主机都必须安装并启用数据收集代理。 当你开始Greenplum性能监视器,代理开始收集关于查询和系统利用率的数据,代理定期将数据发送到Greenplum Master(通常每15秒)。用户可以查询Greenplum Performance Monitor数据库,查看有效查询和历史查询和系统性能数据。 Greenplum Performance Monitor还具有图形化的基于Web的用户界面,用于查看这些性能指标并以其他方式管理其Greenplum

7、postgresql 体系结构

postgresql数据库主要五大部分组成:连接管理系统(系统控制器)、编译执行系统、存储管理系统、事务系统、系统表。
以下模块功能介绍:

  • 1、 连接管理系统:机构外部操作对系统的请求,对操作请求进行预处理和分发,具有系统逻辑控制作用。
  • 2、编译执行系统:由查询编译器、查询执行器、DDL编译器组成,完成操作请求在数据库中的分析处理和转化工作,最终实现屋里存储介质数据的操作;
  • 3、存储管理系统:由索引管理器、内存管理器、外存管理器组成,负责存储和管理物理数据,提供对编译查询系统的支持;
  • 4、事务系统:包含 事务管理器、日志管理器、并发控制、锁管理器组成,日志管理器和事务管理器完成对操作请求处理的事务一致性支持,锁管理器和并发控制提供对并发访问数据的一致性支持;
  • 5、系统表:是postgresql数据库的元信息管理中心,包括数据库对象信息和数据库管理控制信息。系统表管理元数据信息,将postgresql数据库的各个模块有机的连接在一起,形成一个高效的数据管理系统。

安装单机master

环境:

  • Greenplum6
  • Centos7
ip地址 hostname 角色
192.168.137.31 master master
192.168.137.32 segment1 segment
192.168.137.33 segment2 segment

一.Greenplum 6.4 下载

Greenplum下载地址

二.安装单机master环境准备

2.1 关闭防火墙

1
2
systemctl stop firewalld
systemctl disable firewalld

2.2 关闭SELINUX

1
2
3
4
5
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# 或者
vi /etc/selinux/config
SELINUX=disabled

2.3 改机器名

1
2
hostnamectl set-hostname 主机名
hostnamectl set-hostname master

2.4 更改hosts文件

1
2
3
cat >> /etc/hosts << EOF
192.168.137.31 master master
EOF

2.5创建gpaadmin用户和用户组

1
2
3
4
groupadd -g 3030 gpadmin
useradd -u 3030 gpadmin -g gpadmin -d /home/gpadmin
# 更改gpadmin密码
echo "gpadmin" | passwd --stdin gpadmin

2.6配置内核参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cat >> /etc/sysctl.conf << EOF
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 250 512000 100 2048
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.arp_filter = 1
net.ipv4.ip_local_port_range = 10000 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2
EOF
1
2
# 使配置生效
sysctl -p

2.7 更改/etc/security/limits.conf

1
2
3
4
5
6
cat >>/etc/security/limits.conf << EOF
*soft nofile 65536
*hard nofile 65536
*soft nproc 131072
*hard nproc 131072
EOF

2.8 CentOS7需要加入服务logind

1
2
echo "RemoveIPC=no" >> /etc/systemd/logind.conf
service systemd-logind restart

2.9 设置network

1
2
3
4
vi /etc/sysconfig/network
# 添加:
networking=yes
hostname=master # 不区分大小写

2.10 重启服务器reboot

1
reboot

三.安装GreenPlum

安装方式:

  • rpm包 - 本次用rpm安装
  • zip压缩包
  • bin二进制包

3.1 gp6安装包上传到服务器并安装

1
2
# 上传到master服务器上,并安装rpm包
yum -y install greenplum-db-6.1.0-rhel6-x86_64.rpm
1
2
3
#默认安装到/usr/local下,授权给gpadmin
chown -R gpadmin /usr/local/greenplum*
chgrp -R gpadmin /usr/local/greenplum*
1
2
# 加载greenplum环境
source /usr/local/greenplum-db/greenplum_path.sh

3.2创建instance需要的目录

1
2
3
4
5
6
7
# 创建目录
mkdir -p /data/gpdata
mkdir -p /data/gpdata/master
mkdir -p /data/gpdata/gp1
mkdir -p /data/gpdata/gp2
mkdir -p /data/gpdata/gp3
mkdir -p /data/gpdata/gp4
1
2
3
4
# 修改目录属主
chown -R gpadmin:gpadmin /data/gpdata
chown -R gpadmin:gpadmin /data/gpdata/master
chown -R gpadmin:gpadmin /data/gpdata/gp*

3.3切换用户gpadmin

1
2
3
# 切换到gpadmin
su - gpadmin
cd

3.4 /home/gpadmin/.bash_profile文件添加以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
cat >> /home/gpadmin/.bash_profile << EOF
# 确认安装路径是否相同,脚本是否同名
source /usr/local/greenplum-db/greenplum_path.sh

export MASTER_DATA_DIRECTORY=/data/gpdata/master/gpseg-1

export PGPORT=2345

export PGUSER=gpadmin

export PGDATABASE=gpdb
EOF

3.5 /home/gpadmin/.bashrc文件添加同3.4的内容

1
2
3
4
5
6
7
8
9
10
11
12
cat >> /home/gpadmin/.bashrc << EOF
# 确认安装路径是否相同,脚本是否同名
source /usr/local/greenplum-db/greenplum_path.sh

export MASTER_DATA_DIRECTORY=/data/gpdata/master/gpseg-1

export PGPORT=2345

export PGUSER=gpadmin

export PGDATABASE=gpdb
EOF

3.6设置子节点的host

1
2
3
# 添加一行master(单机版只有一个host)
vi all_hosts_file
master

3.7 权限互通

1
2
# 免密登录
gpssh-exkeys -f all_hosts_file

3.8 编辑gp初始化文件

1
2
3
4
5
6
7
8
9
vi initgp_config
# 写入:
SEG_PREFIX=gpseg
PORT_BASE=33000
declare -a DATA_DIRECTORY=(/data/gpdata/gp1 /data/gpdata/gp2 /data/gpdata/gp3 /data/gpdata/gp4)
MASTER_HOSTNAME=master
MASTER_PORT=2345
MASTER_DIRECTORY=/data/gpdata/master
DATABASE_NAME=gpdb

3.9设置节点服务器

1
2
3
vi seg_hosts_file
# 写入:本例单机,只有master这一台
master

四.初始化GreenPlum

4.1 初始化命令

1
gpinitsystem -c initgp_config -h seg_hosts_file

服务器初始化没有设置分配swap空间,会初始化失败,分配好swap空间即可

五.连接GP

5.1psql登录修改密码

1
2
3
4
5
su - gpadmin
psql -p 2345
# 修改数据库密码
alter role gpadmin with password 'gpadmin';
退出: \q

5.2远程连接配置

1
2
3
4
5
6
vi /data/gpdata/master/gpseg-1/postgresql.conf
# 修改:
#listen_addresses = '*',去#注释
vi /data/gpdata/master/gpseg-1/pg_hba.conf
# 添加:
host all gpadmin 0.0.0.0/0 md5

5.3重新加载配置文件

1
gpstop -u

5.4 其他启停命令

1
2
3
4
gpstart #正常启动
gpstop #正常关闭
gpstop -M fast #快速关闭
gpstop –r #重启

安装master后添加segment节点

一.更改segment系统配置

1.1更改机器名为segment1

1
hostnamectl set-hostname segment1

1.2修改/etc/hosts文件

1
2
3
vi /etc/hosts
# 新增
192.168.137.32 segment1 segment1
1
2
# 从master复制到segment
scp /etc/hosts segment1:/etc

1.3关闭selinux及防火墙

参考前文

1
2
# selinux文件可用scp命令由master复制到segment节点
scp /etc/selinux/config segment1:/etc/selinux

1.4修改/etc/sysconfig/network文件(进入每台segment中修改)

1
2
3
4
vi /etc/sysconfig/network
# Created by anaconda
networking=yes
hostname=segment1 # 主机名

1.5复制master的/etc/sysctl.conf文件到segment

1
2
scp /etc/sysctl.conf segment1:/etc/
sysctl -p # segment 执行

1.6修改/etc/security/limits.d/20-nproc.conf文件并复制到segment

1
2
3
4
5
6
7
8
vi /etc/security/limits.d/20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

* soft nproc 4096
root soft nproc unlimited

1
2
# 复制到segment
scp /etc/security/limits.d/20-nproc.conf segment1:/etc/security/limits.d/

1.7复制/etc/security/limits.conf到segment节点

1
scp /etc/security/limits.conf  segment1:/etc/security/

1.8创建gpadmin组及用户

1
2
3
4
groupadd -g 3030 gpadmin
useradd -u 3030 gpadmin -g gpadmin -d /home/gpadmin
# 更改gpadmin密码
echo "gpadmin" | passwd --stdin gpadmin

1.9配置扩展segment节点需要的文件

1
2
3
4
5
6
# 修改master主机gpadmin目录下的all_hosts_file,将所有节点的主机名都加进去
vi /home/gpadmin/all_hosts_file
master
segment1
segment2
...
1
2
3
4
5
# 修改master主机gpadmin目录下的seg_hosts_file,将segment节点的主机名加进去
vi /home/gpadmin/seg_hosts_file
segment1
segment2
...
1
2
3
4
5
# 新增hosts_expand文件,此次增加的segment
# 将当前需要新增的节点主机名加入(如此次需要加入segment1,就将segment1写入)
vi /home/gpadmin/hosts_expand
segment1
...

1.10 创建需要的目录

1
2
3
4
5
6
7
# 创建目录
mkdir -p /data/gpdata
mkdir -p /data/gpdata/master
mkdir -p /data/gpdata/gp1
mkdir -p /data/gpdata/gp2
mkdir -p /data/gpdata/gp3
mkdir -p /data/gpdata/gp4
1
2
3
4
# 修改目录属主
chown -R gpadmin:gpadmin /data/gpdata
chown -R gpadmin:gpadmin /data/gpdata/master
chown -R gpadmin:gpadmin /data/gpdata/gp*

二.配置SSH免密登录

2.1master主机生成密钥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 注意执行用户为gpadmin
ssh-keygen -t rsa
# 一直回车
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:8Z+R0Truk1NIVC4Tl6w5VTgP2WrjhM3ZtmYu2Ykn8v8 root@master
The key's randomart image is:
+---[RSA 2048]----+
| .oo*.|
| .=O .|
| . .+BoB |
| o **O +|
| S ..=* o.|
| o.+o+ |
| +oB .|
| o+= = |
| ++=.E|
+----[SHA256]-----+

id_rsa为私钥,id_rsa.pub为公钥

2.2将公钥复制到segment的 ~/.ssh/authorized_keys文件(.ssh目录及authorized_keys可能要提前创建)

1
2
# 注意执行用户为gpadmin
scp ~/.ssh/id_rsa.pub segment1:~/.ssh/authorized_keys

2.3设置目录权限

1
2
3
4
5
# gpadmin用户的.ssh目录的权限必须是700(非常重要)
chmod 700 .ssh

# gpadmin用户的.ssh/authorized_keys文件权限必须是600
chmod 600 .ssh/authorized_keys

2.4测试节点之间是否连通

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
gpssh-exkeys -f all_hosts_file

[gpadmin@master ~]$ gpssh-exkeys -f all_hosts_file
[STEP 1 of 5] create local ID and authorize on local host
... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped

[STEP 2 of 5] keyscan all hosts and update known_hosts file

[STEP 3 of 5] retrieving credentials from remote hosts
... send to segment1

[STEP 4 of 5] determine common authentication file content

[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with segment1

[INFO] completed successfully

# 最后出现completed successfully即证明节点之间已连通

三.在segment安装GreenPlum

3.1在segment安装GreenPlum的rpm包

1
2
3
4
# 上传到所有segment服务器上,并安装rpm包
yum -y install greenplum-db-6.1.0-rhel6-x86_64.rpm
# 或者用rpm命令安装
rpm -ivh greenplum-db-6.1.0-rhel6-x86_64.rpm
1
2
# 切换gpadmin用户,将segment节点/usr/local的读权限给到gpadmin,否则会报错
chown -R gpadmin:gpadmin /usr/local/greenplum-db*

四.环境配置

4.1复制/home/gpadmin/.bash_profile到segment

1
2
3
scp /home/gpadmin/.bash_profile segment1:/home/gpadmin/
scp /home/gpadmin/.bash_profile segment2:/home/gpadmin/
...

4.2使环境变量生效

1
2
su - gpadmin
source .bash_profile

4.3复制/home/gpadmin/.bashrc到segment

1
2
3
scp /home/gpadmin/.bashrc segment1:/home/gpadmin/
scp /home/gpadmin/.bashrc segment2:/home/gpadmin/
...

五.使用gpexpand函数增加segment节点

5.1gpexpand -f hosts_expand

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
[gpadmin@master ~]$ gpexpand -f hosts_expand

20210514:23:06:59:044510 gpexpand:master:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c'
20210514:23:06:59:044510 gpexpand:master:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Apr 21 2021 19:24:38'
20210514:23:06:59:044510 gpexpand:master:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state

System Expansion is used to add segments to an existing GPDB array.
gpexpand did not detect a System Expansion that is in progress.

Before initiating a System Expansion, you need to provision and burn-in
the new hardware. Please be sure to run gpcheckperf to make sure the
new hardware is working properly.

Please refer to the Admin Guide for more information.

Would you like to initiate a new System Expansion Yy|Nn (default=N):
> y
20210514:23:07:00:044510 gpexpand:master:gpadmin-[ERROR]:-gpexpand failed: Hosts file hosts_gpexpand not found

Exiting...
20210514:23:07:00:044510 gpexpand:master:gpadmin-[INFO]:-Shutting down gpexpand...
[gpadmin@master ~]$ gpexpand -f hosts_expand
20210514:23:07:10:044551 gpexpand:master:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c'
20210514:23:07:10:044551 gpexpand:master:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Apr 21 2021 19:24:38'
20210514:23:07:10:044551 gpexpand:master:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state

System Expansion is used to add segments to an existing GPDB array.
gpexpand did not detect a System Expansion that is in progress.

Before initiating a System Expansion, you need to provision and burn-in
the new hardware. Please be sure to run gpcheckperf to make sure the
new hardware is working properly.

Please refer to the Admin Guide for more information.

Would you like to initiate a new System Expansion Yy|Nn (default=N):
> y

By default, new hosts are configured with the same number of primary
segments as existing hosts. Optionally, you can increase the number
of segments per host.

For example, if existing hosts have two primary segments, entering a value
of 2 will initialize two additional segments on existing hosts, and four
segments on new hosts. In addition, mirror segments will be added for
these new primary segments if mirroring is enabled.


How many new primary segments per host do you want to add? (default=0):
> 4
Enter new primary data directory 1:
> /data/gpdata/gp1
Enter new primary data directory 2:
> /data/gpdata/gp2
Enter new primary data directory 3:
> /data/gpdata/gp3
Enter new primary data directory 4:
> /data/gpdata/gp4

Generating configuration file...

20210514:23:08:27:044551 gpexpand:master:gpadmin-[INFO]:-Generating input file...

Input configuration file was written to 'gpexpand_inputfile_20210514_230827'.

Please review the file and make sure that it is correct then re-run
with: gpexpand -i gpexpand_inputfile_20210514_230827

20210514:23:08:27:044551 gpexpand:master:gpadmin-[INFO]:-Exiting...

成功会显示已生成gpexpand_inoutfile开头的文件

5.2修改gpexpand_inputfile_20xxx(每个节点保留4行)

1
2
3
4
5
6
7
8
9
10
11
12
13
segment1|segment1|33000|/data/gpdata/gp1/gpseg4|6|4|p
segment1|segment1|33001|/data/gpdata/gp2/gpseg5|7|5|p
segment1|segment1|33002|/data/gpdata/gp3/gpseg6|8|6|p
segment1|segment1|33003|/data/gpdata/gp4/gpseg7|9|7|p
# 当前只增加一个节点,所以只保留前面4行
master|master|33004|/data/gpdata/gp1/gpseg8|10|8|p
master|master|33005|/data/gpdata/gp2/gpseg9|11|9|p
master|master|33006|/data/gpdata/gp3/gpseg10|12|10|p
master|master|33007|/data/gpdata/gp4/gpseg11|13|11|p
segment1|segment1|33004|/data/gpdata/gp1/gpseg12|14|12|p
segment1|segment1|33005|/data/gpdata/gp2/gpseg13|15|13|p
segment1|segment1|33006|/data/gpdata/gp3/gpseg14|16|14|p
segment1|segment1|33007|/data/gpdata/gp4/gpseg15|17|15|p

剩下的都可删掉,否则gpexpand -i 命令会失败,报错

5.3gpexpand -i 脚本文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[gpadmin@master ~]$ gpexpand -i gpexpand_inputfile_20210514_230827
20210514:23:11:57:044991 gpexpand:master:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c'
20210514:23:11:57:044991 gpexpand:master:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Apr 21 2021 19:24:38'
20210514:23:11:57:044991 gpexpand:master:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state
20210514:23:11:58:044991 gpexpand:master:gpadmin-[INFO]:-Heap checksum setting consistent across cluster
20210514:23:11:58:044991 gpexpand:master:gpadmin-[INFO]:-Syncing Greenplum Database extensions

...

20210514:23:12:02:044991 gpexpand:master:gpadmin-[INFO]:-{'segment1': '/data/gpdata/gp1/gpseg4:33000:true:false:6:4::-1:,/data/gpdata/gp2/gpseg5:33001:true:false:7:5::-1:,/data/gpdata/gp3/gpseg6:33002:true:false:8:6::-1:,/data/gpdata/gp4/gpseg7:33003:true:false:9:7::-1:'}
20210514:23:12:19:044991 gpexpand:master:gpadmin-[INFO]:-Cleaning up temporary template files
20210514:23:12:19:044991 gpexpand:master:gpadmin-[INFO]:-Cleaning up databases in new segments.
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Unlocking catalog
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Unlocked catalog
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Creating expansion schema
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database template1
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database postgres
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Populating gpexpand.status_detail with data from database gpdb
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-************************************************
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Initialization of the system expansion complete.
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-To begin table expansion onto the new segments
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-rerun gpexpand
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-************************************************
20210514:23:12:21:044991 gpexpand:master:gpadmin-[INFO]:-Exiting...

(出现Initialization of the system expansion complete即增加节点成功)

5.4删除增加节点生成的schema

(不删除以后则无法增加节点)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[gpadmin@master ~]$ gpexpand -c
20210515:00:49:17:051000 gpexpand:master:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c'
20210515:00:49:17:051000 gpexpand:master:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.16.0 build commit:5650be2b79197fed564dca8d734d10f2a76b876c) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Apr 21 2021 19:24:38'
20210515:00:49:17:051000 gpexpand:master:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state
20210515:00:49:18:051000 gpexpand:master:gpadmin-[WARNING]:-Expansion has not yet completed. Removing the expansion
20210515:00:49:18:051000 gpexpand:master:gpadmin-[WARNING]:-schema now will leave the following tables unexpanded:
20210515:00:49:18:051000 gpexpand:master:gpadmin-[WARNING]:-
20210515:00:49:18:051000 gpexpand:master:gpadmin-[WARNING]:-These tables will have to be expanded manually by setting
20210515:00:49:18:051000 gpexpand:master:gpadmin-[WARNING]:-the distribution policy using the ALTER TABLE command.


Are you sure you want to drop the expansion schema? Yy|Nn (default=N):
> y


Do you want to dump the gpexpand.status_detail table to file? Yy|Nn (default=Y):
> y
20210515:00:49:22:051000 gpexpand:master:gpadmin-[INFO]:-Dumping gpexpand.status_detail to /home/gpdata/master/gpseg-1/gpexpand.status_detail
20210515:00:49:22:051000 gpexpand:master:gpadmin-[INFO]:-Removing gpexpand schema
20210515:00:49:22:051000 gpexpand:master:gpadmin-[INFO]:-Cleanup Finished. exiting...

5.5重分布表

1
gpexpand -d 60:00:00

(出现completed successfully即重分布成功)

5.6失败回滚

1
gpexpand -r

5.7进入GP查询节点信息

1
2
3
4
5
su - gpadmin
# 登录greenplum,注意端口(前面的初始化配置文件设置的)
psql -p 2345
# 执行sql查询集群状态
select * from gp_segment_configuration;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
gpdb=# select * from gp_segment_configuration;
dbid | content | role | preferred_role | mode | status | port | hostname | address | datadir
------+---------+------+----------------+------+--------+-------+----------+----------+-----------------------------
1 | -1 | p | p | n | u | 2345 | master | master | /data/gpdata/master/gpseg-1
2 | 0 | p | p | n | u | 33000 | master | master | /data/gpdata/gp1/gpseg0
3 | 1 | p | p | n | u | 33001 | master | master | /data/gpdata/gp2/gpseg1
4 | 2 | p | p | n | u | 33002 | master | master | /data/gpdata/gp3/gpseg2
5 | 3 | p | p | n | u | 33003 | master | master | /data/gpdata/gp4/gpseg3
6 | 4 | p | p | n | u | 33000 | segment1 | segment1 | /data/gpdata/gp1/gpseg4
7 | 5 | p | p | n | u | 33001 | segment1 | segment1 | /data/gpdata/gp2/gpseg5
8 | 6 | p | p | n | u | 33002 | segment1 | segment1 | /data/gpdata/gp3/gpseg6
9 | 7 | p | p | n | u | 33003 | segment1 | segment1 | /data/gpdata/gp4/gpseg7
(9 rows)

原文链接

 评论