环境
名称 | 说明 |
---|---|
操作系统 | CentOS7 x86_64 |
greenplum | greenplum-db-6.0.0-rhel7-x86_64.rpm |
下载地址
集群
Host | IP | 功能 |
---|---|---|
test1 | 172.20.0.23 | master |
test2 | 172.20.0.26 | segment |
test3 | 172.20.0.27 | segment |
修改/etc/hosts
每个节点都修改
vim /etc/hosts
172.20.0.23 test1 test1
172.20.0.26 test2 test2
172.20.0.27 test3 test3
修改/etc/sysconfig/network
每个节点都修改
vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME= host名字
修改/etc/security/limits.conf
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
修改/etc/sysctl.conf
vim /etc/sysctl.conf
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.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.swappiness = 10
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
vm.dirty_background_ratio = 0
vm.dirty_ratio=0
vm.dirty_background_bytes = 1610612736
vm.dirty_bytes = 4294967296
vm.overcommit_memory = 2 ### 测试环境要取消这个,否则oracle启不来 ### 值为1
让配置生效
sysctl -p
修改/etc/security/limits.d/90-nproc.conf
vim /etc/security/limits.d/90-nproc.conf
* soft nproc 131072
root soft nproc unlimited
关闭防火墙
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
修改/etc/selinux/config
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
拷贝文件到其他节点
scp /etc/sysctl.conf test2:/etc
scp /etc/security/limits.d/90-nproc.conf test2:/etc/security/limits.d
scp /etc/selinux/config test2:/etc/selinux
创建gpadmin用户
groupadd -g 530 gpadmin
useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin
chown -R gpadmin:gpadmin /home/gpadmin
passwd gpadmin 密码
echo "gpadmin" | passwd --stdin gpadmin
master安装greenplum
rpm -ivh greenplum-db-6.0.0-rhel7-x86_64.rpm
# 默认的安装路径是/usr/local,然后需要修改该路径gpadmin操作权限:
chown -R gpadmin:gpadmin /usr/local
创建hostlist
su - gpadmin
mkdir -p /home/gpadmin/conf
vim /home/gpadmin/conf/hostlist
test1
test2
test3
创建seg_hosts
vim /home/gpadmin/conf/seg_hosts
test2
test3
配置免密(每个节点)
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh -o stricthostkeychecking=no gpadmin@test1 "cat - >> ~/.ssh/authorized_keys"
cat ~/.ssh/id_rsa.pub | ssh -o stricthostkeychecking=no gpadmin@test2 "cat - >> ~/.ssh/authorized_keys"
cat ~/.ssh/id_rsa.pub | ssh -o stricthostkeychecking=no gpadmin@test3 "cat - >> ~/.ssh/authorized_keys"
# 配置ssh权限
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
greenplum配置ssh免密连接
su root
source /usr/local/greenplum-db/greenplum_path.sh
gpssh-exkeys -f /home/gpadmin/conf/hostlist
segment安装greenplum
权限
chown -R gpadmin:gpadmin /usr/local
chown -R gpadmin:gpadmin /opt
压缩、传到各节点
tar -cf gp.tar greenplum-db-5.0.0/
scp gp.tar test2:/usr/local
scp gp.tar test3:/usr/local
批量解压
source /usr/local/greenplum-db/greenplum_path.sh
gpssh -f /home/gpadmin/conf/seg_hosts
cd /usr/local
tar -xf gp.tar
# 因为greenplum默认的路径为greenplum-db需要映射过去
ln -s /urs/local/greenplum-db-6.0.0 greenplum-db
ll
exit
初始化数据库
source /usr/local/greenplum-db/greenplum_path.sh
gpssh -f /home/gpadmin/conf/hostlist #统一处理所有节点
# 创建资源目录 /opt/greenplum/data下一系列目录(生产目录个数可根据需求生成)
mkdir -p /opt/greenplum/data/master
mkdir -p /opt/greenplum/data/primary
mkdir -p /opt/greenplum/data/mirror
mkdir -p /opt/greenplum/data2/primary
mkdir -p /opt/greenplum/data2/mirror
环境变量配置
vim /home/gpadmin/.bash_profile
# 添加文本
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1
export GPPORT=5432
export PGDATABASE=gp_sydb
# 复制到各节点
scp /home/gpadmin/.bash_profile test2:/home/gpadmin/
source .bash_profile
NTP配置
gpssh -f /home/gpadmin/conf/hostlist -v -e 'sudo ntpd'
gpssh -f /home/gpadmin/conf/hostlist -v -e 'sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on'
检查个各节点的连通性
cd /usr/local/greenplum-db/bin
gpcheckperf -f /home/gpadmin/conf/hostlist -r N -d /tmp
修改/usr/local/greenplum-db/greenplum_path.sh
vim /usr/local/greenplum-db/greenplum_path.sh
# libgpopt.so.3所在的路径/usr/local/greenplum-db-6.0.0/lib
LD_LIBRARY_PATH=$GPHOME/lib:libgpopt.so.3所在的路径:${LD_LIBRARY_PATH-}
export LD_LIBRARY_PATH
初始化
cd /usr/local/greenplum-db/docs/cli_help/gpconfigs
cp gpinitsystem_config initgp_config
vim initgp_config
#以下为文本要修改的属性字段配置
#配置几次资源目录就是每个子节点有几个实例(推荐4-8个,这里配置了4个,primary与mirror文件夹个数对应)
declare -a DATA_DIRECTORY=(/opt/greenplum/data/primary /opt/greenplum/data/primary /opt/greenplum/data2/primary /opt/greenplum/data2/primary)
declare -a MIRROR_DATA_DIRECTORY=(/opt/greenplum/data/mirror /opt/greenplum/data/mirror /opt/greenplum/data2/mirror /opt/greenplum/data2/mirror)
ARRAY_NAME=”gp_sydb” #4.2.1章节配置的初始化数据库名称
MASTER_HOSTNAME=test1 #主节点名称
MASTER_DIRECTORY=/opt/greenplum/data/master #资源目录为在4.1章节创建的资源目录
MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1 #与4.1章节配置一样
DATABASE_NAME=gp_sydb #4.2.1章节配置的初始化数据库名称
MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts #就是3.2.2章节创建的文件
gpinitsystem -c initgp_config
数据库操作
gpstop -M fast
gpstart -a
psql -d postgres
\l # 查看数据库
\c # 进入数据库
\d # 查看表
\d tablename # 查看表结构