MPP架构之Greenplum的安装配置高级版(企业配置)

0    77    2

Tags:

👉 本文共约5452个字,系统预计阅读时间或需21分钟。

简介

硬件要求:https://docs.vmware.com/en/VMware-Tanzu-Greenplum/6/greenplum-database/GUID-install_guide-platform-requirements-overview.html

操作系统要求

Greenplum Database 6 runs on the following operating system platforms:

  • Red Hat Enterprise Linux 64-bit 8.7 or later (As of Greenplum Database version 6.20. See the following Note)
  • Red Hat Enterprise Linux 64-bit 7.x (See the following Note.)
  • Red Hat Enterprise Linux 64-bit 6.x
  • CentOS 64-bit 7.x
  • CentOS 64-bit 6.x
  • Ubuntu 18.04 LTS
  • Oracle Linux 64-bit 7, using the Red Hat Compatible Kernel (RHCK)

特别注意:

1、华为的openEuler 22.03 LTS是不支持GP6的(麦老师已花时间测试)

软件下载

可以从以下2个地方下载:

1、从 Greenplum 的 GitHub 页面(https://github.com/greenplum-db/gpdb/releases)下载RPM

2、需要注册并登录到 Pivotal 公司官网(https://network.pivotal.io/products/vmware-tanzu-greenplum)进行下载

安装包大约66MB,如下:

环境申请

本文以1个master+1个standby master,4个segment的集群示例,OS均为CentOS 7.6.1810,采用docker初始化环境。

每个segment主机上有4个Primary Segment Instance 和 4个Mirror Segment Instance共8个实例。

所以,该集群共有16个Primary实例和16个Mirror实例,再加1个master实例和1个standby master实例共34个数据库实例。

master对外服务的端口号为5432,其它segment的端口号为primary从6000-6003,对应的mirror为7000-7003

MPP架构之Greenplum的安装配置高级版(企业配置)

MPP架构之Greenplum的安装配置高级版(企业配置)

IP主机名内存CPU硬盘操作系统数据目录端口备注
172.72.6.50mdw64G32200GCentOS 7.6/opt/greenplum/data/master5432,28080Master host
172.72.6.51smdw64G32200GCentOS 7.6/opt/greenplum/data/master5432,28080Standby host
172.72.6.52sdw164G324TCentOS 7.6/opt/greenplum/data/primary
/opt/greenplum/data/mirror
主:6000-6003
镜像:7000-7003
segment host1,配置4个主实例+4个镜像实例
172.72.6.53sdw264G324TCentOS 7.6/opt/greenplum/data/primary
/opt/greenplum/data/mirror
主:6000-6003
镜像:7000-7003
segment host2,配置4个主实例+4个镜像实例
172.72.6.54sdw364G324TCentOS 7.6/opt/greenplum/data/primary
/opt/greenplum/data/mirror
主:6000-6003
镜像:7000-7003
segment host3,配置4个主实例+4个镜像实例
172.72.6.55sdw464G324TCentOS 7.6/opt/greenplum/data/primary
/opt/greenplum/data/mirror
主:6000-6003
镜像:7000-7003
segment host4,配置4个主实例+4个镜像实例
172.72.6.59VIP,在mdw和smdw上进行漂移

docker环境:

修改主机名

修改内核参数

若是docker环境,则以下配置需要在宿主机运行。

修改/etc/hosts文件

在Greenplum中,习惯将Master机器叫做mdw,将Segment机器叫做sdw。dw的含义为Data Warehouse。

mdw和sdw只是一个主机的别名,不影响程序去查找IP。

docker环境每次重启容器都会重置/etc/hosts文件的内容,但是这不会影响GreenPlum的正常运行。

也可以在创建容器的时候添加参数"--add-host='mdw:172.72.6.50'"来规避这个问题。

创建用户和集群配置文件(所有节点)

所有节点创建gpadmin用户:

所有节点创建一个all_hosts文件,包含所有节点主机名:

所有节点创建一个 seg_hosts文件 ,包含所有的Segment Host的主机名:

配置互信

只在master节点(172.72.6.50)操作

1、为了后续的维护方便,建议root和gpadmin用户都做互信的配置。

2、必须给600权限,否则会报错“.Bad owner or permissions on /home/gpadmin/.ssh/config”

安装GP软件(所有节点)

在所有节点以root用户操作:

默认的安装路径是/usr/local,修改该路径gpadmin操作权限:

创建目录,用作集群数据的存储目录:

配置环境变量

数据库初始化(重要)

该步为最核心最重要的命令过程!!!

Greenplum 配置文件模板都在/usr/local/greenplum-db/docs/cli_help/gpconfigs目录下,其中gpinitsystem_config是初始化 Greenplum 的模板。

在master节点操作:

在master节点操作:创建一个初始化副本 initgp_config,根据前面的架构规划配置,修改参数:

在master节点操作:执行初始化命令:

1、选项“-e”指定superuser用户的密码,默认密码为gparray

2、选项“-s” 指定standby host主机名,-P 指定standby host端口,-S 指定standby host数据文件路径,注意要多一层

3、-m指定最大连接数,默认250

4、-b指定shared_buffers,默认128000kB

5、初始化数据库时根据脚本的提示操作即可,如果配置有问题,gpinitsystem 命令就不能运行成功,错误日志存储在 /home/gpadmin/gpAdminLogs 中,需要认真查看日志报错信息,修改正确后再重新安装。

若初始化失败,需要删除/opt/greenplum/data下的数据资源目录重新初始化。

初始化过程:

看到“Greenplum Database instance successfully created”说明创建成功。

若创建失败,则可以使用如下命令检查错误:

GP验证

若初始化成功,则GP自动启动,可以看到master节点上的5432已经在listen了,psql进入数据库,开始greenplum之旅。

其它命令

删除集群数据库

若要删除集群数据库,则可以使用如下命令

若报错不能删除,则可以使用手动删除方法:

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

请参考:https://www.xmmup.com/greenplumshujukuchushihuaminglinggpinitsystemheshanchushujukuminglinggpdeletesystem.html#gpdeletesystem

添加和删除standby master库

命令gpstate -f可以查看standby master库的详情。

添加:

删除:

注意:master和standby master可以在同一台主机上,请注意端口号和data目录不能一样。

参考:https://www.xmmup.com/zaigreenplumshujukuzhongqiyongmasterhesegmentjingxiangmirrors.html#shi_li2

max_connections和shared_buffers参数

max_connections: 最大连接数,Segment建议设置成Master的3-10倍。增加此参数时,还必须增加max_prepared_transactions

远程访问

1、本地登陆修改密码

2、修改pg_hba.conf

3、远程登录