【GP集群部署】1master 1standy master 2segments实施过程
Greenplum集群安装文档
一、环境准备
操作系统版本
$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
Python版本:Python 2.7.5
Greenplum版本:
gpdb-6.17.5.tar.gz
下载地址: https://github.com/greenplum-db/gpdb/releases
IP地址规划
10.15.140.115 t3-gpdb09
10.15.140.117 t3-gpdb11
10.15.140.118 t3-gpdb12
10.15.140.119 t3-gpdb13
计划将10.15.140.115作为master,10.15.140.117作为standby master, 10.15.140.118、10.15.140.119作为segment instance
1)修改host文件(所有节点)
$ vi /etc/hosts
# for greenplum
10.15.140.115 t3-gpdb09
10.15.140.117 t3-gpdb11
10.15.140.118 t3-gpdb12
10.15.140.119 t3-gpdb13
2)创建用户和用户组(所有节点)
groupadd -g 1921 greenplum
useradd -g 1921 –u1921 -m -d /home/greenplum -s /bin/bash greenplum
echo greenplum | passwd greenplum --stdin
usermod -aG wheel greenplum
3)修改系统内核(所有节点)
vi /etc/sysctl.conf
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.ip_forward = 0 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 = 1025 65535 net.core.netdev_max_backlog = 10000 net.core.rmem_max = 2097152 net.core.wmem_max = 2097152 vm.overcommit_memory = 2
sysctl -p
4)修改文件打开限制(所有节点)
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 13107
5)关闭防火墙(所有节点)
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
6)关闭SELINUX(所有节点)
vi /etc/selinux/config
SELINUX=disabled
7)设置时区(所有节点)
timedatectl set-timezone Asia/Shanghai
8)创建安装文件目录(所有节点)
su - greenplum
mkdir /home/greenplum/{gphome,gpbase}
chown -R greenplum: greenplum /home/greenplum
mkdir /home/greenplum/dba 存放安装软件的目录
9)上传greenplum安装包到master节点,其他安装包所有节点都需要上传
$ cd dba
$ ls |grep tar
gpdb-6.17.5.tar.gz
pip-20.1.tar.gz
psutil-3.2.2.tar.gz
PyYAML-5.3.tar.gz
wheel-0.33.6.tar.gz
10)配置ssh免密登录(所有节点)
$ su - greenplum
$ssh-keygen -t rsa
将其他节点公钥id_rsa.pub导入到其他节点的认证文件
$cat id_rsa.pub >> authorized_keys
并修改文件权限
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
最后,进行测试
ssh t3-gpdb09 date
ssh t3-gpdb11 date
ssh t3-gpdb12 date
ssh t3-gpdb13 date
二、集群安装
1)安装依赖包及python环境
yum install -y apr-devel
yum install -y libevent-devel
yum install -y libcurl-devel.x86_64
yum install -y bzip2-devel
yum install -y gcc-c++
yum install -y bison.x86_64 bison-devel.x86_64
yum install -y openssl-devel
yum install -y flex
yum install -y python-pip
yum install -y python-devel
yum install -y gcc python27-devel libxml2 libxml2-devel libxslt libxslt-devel openssl libzstd
yum install -y python-setuptools
root执行
# cd /home/greenplum/dba/pip/
# python setup.py install
# cd /home/greenplum/dba/PyYAML/
# python setup.py install
# cd /home/greenplum/dba/wheel/
# python setup.py install
1 # pip install PyYAML-5.3.tar.gz --user 2 DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support 3 Processing ./PyYAML-5.3.tar.gz 4 Building wheels for collected packages: PyYAML 5 Building wheel for PyYAML (setup.py) ... done 6 Created wheel for PyYAML: filename=PyYAML-5.3-cp27-cp27mu-linux_x86_64.whl size=45218 sha256=2a05239a589bf9a7111e7cdf19316055cbc671e6f088d1b845c7139cb4808c06 7 Stored in directory: /root/.cache/pip/wheels/42/80/44/ca57ab804b2a71a9e5eb87c0b5ce9b6739ab765ab30bedfa3c 8 Successfully built PyYAML 9 Installing collected packages: PyYAML 10 Successfully installed PyYAML-5.3
2)初始化master数据库实例
./configure --prefix=/home/greenplum/gphome --with-pgport=1921 --disable-gpcloud --disable-orca
make
make install
3)修改用户greenplum的环境变量.bash_profile
master节点、standby master节点
#for greenplum
source /home/greenplum/gphome/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/home/greenplum/gpbase/gpmaster/gpseg-1
export PGPORT=1921
segment instance节点
#for greenplum
source /home/greenplum/gphome/greenplum_path.sh
export PGPORT=1921
4)创建配置集群hostlist文件、seg_hosts
$ su - greenplum
$ mkdir -p /home/greenplum/gphome/conf/
$ vi /home/greenplum/gphome/conf/hostlist
t3-gpdb09
t3-gpdb11
t3-gpdb12
t3-gpdb13
$ vi /home/greenplum/gphome/conf/seg_hosts
t3-gpdb12
t3-gpdb13
5)将gphome分发到每个节点
$ source /home/greenplum/gphome/greenplum_path.sh
$ gpssh-exkeys -f /home/greenplum/gphome/conf/hostlist
[STEP 1 of 5] create local ID and authorize on local host
... /home/greenplum/.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 t3-gpdb11
... send to t3-gpdb12
... send to t3-gpdb13
[STEP 4 of 5] determine common authentication file content
[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with t3-gpdb11
... finished key exchange with t3-gpdb12
... finished key exchange with t3-gpdb13
[INFO] completed successfully
$ gpssh -f /home/greenplum/gphome/conf/hostlist
=> pwd
[t3-gpdb12] /home/greenplum
[t3-gpdb09] /home/greenplum
[t3-gpdb11] /home/greenplum
[t3-gpdb13] /home/greenplum
=> tar -cf gphome.tar gphome
/home/greenplum/gphome/bin/gpscp -f /home/greenplum/gphome/conf/hostlist gp.tar =:/home/greenplum/ (复制到每台机器命令)
[OUT t3-gpdb11] Hello , Non maintenance personnel are not allowed to login !
[OUT t3-gpdb12] Hello , Non maintenance personnel are not allowed to login !
[OUT t3-gpdb13] Hello , Non maintenance personnel are not allowed to login !
创建pgbase目录
$ gpssh -f /home/greenplum/gphome/conf/hostlist
=> cd /home/greenplum
[t3-gpdb11]
[t3-gpdb12]
[t3-gpdb13]
=> mkdir pgdata
[t3-gpdb11]
[t3-gpdb12]
[t3-gpdb13]
=> cd pgdata
[t3-gpdb11]
[t3-gpdb12]
[t3-gpdb13]
=> mkdir gpmaster gpdatap1 gpdatap2 gpdatam1 gpdatam2
[t3-gpdb11]
[t3-gpdb12]
[t3-gpdb13]
=> ls
[t3-gpdb11]
gpdatam1 gpdatam2 gpdatap1 gpdatap2 gpmaster
[t3-gpdb12]
gpdatam1 gpdatam2 gpdatap1 gpdatap2 gpmaster
[t3-gpdb13]
gpdatam1 gpdatam2 gpdatap1 gpdatap2 gpmaster
=> exit
在master及standby master节点编辑gpinitsystem_config文件
vi /home/greenplum/gphome/conf/gpinitsystem_config
ARRAY_NAME="Greenplum"
SEG_PREFIX=gpseg
PORT_BASE=3300
declare -a DATA_DIRECTORY=(/home/greenplum/gpbase/gpdatap1 /home/greenplum/gpbase/gpdatap2)
MASTER_HOSTNAME=t3-gpdb09
MASTER_DIRECTORY=/home/greenplum/gpbase/gpmaster
MASTER_PORT=1921
TRUSTED_SHELL=/usr/bin/ssh
MIRROR_PORT_BASE=4300
REPLICATION_PORT_BASE=3400
MIRROR_REPLICATION_PORT_BASE=4400
declare -a MIRROR_DATA_DIRECTORY=(/home/greenplum/gpbase/gpdatam1 /home/greenplum/gpbase/gpdatam2)
MACHINE_LIST_FILE=/home/greenplum/gphome/conf/seg_hosts
6)安装GP集群数据库*******
初始化-单库
gpinitsystem -c / home /greenplum/gphome/conf/gpinitsystem_config -s gpmaster
初始化-未配置standby master(架构:1master、3segment instances)
gpinitsystem -c /home/greenplum/gphome/conf/gpinitsystem_config -h / home /greenplum/gphome/conf/hostlist
初始化-配置单库,master上面也部署data,mirror,(1master、1standby master、2segment instances)
source ~/.bash_profile
gpinitsystem -c / home /greenplum/gphome/conf/gpinitsystem_config -h / home /greenplum/gphome/conf/hostlist -s t3-gpdb11
初始化-配置单库(1master、1standby master、2segment instances),data,mirror分布在segment节点
gpinitsystem -c / home /greenplum/gphome/conf/gpinitsystem_config -h / home /greenplum/gphome/conf/seg_hosts -s t3-gpdb11
三、集群管理
gpstop -M fast
gpstart -a
内存配置:
$ gpconfig -c shared_buffers -v 4096MB -m 4096MB
$ gpconfig -c gp_vmem_protect_limit -v 30720 -m 30720
$ gpconfig -c max_connections -v 2000 -m 400
$ gpconfig --skipvalidation -c wal_send_client_timeout -v 60s -m 60s