Greenplum install

架构:
master
主要建立与客户端的连接,收集segment的执行结果,不存放业务数据,可以一主一备
segment
业务数据存放处,执行master分发的SQL,一台机器可以配置多个segment,segment分primary和mirror

四台服务器搭建测试环境

192.168.101.115 master
192.168.101.116 segment+standby
192.168.100.217 segment
192.168.100.225 segment

分辨配置一个primary,一个mirror
对应后面参数路径,如果设置多个,空格分隔即可
declare -a DATA_DIRECTORY=(/data01/gpadmin/gpdata/primary)
declare -a MIRROR_DATA_DIRECTORY=(/data01/gpadmin/gpdata/mirror)

1.每台服务器/etc/hosts
192.168.101.115 db-192-168-101-115.sky-mobi.com db-192-168-101-115
192.168.101.116 db-192-168-101-116.sky-mobi.com db-192-168-101-116
192.168.100.217 db-192-168-100-217.sky-mobi.com db-192-168-100-217
192.168.100.225 db-192-168-100-225.sky-mobi.com db-192-168-100-225

2.配置/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.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 = 10000 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2

3.配置/etc/security/limits.conf

  • soft nofile 65536
  • hard nofile 65536
  • soft nproc 131072
  • hard nproc 131072
  1. 修改磁盘调度策略
    echo deadline > /sys/block/sba/queue/scheduler

5.执行安装程序
useradd gpadmin
passwd gpadmin
unzip greenplum-db-4.3.12.0-rhel5-x86_64.zip
./greenplum-db-4.3.12.0-rhel5-x86_64.bin
默认安装在/usr/local下

7.chown -R gpadmin.gpadmin /usr/local/greenplum-db
8.配置gpadmin环境变量,添加以下
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data01/gpadmin/gpdata/master/gpseg-1
export PGPORT=1922
export PS1=”$USER@/bin/hostname -s-> “

9.新建两个文件hostlist, seg_hosts
hostlist
db-192-168-101-115
db-192-168-101-116
db-192-168-100-217
db-192-168-100-225

seg_hosts
db-192-168-101-116
db-192-168-100-217
db-192-168-100-225

10.使用gpssh-exkeys打通所有服务器的透明登陆
gpssh-exkeys -f hostlist
gpssh -f hostlist ls //批量执行命令

11.打包安装好的目录,并复制到其他节点,解压
tar -cf gp.tar /use/local/greenplum-db-4.3.12.0/
gpscp -f hostlist gp.tar =:/home/gpmadin //批量服务到每个节点
tar -xf gp.tar //解压

12.建立相关数据目录赋予权限
mkdir -p /data01/gpadmin/gpdata/master
mkdir -p /data01/gpadmin/gpdata/primary
mkdir -p /data01/gpadmin/gpdata/mirror
chown -R gpadmin.gpadmin /data01/gpadmin/gpdata/master /data01/gpadmin/gpdata/primary /data01/gpadmin/gpdata/mirror

13.初始化Greenplum
复制配置文件到自己的目录
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/

修改后的相关参数
ARRAY_NAME=”SKY Greenplum DW”
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data01/gpadmin/gpdata/primary)
MASTER_HOSTNAME=db-192-168-101-115
MASTER_DIRECTORY=/data01/gpadmin/gpdata/master
MASTER_PORT=1922
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UTF-8
MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
MIRROR_REPLICATION_PORT_BASE=51000
declare -a MIRROR_DATA_DIRECTORY=(/data01/gpadmin/gpdata/mirror)
MACHINE_LIST_FILE=/home/gpadmin/seg_hosts

初始化GP
gpinitsystem -c /home/gpadmin/gpinitsystem_config -s db-192-168-101-116

数据库可以正常连接:
psql -d postgres
psql (8.2.15)
Type “help” for help.

postgres=# \l
List of databases
Name | Owner | Encoding | Access privileges
———–+———+———-+————————
hank | gpadmin | UTF8 | =Tc/gpadmin
: gpadmin=CTc/gpadmin
: hank=C
Tc/gpadmin
postgres | gpadmin | UTF8 |
template0 | gpadmin | UTF8 | =c/gpadmin
: gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8 | =c/gpadmin
: gpadmin=CTc/gpadmin

关闭与启动:
gpstart -a 启动
gpstop -a 关闭
gpstop -r 重启
gpstop -u 重载配置参数
gpstart -m 单用户维护模式启动
PGOPTIONS=’-c gp_session_role=utility’ psql
gpstate 查看GP状态

参考:http://gpdb.docs.pivotal.io/43120/install_guide/prep_os_install_gpdb.html

你活着,证明了什么?