docker安装gp步骤
1.安装docker
略
2.安装基础镜像
# 拉取centos7最小安装镜像
$ docker pull centos:7
# 创建并后台启动容器,名称为dev,使用自定义的网络syf_net,指定静态ip(比如属于syf_net所指定的子网,如果使用非自定义网络,不可设置静态ip,自动分配)
$ docker run -dit --privileged --name dev centos /usr/sbin/init
# 在容器中打开一个交互终端
$ docker exec -it dev /bin/bash
# 安装常用工具和开发包
$ yum install -y net-tools which openssh-clients openssh-server less zip unzip iproute bzip2 cmake gcc gcc-c++ gdb git libtool lrzsz make man net-tools sysstat vim wget sudo
$ yum install -y apr-devel apr-util-devel bison bzip2-devel c-ares-devel flex java-1.8.0-openjdk java-1.8.0-openjdk-devel json-c-devel krb5-devel libcurl-devel libevent-devel libkadm5 libxml2-devel libxslt-devel libyaml-devel openldap-devel openssl-devel pam-devel perl perl-devel perl-ExtUtils-Embed readline-devel unixODBC-devel zlib-devel
# 设置系统参数
$ cat >> /etc/sysctl.conf <<-EOF
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 500 1024000 200 4096
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
EOF
$ cat >> /etc/security/limits.conf <<-EOF
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
EOF
$ cat >> /etc/ld.so.conf <<-EOF
/usr/local/lib
EOF
# 设置ssh自启动
systemctl enable sshd
systemctl start sshd
# 添加用户
passwd root
useradd -m gpadmin
passwd gpadmin
#创建目录
mkdir -p /data/master
mkdir -p /data1/primary /data1/mirror
mkdir -p /data2/primary /data2/mirror
chown -R gpadmin:gpadmin /data
chown -R gpadmin:gpadmin /data1
chown -R gpadmin:gpadmin /data2
# 退出当前终端
exit
# 把该容器制作为镜像
docker commit -a zhou -m "develop environment for greenplum" dev centos-gpdb
3.安装gp
# 基于新镜像启动容器
docker run -dit --privileged -v /tmp:/tmp -p 5432:5432 -p 28080:28080 --name mdw --hostname mdw centos-gpdb /usr/sbin/init
docker run -dit --privileged -v /tmp:/tmp --name sdw1 --hostname sdw1 centos-gpdb /usr/sbin/init
docker run -dit --privileged -v /tmp:/tmp --name sdw2 --hostname sdw2 centos-gpdb /usr/sbin/init
docker run -dit --privileged -v /tmp:/tmp --name sdw3 --hostname sdw3 centos-gpdb /usr/sbin/init
# 打开终端,可以以ssh方式或docker方式
docker exec -it master /bin/bash
# 每个节点都要进行 ip换为实际的(使用docker inspect [mdw, sdw1, sdw2, sdw3(任选一个)])
$ bash -c 'cat >> /etc/hosts <<-EOF
172.17.0.2 dw-greenplum-1 mdw
172.17.0.3 dw-greenplum-2 sdw1
172.17.0.6 dw-greenplum-3 sdw2
172.17.0.7 dw-greenplum-4 sdw3
EOF'
# 在主机点上运行
$ ssh-keygen -t rsa
$ cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
$ chmod 600 /root/.ssh/authorized_keys
$ vim /usr/local/bin/xsync(这是一个同步脚本)
(脚本见最后)
$ xsync /root/.ssh
之后输入密码
#在主节点运行
$ su gpadmin
$ ssh-keygen -t rsa
$ xsync /home/gpadmin/.ssh
# 进入docker主机 将下载好的gp安装包 放入/tmp下面
# 在所有节点上运行
yum install /tmp/greenplum-db-6.1.0-rhel7-x86_64.rpm
4.初始化(使用gpadmi用户 master上)
$ vim /home/gpadmin/conf/gpinitsystem_config
见后方
$ vim /home/gpadmin/conf/hostfile_gpssh_segonly
sdw1
sdw2
sdw3
cat ~/.bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
source /usr/local/greenplum-db/greenplum_path.sh
MASTER_DATA_DIRECTORY=/data/master/gpseg-1
export MASTER_DATA_DIRECTORY
source ~/.bash_profile
gpinitsystem -c /home/gpadmin/conf/gpinitsystem_config -h /home/gpadmin/conf/hostfile_gpinitsystem
出现successful installed即是安装完成
如果出现安装错误 需要看/home/gpadmin/gpAdminLogs/gpinitsystem_20200423.log
可以查看失败原因
xsync脚本
#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
pcount=$#
if ((pcount==0)); then
echo no args;
exit;
fi
#2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname
#3 获取上级目录到绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir
#4 获取当前用户名称
user=`whoami`
hosts=(mdw sdw1 sdw2 sdw3)
#5 循环
for host in ${hosts[*]}; do
echo ------------------- ${host} --------------
rsync -av $pdir/$fname $user@${host}:$pdir
done
gpinitsystem_config
# FILE NAME: gpinitsystem_config
# Configuration file needed by the gpinitsystem
################################################
#### REQUIRED PARAMETERS
################################################
#### Name of this Greenplum system enclosed in quotes.
ARRAY_NAME="Greenplum Data Platform"
#### Naming convention for utility-generated data directories.
SEG_PREFIX=gpseg
#### Base number by which primary segment port numbers
#### are calculated.
PORT_BASE=6000
### 这里需要和sysctl.conf中net.ipv4.ip_local_port_range对比 是否在ip_local_port_range范围内
#### File system location(s) where primary segment data directories
#### will be created. The number of locations in the list dictate
#### the number of primary segments that will get created per
#### physical host (if multiple addresses for a host are listed in
#### the hostfile, the number of segments will be spread evenly across
#### the specified interface addresses).
declare -a DATA_DIRECTORY=(/data1/primary /data1/primary /data1/primary /data2/primary /data2/primary /data2/primary)
#### OS-configured hostname or IP address of the master host.
MASTER_HOSTNAME=mdw
#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/data/master
#### Port number for the master instance.
MASTER_PORT=5432
#### Shell utility used to connect to remote hosts.
TRUSTED_SHELL=ssh
#### Maximum log file segments between automatic WAL checkpoints.
CHECK_POINT_SEGMENTS=8
#### Default server-side character set encoding.
ENCODING=UNICODE
####这里往下都是镜像segment设置
################################################
#### OPTIONAL MIRROR PARAMETERS
################################################
#### Base number by which mirror segment port numbers
#### are calculated.
MIRROR_PORT_BASE=7000
#### File system location(s) where mirror segment data directories
#### will be created. The number of mirror locations must equal the
#### number of primary locations as specified in the
#### DATA_DIRECTORY parameter.
declare -a MIRROR_DATA_DIRECTORY=(/data1/mirror /data1/mirror /data1/mirror /data2/mirror /data2/mirror /data2/mirror)
################################################
#### OTHER OPTIONAL PARAMETERS
################################################
#### Create a database of this name after initialization.
#DATABASE_NAME=name_of_database
#### Specify the location of the host address file here instead of
#### with the the -h option of gpinitsystem.
#MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem