Greenplum扩容-纵向扩容 – 记忆角落

Greenplum扩容-纵向扩容

/ 0评 / 0

Greenplum扩容-纵向扩容

扩容前准备

首先看看现有的集群的状态:gpstate

现在的状态是有3台主机,一个是master节点,还有两个segment的机器,每个segment的机器上都有一个primary和mirror的segment.

现在计划在现有的集群上进行segment的扩容,在每台机器上的segment的数量翻倍.
现在segment的目录为:

/data/data1/gp/mirror
/data/data1/gp/primary

现在需要在两个segment的主机上创建新的目录如下:

/data/data2/gp/mirror
/data/data2/gp/primary

上面的目录的所属组和用户均为gpadmin:gpamdin,这里创建目录可以使用gpssh创建也可以一个一个的创建

mkdir -p /data/data2/gp/primary
mkdir -p /data/data2/gp/mirror

mkdir -p /data/data2/gp/primary/space_fastdisk
mkdir -p /data/data2/gp/mirror/space_fastdisk

chown -R gpadmin:gpadmin /data/data2

创建初始化文件

查看目前segment的主机:

[gpadmin@hljydwxywgzt4-7 ~]$ cat seg_host 
hljydwxywgzt-8 
hljydwxywgzt2-4

执行:gpexpand -f seg_hostsor gpexpand -f seg_hosts -D your_db_name

如果报错这个错:[ERROR]:-gpexpand failed: Invalid database 'template1' specified. Cannot use a template database. 就有两种解决办法:

1.指定您的数据库:gpexpand -f seg_hosts -D lte_mr

2.在.bash_profile 新增:export PGDATABASE=lte_mr 指向数据库

[gpadmin@hljydwxywgzt4-7 ~]$ gpexpand -f seg_host 
20220121:15:27:33:197129 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.29.3 build commit:dcbb78a61cebd6eb8d196cb73d2eb76836bd59c7'
20220121:15:27:33:197129 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.3.23 (Greenplum Database 5.29.3 build commit:dcbb78a61cebd6eb8d196cb73d2eb76836bd59c7) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 6.2.0, 64-bit compiled on Jan  4 2022 04:24:09'
20220121:15:27:33:197129 gpexpand:hljydwxywgzt4-7: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

You must now specify a mirroring strategy for the new hosts.  Spread mirroring places
a given hosts mirrored segments each on a separate host.  You must be 
adding more hosts than the number of segments per host to use this. 
Grouped mirroring places all of a given hosts segments on a single 
mirrored host.  You must be adding at least 2 hosts in order to use this.



What type of mirroring strategy would you like?
 spread|grouped (default=grouped):#默认的mirror方式
> 

** No hostnames were given that do not already exist in the **
** array. Additional segments will be added existing hosts. **

    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):
> 1
Enter new primary data directory 1:
> /data/data2/gp/primary
Enter new mirror data directory 1:
> /data/data2/gp/mirror

Generating configuration file...

20220121:15:28:41:197129 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-Generating input file...

Input configuration files were written to 'gpexpand_inputfile_20220121_152841' and 'None'.
Please review the file and make sure that it is correct then re-run
with: gpexpand -i gpexpand_inputfile_20220121_152841 -D lte_mr #生成的初始化文件

20220121:15:28:41:197129 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-Exiting...

查看初始化文件:

[gpadmin@hljydwxywgzt4-7 ~]$ cat gpexpand_inputfile_20220121_152841
hljydwxywgzt-8:hljydwxywgzt-8:40001:/data/data2/gp/primary/gpseg2:7:2:p:41001
hljydwxywgzt2-4:hljydwxywgzt2-4:50001:/data/data2/gp/mirror/gpseg2:10:2:m:51001
hljydwxywgzt2-4:hljydwxywgzt2-4:40001:/data/data2/gp/primary/gpseg3:8:3:p:41001
hljydwxywgzt-8:hljydwxywgzt-8:50001:/data/data2/gp/mirror/gpseg3:9:3:m:51001

初始化Segment并且创建扩容schema

执行命令: gpexpand -i gpexpand_inputfile_20220121_152841 orgpexpand -i gpexpand_inputfile_20220121_152841 -D your_db_name

使用gpstate验证下节点是否添加成功!

重分布数据

执行命令:gpexpand -d 1:00:00

移除扩容schema

执行命令:gpexpand -c

[gpadmin@hljydwxywgzt4-7 ~]$ gpexpand -c
20220121:15:41:33:202342 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.29.3 build commit:dcbb78a61cebd6eb8d196cb73d2eb76836bd59c7'
20220121:15:41:33:202342 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.3.23 (Greenplum Database 5.29.3 build commit:dcbb78a61cebd6eb8d196cb73d2eb76836bd59c7) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 6.2.0, 64-bit compiled on Jan  4 2022 04:24:09'
20220121:15:41:33:202342 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-Querying gpexpand schema for current expansion state


Do you want to dump the gpexpand.status_detail table to file? Yy|Nn (default=Y):
> y
20220121:15:41:37:202342 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-Dumping gpexpand.status_detail to /data/master/gpseg-1/gpexpand.status_detail
20220121:15:41:37:202342 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-Removing gpexpand schema
20220121:15:41:38:202342 gpexpand:hljydwxywgzt4-7:gpadmin-[INFO]:-Cleanup Finished.  exiting...

这里为止纵向扩容就完成了,不出错都是傻瓜式的操作,出错多看日志,也不难。

注意:如果在扩容的时候失败或者出错了,记得回滚:gpexpand -r ,还有就是扩容成功,数据重分布成功后记得使用analyze或者analyzedb进行分析

发表评论

您的电子邮箱地址不会被公开。