GreenPlum安装指南
针对Centos7平台
[gpadmin@aivmp-bigdata0001 ~]$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
机器
- 外网地址
121.36.194.125 aivmp-bigdata0001
124.70.139.178 aivmp-bigdata0002
124.70.192.187 aivmp-bigdata0003
121.36.245.248 ecs-application0002
root/Allcam@2021
- 内网地址
192.168.0.244 aivmp-bigdata0001
192.168.0.81 aivmp-bigdata0002
192.168.0.128 aivmp-bigdata0003
192.168.0.150 ecs-application0002
禁用SELinux和防火墙软件
对于运行RHEL或CentOS的所有Greenplum数据库主机系统,必须禁用SELinux。跟着这些步骤:
-
以root用户身份检查SELinux的状态:
[gpadmin@aivmp-bigdata0001 ~]# sestatus SELinux status: disabled
-
如果未禁用SELinux,请通过编辑
/etc/selinux/config
文件。以root身份更改文件如下:SELINUX=disabled
-
如果系统上安装了系统安全服务守护程序(SSSD),请编辑SSSD配置文件并设置
selinux_provider
的参数 .以防止即使禁用SELinux也可能发生与SELinux相关的SSH身份验证拒绝。以root用户身份,编辑/etc/sssd/sssd.conf
并添加以下参数:selinux_provider=none
-
重新引导系统以应用所做的任何更改,并验证
SELinux
已禁用。
您还应该禁用防火墙软件,请按照以下步骤禁用 iptables
-
对于具有防火墙,检查状态防火墙。使用命令:
[gpadmin@aivmp-bigdata0001 ~]$ systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
-
如有必要,以root用户身份执行这些命令以禁用防火墙:
systemctl stop firewalld.service systemctl disable firewalld.service
配置Hosts
# cat >> /etc/hosts <<EOF
192.168.0.244 aivmp-bigdata0001
192.168.0.81 aivmp-bigdata0002
192.168.0.128 aivmp-bigdata0003
192.168.0.150 ecs-application0002
EOF
ping 192.168.0.244
ping 192.168.0.81
ping 192.168.0.128
ping 192.168.0.150
修改内核文件参数
vi /etc/sysctl.conf
cat >> /etc/sysctl.conf << EOF
#xialonglong
kernel.shmall = 4097404
kernel.shmmax = 16782966784
kernel.shmmni = 4096
vm.overcommit_memory = 2
vm.overcommit_ratio = 95
net.ipv4.ip_local_port_range = 10000 65535
kernel.sem = 500 2048000 200 4096
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.ip_local_reserved_ports=65330
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.arp_filter = 1
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.min_free_kbytes = 983377
vm.swappiness = 10
vm.zone_reclaim_mode = 0
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
vm.dirty_background_ratio = 3
vm.dirty_ratio = 10
EOF
echo 1024 > /proc/sys/net/core/somaxconn
echo "4096 65536 16777216"> /proc/sys/net/ipv4/tcp_wmem
echo 360000 > /proc/sys/net/ipv4/tcp_max_tw_buckets
修改系统连接数
vi /etc/security/limits.conf
# cat > /etc/security/limits.conf<< EOF
* soft nofile 524288
* hard nofile 524288
* soft nproc 131072
* hard nproc 131072
EOF
cat > /etc/security/limits.conf<< EOF
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
EOF
cat /etc/security/limits.conf
ulimit -u
sysctl -p
ulimit -n
//设置read-ahead
/sbin/blockdev --setra 16384 /dev/vdb1
/sbin/blockdev --setra 16384 /dev/vda1
//设置IO调度策略
[gpadmin@aivmp-bigdata0001 ~]$ cat /sys/block/vda/queue/scheduler
[mq-deadline] kyber none
#grubby --update-kernel=ALL --args="elevator=deadline"
//禁用Transparent Huge Page(THP)
#grubby --update-kernel=ALL --args="transparent_hugepage=never"
//设置RemoveIPC
[gpadmin@aivmp-bigdata0001 ~]$ cat /etc/systemd/logind.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
RemoveIPC=no
#UserTasksMax=
//增加ssh最大连接数
/etc/ssh/sshd_config
# cat >> /etc/ssh/sshd_config<< EOF
MaxStartups 200
MaxSessions 200
EOF
# service sshd restart
同步集群时间
yum install ntp ntpdate -y
sudo ntpdate cn.pool.ntp.org && hwclock --systohc
创建Greenplum管理用户
-
创建 gpadmin组和用户。
groupadd gpadmin useradd gpadmin -r -m -g gpadmin passwd gpadmin 新密码:<gpadmin> 重新输入新密码:<gpadmin>
-
切换到 gpadmin用户并对 gpadmin 用户为该服务器生成SSH密钥。
$ su gpadmin $ ssh-keygen -t rsa $ ssh-copy-id aivmp-bigdata0001 $ ssh-copy-id aivmp-bigdata0002 $ ssh-copy-id aivmp-bigdata0003 $ ssh-copy-id ecs-application0002
-
(可选)对 gpadmin 用户授予sudo权限。
# visudo ..... root ALL=(ALL) ALL gpadmin ALL=(ALL) ALL .....
-
添加 gpadmin 用户到此分组。
usermod -aG wheel gpadmin
安装数据库到每台机器
- 下载安装
wget https://github.com/greenplum-db/gpdb/releases/download/6.14.1/open-source-greenplum-db-6.14.1-rhel7-x86_64.rpm && yum install open-source-greenplum-db-6.14.1-rhel7-x86_64.rpm -y
- 授予权限给gpadmin用户
sudo chown -R gpadmin:gpadmin /usr/local/greenplum*
sudo chgrp -R gpadmin /usr/local/greenplum*
- 添加环境变量为gpadmin
$ cat > /home/gpadmin/.bashrc<< EOF
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=test
export LD_PRELOAD=/lib64/libz.so.1 ps
export GPHOME=/usr/local/greenplum-db
EOF
cat >> /home/gpadmin/.bashrc<< EOF
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=test
export LD_PRELOAD=/lib64/libz.so.1 ps
export GPHOME=/usr/local/greenplum-db
EOF
cat ~/.bashrc
master机器
- 创建文件allhost
$ cat > /usr/local/greenplum-db/allhost<< EOF
aivmp-bigdata0001
aivmp-bigdata0002
aivmp-bigdata0003
ecs-application0002
EOF
- 创建文件seghost
$ cat > /usr/local/greenplum-db/seghost<< EOF
aivmp-bigdata0001
aivmp-bigdata0002
aivmp-bigdata0003
EOF
cat > /usr/local/greenplum-db/seghost<< EOF
aivmp-bigdata0002
aivmp-bigdata0003
EOF
cat > /usr/local/greenplum-db/seghost<< EOF
node203
node204
EOF
cat > /usr/local/greenplum-db/seghost<< EOF
cdh-upgrade-1
cdh-upgrade-3
EOF
cat > /usr/local/greenplum-db/seghost<< EOF
cdh-upgrade-3
EOF
- 创建文件夹
# mkdir -p /data/master
# chown -R gpadmin:gpadmin /data/master
- 创建
gpinitsystem_config
文件
注意:
declare -a DATA_DIRECTORY
和declare -a MIRROR_DATA_DIRECTORY
必须是成对出现得。里面几个文件夹,就代表一个segment机器上面启动了几个实例。一般推荐每台机器上启动2~4个实例,最大化cpu利用。
cat > /home/gpadmin/gpinitsystem_config<< EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=6000
declare -a DATA_DIRECTORY=(/home/gpadmin/data/primary /home/gpadmin/data/primary)
MASTER_HOSTNAME=ecs-application0002
MASTER_DIRECTORY=/home/gpadmin/data/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=7000
declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/data/mirror /home/gpadmin/data/mirror)
DATABASE_NAME=test
MACHINE_LIST_FILE=/usr/local/greenplum-db/seghost
EOF
cat > /home/gpadmin/gpinitsystem_config<< EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=6000
declare -a DATA_DIRECTORY=(/home/gpadmin/data/primary /home/gpadmin/data/primary /home/gpadmin/data/primary)
MASTER_HOSTNAME=ecs-application0002
MASTER_DIRECTORY=/home/gpadmin/data/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=7000
declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/data/mirror /home/gpadmin/data/mirror /home/gpadmin/data/mirror)
DATABASE_NAME=test
MACHINE_LIST_FILE=/usr/local/greenplum-db/seghost
EOF
cat > /home/gpadmin/gpinitsystem_config<< EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=6000
declare -a DATA_DIRECTORY=(/data/primary /data/primary)
MASTER_HOSTNAME=ecs-application0002
MASTER_DIRECTORY=/data/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=7000
declare -a MIRROR_DATA_DIRECTORY=(/data/mirror /data/mirror)
DATABASE_NAME=test
MACHINE_LIST_FILE=/usr/local/greenplum-db/seghost
EOF
cat > /home/gpadmin/gpinitsystem_config<< EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=8000
declare -a DATA_DIRECTORY=(/data/primary /data/primary)
MASTER_HOSTNAME=node201
MASTER_DIRECTORY=/data/master
MASTER_PORT=15432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=9000
declare -a MIRROR_DATA_DIRECTORY=(/data/mirror /data/mirror)
DATABASE_NAME=test
MACHINE_LIST_FILE=/usr/local/greenplum-db/seghost
EOF
cat > /home/gpadmin/gpinitsystem_config<< EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=16000
declare -a DATA_DIRECTORY=(/data/primary /data/primary)
MASTER_HOSTNAME=cdh-upgrade-2
MASTER_DIRECTORY=/data/master
MASTER_PORT=15432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=17000
declare -a MIRROR_DATA_DIRECTORY=(/data/mirror /data/mirror)
DATABASE_NAME=test
MACHINE_LIST_FILE=/usr/local/greenplum-db/seghost
EOF
cat > /home/gpadmin/gpinitsystem_config<< EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=16000
declare -a DATA_DIRECTORY=(/data/primary /data/primary)
MASTER_HOSTNAME=cdh-upgrade-3
MASTER_DIRECTORY=/data/master
MASTER_PORT=15432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=17000
declare -a MIRROR_DATA_DIRECTORY=(/data/mirror /data/mirror)
DATABASE_NAME=test
MACHINE_LIST_FILE=/usr/local/greenplum-db/seghost
EOF
segment机器
# source /usr/local/greenplum-db/greenplum_path.sh
# gpssh -f seghost -e 'mkdir -p /data/primary'
# gpssh -f seghost -e 'mkdir -p /data/mirror'
# gpssh -f seghost -e 'chown -R gpadmin:gpadmin /data/*'
$ gpssh-exkeys -f /usr/local/greenplum-db/seghost
$ gpssh-exkeys -f /usr/local/greenplum-db/allhost
sudo chown -R gpadmin:gpadmin /data
mkdir -p /data/primary /data/mirror /data/master
mkdir -p data/mirror
mkdir -p data/master
初始化
- 正常的初始化
$ gpinitsystem -c gpinitsystem_config
- 带有Standby节点:
- Standby节点必须能ssh到所有机器,其他配置和master保持完全一致,同样需要提前建立data/master/文件夹。
$ gpinitsystem -c gpinitsystem_config -s aivmp-bigdata0001
- 如果初始化得时候没有做Standby,那就在集群正常运行得时候,在master节点运行
gpinitstandby
命令完成新增Stanby节点
$ gpinitstandby -s aivmp-bigdata0001
- 不成功了删除Stanby产生得脏数据,排错,从新建立Standby节点
$ rm -rf /home/gpadmin/data/master/*
- 初始化失败后,清楚数据,清楚日志,并重新初始化
# rm -rf /home/gpadmin/data/master/* /home/gpadmin/data/primary/* /home/gpadmin/data/mirror/* /home/gpadmin/gpAdminLogs /tmp/*
# rm -rf /data/master/* /data/primary/* /data/mirror/* /home/gpadmin/gpAdminLogs /tmp/*
# rm -rf /home/gpadmin/data /home/gpadmin/gpAdminLogs /tmp/*
授权远程连接
cat >> /data/master/gpseg-1/pg_hba.conf<<EOF
host all gpadmin 221.226.11.218/32 trust
host replication gpadmin 221.226.11.218/32 trust
EOF
cat >> /data/master/gpseg-1/pg_hba.conf<<EOF
host all all 0.0.0.0/0 trust
EOF
pg_ctl reload -D /data/master/gpseg-1/
cat >> /home/gpadmin/data/master/gpseg-1/pg_hba.conf<<EOF
host all gpadmin 221.226.11.218/32 trust
host replication gpadmin 221.226.11.218/32 trust
EOF
cat >> /home/gpadmin/data/master/gpseg-1/pg_hba.conf<<EOF
host all gpadmin 221.226.11.218/32 trust
host replication gpadmin 221.226.11.218/32 trust
host all all 0.0.0.0/0 trust
EOF
cat >> /home/gpadmin/data/master/gpseg-1/pg_hba.conf<<EOF
host all all 0.0.0.0/0 trust
EOF
pg_ctl reload -D /home/gpadmin/data/master/gpseg-1/
报错
- 如果初始化stanby节点报错:
-[ERROR]:-Failed to copy data directory from master to standby.
20200331:15:20:51:008596 gpinitstandby:pc3:gpadmin-[ERROR]:-Failed to create standby
[ERROR]:-Error initializing standby master: ExecutionError: 'non-zero rc: 1' occurred. Details: 'ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=60 pc1 ". /usr/local/greenplum-db/./greenplum_path.sh; pg_basebackup -c fast -D /data/greenplum/data/master/gpseg-1 -h pc3 -p 5432 --xlog --force-overwrite --write-recovery-conf --target-gp-dbid 7 -E ./db_dumps -E ./gpperfmon/data -E ./gpperfmon/logs -E ./promote --progress --verbose"' cmd had rc=1 completed=True halted=False
请确认原主库的防火墙端口是否开通
45d2e029-d13b-4f8b-9106-e00f05de2a9e
/dev/vdb1 /data xfs nodev,noatime,nobarrier,inode64 0 0
docker run -d -p 5432:5432 lyasper/greenplum:6
gpdeletesystem -d /data/master/gpseg-1 -f
标签:aivmp,安装,GreenPlum,greenplum,master,home,data,gpadmin
From: https://www.cnblogs.com/edclol/p/17282478.html