背景
机器为centos7.6机器,greenplum版本为6.16.0版本
安装方式:rpm包离线安装
Git地址:https://github.com/greenplum-db/gpdb/releases
文档:http://docs-cn.greenplum.org/v6/homenav.html
单机点安装
Rpm方式安装:
安装依赖:
libevent-2.0.21-4.el7.x86_64.rpm
bzip2-1.0.6-13.el7.x86_64.rpm
apr-1.4.8-5.el7.x86_64.rpm
apr-util-1.5.2-6.el7.x86_64.rpm
安装过程:
建立用户并设置密码
groupadd gpadmin
useradd gpadmin -g gpadmin
yes gpadmin|passwd gpadmin
设置新建用户免密登录
登录到新用户:su gpadmin
ssh-keygen -t rsa -P "" -f /home/gpadmin/.ssh/id_rsa
cat /home/gpadmin/.ssh/id_rsa.pub > /home/gpadmin/.ssh/authorized_keys
chmod 700 /home/gpadmin/.ssh/
chmod 600 /home/gpadmin/.ssh/authorized_keys
安装rpm安装包
安装:rpm -ivh greenplum-db-6.16.0-rhel7-x86_64.rpm
住:安装后默认在/usr/local下生成文件目录,并生成软链
修改目录权限:chown -R gpadmin:gpadmin /usr/local/greenplum-db-6.16.0/
修改系统配置:
增大系统信号量数
如果系统环境配置不是特别低建议设置该值高一些,例如:
kernel.shmall = 2041774
kernel.shmmax = 8363106304
kernel.shmmni = 4096
vm.overcommit_memory = 1
vm.overcommit_ratio = 95
net.ipv4.ip_local_port_range = 10000 65535
kernel.sem = 500 2048000 200 40960
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_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.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
在/etc/sysctl.conf设置该值,并通过sysctl -p命令生效
修改系统配置:vim /etc/security/limits.conf
* hard core 0
* soft nofile 65536
* hard nofile 65536
修改/etc/hosts文件
添加配置:ip hostname
例:10.0.10.10 sdw1
初始化服务
配置文件initConfig:
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=6000
declare -a DATA_DIRECTORY=(/data/gpadmin/gp0 /data/gpadmin/gp1 )
MASTER_HOSTNAME=hostname
MASTER_DIRECTORY=/data/gpadmin/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
DATABASE_NAME=gpdatabase
在root用户下创建相应目录并将目录权限更改为gpadmin用户:
mkdir -p /data/gpadmin/gp0 /data/gpadmin/gp1 /data/gpadmin/master
chown -R gpadmin:gpadmin /data/gpadmin/
配置文件hosts(每个节点的hostname):
Hostname1
初始化(需要到gpadmin用户下执行):
在/usr/local/greenplum-db/greenplum_path.sh添加参数:
export MASTER_DATA_DIRECTORY=/data/gpadmin/master/gpseg-1
export PGDATABASE=gpdatabase
export PGPORT=5432
编辑文件:vim ~/.bashrc 添加:source /usr/local/greenplum-db/greenplum_path.sh
进行初始化:./gpinitsystem -c initConfig -h hosts
设置远程连接
编辑文件:vim /data/gpadmin/master/gpseg-1/
添加参数:host all all 0.0.0.0/0 trust
并重新加载文件:./gpstop -u
shell实现自动化安装
通过shell实现服务安装
#!/bin/bash
GREENPLUM_HOME="greenplum-6.16.0"
userName=gpadmin
userPass="gpadmin"
useradd ${userName}
yes ${userPass}|passwd ${userPass}
chage -M 99999 gpadmin
mkdir -p /data/greenplum/master
mkdir -p /data/greenplum/gp0
mkdir -p /data/greenplum/gp1
mkdir -p /user/searchlight
echo `hostname` > /usr/local/${GREENPLUM_HOME}/bin/allhosts
echo 'net.ipv4.ip_local_reserved_ports = 3306,6379,6380,2182,2181,16000,16010,16020,16030,8083,8084,9093,9094,9993,1993,19093,1883,8883,18083,9090,11883,6369,5369,9092,8888,80,90,4242,4243,3000,8300,8301,8100,8098,18630,18333,8118,8119,7667,8282,7890,8180,8182,7601,8166,4245,7788,8890,9500,3090,3080,7300,9997,9998,9999,9796,9798,9001,9400,8080,8440,8441,9420,9421,9422,9419,9425,5443,6000,7000,6080,6081,7077,8670,44444,11001,11000,11443,2888,3888,60000,60010,60020,60030,9112,9111,4000,9115,9540,9109,9108,9308,9104,9100,9250,9091,9122,8038,51000,389,88,464,6667,9010,45454,6188,21000,21050,22000,23000,24000,25000,25010,25020,26000,28000,9200,9600,5601,9300,50030,50060,19888,13562,10020,8021,50070,9000,1004,1006,6627,8000,3772,3773,3774,6699,10015,4040,8088,8042,9083,10000,7070,6700-6749
kernel.shmall = 2041774
kernel.shmmax = 8363106304
kernel.shmmni = 4096
vm.overcommit_memory = 1
vm.overcommit_ratio = 95
net.ipv4.ip_local_port_range = 10000 65535
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_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.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
vm.max_map_count=655360
' >> /etc/sysctl.conf
sysctl -p
chown -R ${userName}:${userName} /usr/local/greenplum*
chown -R ${userName}:${userName} /data/greenplum
chown -R ${userName}:${userName} /home/${userName}
chown -R ${userName}:${userName} /user/searchlight
setfacl -m d:u:${userName}:rwx -R /user/searchlight
chmod +x /usr/local/${GREENPLUM_HOME}/*.sh
su - ${userName} -c "[ ! -f /home/${userName}/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -P \"\" -f /home/${userName}/.ssh/id_rsa"
su - ${userName} -c "cat /home/${userName}/.ssh/id_rsa.pub >> /home/${userName}/.ssh/authorized_keys"
chmod 700 /home/${userName}/.ssh
chmod 600 /home/${userName}/.ssh/authorized_keys
echo "source /usr/local/${GREENPLUM_HOME}/greenplum_path.sh " >> /home/${userName}/.bashrc
cd /usr/local/${GREENPLUM_HOME}/bin
su - ${userName} -c "yes y|gpinitsystem -c /usr/local/${GREENPLUM_HOME}/bin/initconfig -h /usr/local/${GREENPLUM_HOME}/bin/allhosts"
echo "host all ${userName} 0.0.0.0/0 md5
host all all ::1/128 md5
host all all 127.0.0.1/28 md5" >> /data/greenplum/master/gpseg-1/pg_hba.conf
su - ${userName} -c "yes y | gpstop -u"
echo "
log_filename = 'greenplum-%u.log'
log_truncate_on_rotation = on
log_rotation_size = 100MB
log_rotation_age = 1d
gp_enable_global_deadlock_detector = on
optimizer = off
" >> /data/greenplum/master/gpseg-1/postgresql.conf
su - ${userName} -c "gpconfig -c log_statement -v ddl"
su - ${userName} -c "yes y | gpstop -M fast"
su - ${userName} -c "yes y | gpstart"
定义greenplum初始化时initconfig文件
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=6000
declare -a DATA_DIRECTORY=(/data/greenplum/gp0 /data/greenplum/gp1)
MASTER_HOSTNAME=hostname
MASTER_DIRECTORY=/data/greenplum/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
DATABASE_NAME=gpadmin
定义greenplum目录中greenplum_path文件,此文件在服务通过rpm安装后,放入/usr/local/greenplum目录,覆盖原始文件
GPHOME=/usr/local/greenplum-db-6.16.0
PYTHONHOME="${GPHOME}/ext/python"
export PYTHONHOME
PATH="${PYTHONHOME}/bin:${PATH}"
LD_LIBRARY_PATH="${PYTHONHOME}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
PYTHONPATH="${GPHOME}/lib/python"
PATH="${GPHOME}/bin:${PATH}"
LD_LIBRARY_PATH="${GPHOME}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
if [ -e "${GPHOME}/etc/openssl.cnf" ]; then
OPENSSL_CONF="${GPHOME}/etc/openssl.cnf"
fi
export GPHOME
export PATH
export PYTHONPATH
export LD_LIBRARY_PATH
export OPENSSL_CONF
export MASTER_DATA_DIRECTORY=/data/greenplum/master/gpseg-1
export PGDATABASE=gpadmin
export PGPORT=5432
定义allhosts文件
hostname1
扩展--启停服务
命令: gpstart
作用: 开启gp数据库,将启动所有postgres数据库监听进程(master+所有segment)。
gpstart总是运行在master上的
命令: gpstop
作用: 用来停止或重启数据库,将停止所有postgres进程(master+所有segment)。
gpstop总是运行在master上的
默认情况下,系统将等待所有事务结束后再关闭,并且如果有任何活跃的连接都将不会停掉数据库。
命令: gpstop -r
作用: 一旦数据库被成功关闭的话,将重启数据库系统。
命令: gpstop -u
作用: 将pg_hba.conf文件重新上传 并运行master中的postgresql.conf 文件的参数,期间不会中断服务。
已建立连接的用户将不会使用最新配置,重连后将应用最新。
部分服务配置参数是需要重启整个系统才能被激活(gpstop -r)。
命令: gpstop -M fast
作用: 在快速模式下,停库。
所有活跃事务将中断或回滚,所有活跃连接被取消。