本节主要从snova原生环境-greenplum编译安装入手,熟悉原生环境操作及使用。
目录:
基本概念:
GP | greenplum 5.21.1 |
---|---|
cvm | 腾讯云服务器 |
采用PG高可用架构,master部署两台,segment host部署部署两台,集群环境腾讯云CVM
节点名称 | 数量 | 配置 |
---|---|---|
pg-master | 1 | Centos7 1核2G 50G云盘 swap1G |
pg-standby | 1 | Centos7 1核2G 50G云盘 swap1G |
segment-host | 2 | Centos7 1核2G 50G云盘 swap1G |
htop查看机器情况:
yum install ntp vim
四台机器都需要修改
vi /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.overcommit_memory = 2
net.ipv4.ip_forward = 0
sysctl -p //配置生效命令
sysctl -a //打印配置参数信息
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
//此配置参数为及时生效,但是需要登录到新的会话页面查看。
blockdev --setra 65536 /dev/vda //物理机一般为sda,云盘为vda
echo deadline > /sys/block/sda/queue/scheduler
Centos7 系统为firewalld 守护进程,6系统为iptables
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config //重启生效
setenforce 0 //当前会话生效
sestatus //查看selinux状态
//hosts修改
172.16.0.8 gp-master
172.16.0.17 gp-standby
172.16.0.11 gp-node1
172.16.0.6 gp-node2
//hostname修改
vi /etc/sysconfig/network //配置文件修改
NETWORKING=yes
HOSTNAME=gp-master //各节点依次修改对应的名称
hostnamectl set-hostname gp-master //即时生效,需要登录新会话
在每个Segment主机,以root登录编辑/etc/ntp.conf文件。设置第一个server参数指向Master主机,第二个server参数指向Standby主机。如下面:
server gp-master prefer
server gp-standby
在Standby主机,以root登录编辑/etc/ntp.conf文件。设置第一个server参数指向Master主机
server gp-master prefer
//注意配置文件修改后需重启ntpd才能生效
systemctl restart ntpd
systemctl status ntpd //查看ntpd服务运行情况
pivotal官方预编译版本:
https://network.pivotal.io/products/pivotal-gpdb/#/releases/422445
rpm -ivh greenplum-db-5.21.1-rhel7-x86_64.rpm //安装rpm
useradd gpadmin //创建用户
passwd gpadmin //设定密码
su - gpadmin //切换到gpadmin用户
创建两个文件:包含以下内容
[gpadmin@gp-master ~]$ cat all_hosts
gp-master
gp-standby
gp-node1
gp-node2
[gpadmin@gp-master ~]$ cat seg_hosts
gp-node1
gp-node2
//以下gp命令在执行前,必须加载gp环境变量脚本,否则命令不可用
cd /home/gpadmin/
source /usr/local/greenplum-db/greenplum_path.sh
[root@gp-master gpadmin]# gpssh-exkeys -f all_hosts //建立互信
[INFO] completed successfully //最后输出此信息表示成功
cd /home/gpadmin/
source /usr/local/greenplum-db/greenplum_path.sh
gpseginstall -f all_hosts -u gpadmin -p gpadmin
//出现下述信息表示所有节点安装成功
20160827:13:58:47:020986 gpseginstall:greenplum_master:root-[INFO]:-SUCCESS -- Requested commands completed
su - gpadmin
source /usr/local/greenplum-db/greenplum_path.sh
gpssh -f all_hosts -e ls -l $GPHOME
mkdir -p /data/master
chown -R gpadmin.gpadmin /data/master/
cd /home/gpadmin/
source /usr/local/greenplum-db/greenplum_path.sh
gpssh -f seg_hosts -e 'mkdir -p /data/primary'
gpssh -f seg_hosts -e 'mkdir -p /data/mirror'
gpssh -f seg_hosts -e 'chown -R gpadmin.gpadmin /data/primary'
gpssh -f seg_hosts -e 'chown -R gpadmin.gpadmin /data/mirror'
cd /home/gpadmin/
source /usr/local/greenplum-db/greenplum_path.sh
[root@gp-master gpadmin]# gpcheck -f all_hosts -m gp-master
//如下信息代表完全无问题
20160827:16:47:47:022142 gpcheck:mdw:root-[INFO]:-dedupe hostnames
20160827:16:47:47:022142 gpcheck:mdw:root-[INFO]:-Detected platform: Generic Linux Cluster
20160827:16:47:47:022142 gpcheck:mdw:root-[INFO]:-generate data on servers
20160827:16:47:47:022142 gpcheck:mdw:root-[INFO]:-copy data files from servers
20160827:16:47:48:022142 gpcheck:mdw:root-[INFO]:-delete remote tmp files
20160827:16:47:48:022142 gpcheck:mdw:root-[INFO]:-Using gpcheck config file: /usr/local/greenplum-db/./etc/gpcheck.cnf
20160827:16:47:48:022142 gpcheck:mdw:root-[INFO]:-GPCHECK_NORMAL
20160827:16:47:48:022142 gpcheck:mdw:root-[INFO]:-gpcheck completing...
云服务器在检查时出现如下问题:磁盘预读参数,内核参数等问题,根据错误提示针对性调整即可。环境配置模块提供的内核参数,即为调整完成的。
su - gpadmin
cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/gpinitsystem_config
chmod 775 gpinitsystem_config
//修改如下内容
SEG_PREFIX=gpseg
declare -a DATA_DIRECTORY=(/data/primary)
MASTER_HOSTNAME=mdw
MASTER_DIRECTORY=/data/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
su - gpadmin
source /usr/local/greenplum-db/greenplum_path.sh
gpinitsystem -c gpinitsystem_config -h seg_hosts
//正常情况下会输出如下日志 无报错即表示成功
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-Review options for gpinitstandby
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-The Master /data/master/gpseg-1/pg_hba.conf post gpinitsystem
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-has been configured to allow all hosts within this new
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-new array must be explicitly added to this file
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-located in the /usr/local/greenplum-db/./docs directory
20160827:16:23:11:002458 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------
此处初始化可能会有错误,此次使用的cvm因为没有设置swap导致初始化时内存无法分配。
解决方法:
报错原因:可能swap太小或者没有交换分区 解决方法: (1)查看swap:swapon -s (2)如果什么都没有显示,说明你没有任何可用的swap,此时你可以添加1GB的swap: dd if=/dev/zero of=/swapfile bs=1024 count=1024k mkswap /swapfile swapon /swapfile (3)使swap持久化:vi /etc/fstab 加入/swapfile none swap sw 0 0
//在master服务器上执行
gpinitstandby -s gp-standby
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。