Greenplum数据库扩容实务(上)-准备工作

任何分布式系统都要面对的事儿就包括扩容,不然分布式系统存在的意义就大打折扣了,这篇就介绍一下对GP进行扩容的准备过程,事实上,扩容的实施是个非常简单的过程,主要要做的就是准备。

准备

创建主机信息文件

用GP管理员OS用户gpadmin创建6个主机信息文件:

  • /home/gpadmin/20150523exp/currenthosts:当前已经存在的所有主机的主机名
  • /home/gpadmin/20150523exp/currentnodes:当前已经存在的所有主机的主机名,以及seg node使用的地址,示例如下:
sdw1
sdw1-1
sdw1-2
sdw2
sdw2-1
sdw2-2
...
  • /home/gpadmin/20150523exp/newhosts:本次扩容的新主机的主机名
  • /home/gpadmin/20150523exp/newnodes:本次扩容的新主机的主机名,以及seg node使用的地址
  • /home/gpadmin/20150523exp/allhosts:新的旧的加一起的主机名
  • /home/gpadmin/20150523exp/allnodes:新的旧的加一起的主机名 ,以及seg node使用的地址

操作系统安装和配置

  • 安装新主机OS:所有配置应与已有主机一致,在特殊情况下(比如新服务器不再支持旧的OS),可按照GP本身的OS兼容性列表在新主机上使用较高版本OS。
  • root登陆mdw(GP master),编写一个脚本/root/uetchosts20150523.sh:
#!/bin/bash
echo –e >> /etc/hosts
echo "#20150523 expand hosts begin" >> /etc/hosts
echo 192.168.1.26 sdw26-1 sdw26 >> /etc/hosts
echo 192.168.2.26 sdw26-2 >> /etc/hosts
echo –e >> /etc/hosts
echo 192.168.1.27 sdw27-1 sdw27 >> /etc/hosts
echo 192.168.2.27 sdw27-2 >> /etc/hosts
...
echo "#20150523 expand hosts end" >> /etc/hosts
echo –e >> /etc/hosts
  • 用此脚本更新所有现有主机的hosts文件,添加新主机的域名解析
chmod 755 /root/uetchosts20150523.sh
gpscp -f /home/gpadmin/currenthosts uetchosts20150523.sh =:/root/
gpssh -f /home/gpadmin/currenthosts /root/uetchosts20150523.sh
  • 更新新增主机的hosts:root登陆新增的8台服务器,将现有seg host的/etc/hosts文件中关于GP主机的定义全部添加到/etc/hosts中

交换root授权信息

root登陆mdw,按照提示输入新服务器的root密码

source /usr/local/greenplum-db/greenplum_path.sh
gpssh-exkeys -e /home/gpadmin/20150523exp/currentnodes -x /home/gpadmin/20150523exp/newnodes 

创建gpadmin用户

gpssh -f /home/gpadmin/20150523exp/newhosts
=> useradd gpadmin -d /home/gpadmin
=> echo p@ssword | passwd gpadmin --stdin
=> ll /home
=> exit
su - gpadmin
gpssh-exkeys -e /home/gpadmin/20150523exp/currentnodes -x /home/gpadmin/20150523exp/newnodes
exit

更改操作系统配置并创建数据文件路径

gpscp -f /home/gpadmin/20150523exp/newhosts /etc/security/limits.conf =:/etc/security/limits.conf
gpscp -f /home/gpadmin/20150523exp/newhosts /etc/security/limits.d/90-nproc.conf  =:/etc/security/limits.d/90-nproc.conf
gpscp -f /home/gpadmin/20150523exp/newhosts /etc/sysctl.conf  =:/etc/sysctl.conf
gpssh -f /home/gpadmin/20150523exp/newhosts
=> sysctl –p
=> mkdir /data1/primary /data1/mirror /data2/primary /data2/mirror /data3/primary /data3/mirror /data4/primary /data4/mirror
=> chown -R gpadmin:gpadmin /data1'
=> chown -R gpadmin:gpadmin /data2'
=> chown -R gpadmin:gpadmin /data3'
=> chown -R gpadmin:gpadmin /data4'
=> ll /
=> ll /data1 /data2 /data3 /data4
=> exit
gpssh -f /home/gpadmin/20150523exp/allhosts 
=> echo 'deadline' > /sys/block/sda/queue/scheduler
=> echo 'deadline' > /sys/block/sdb/queue/scheduler
=> echo 'deadline' > /sys/block/sdc/queue/scheduler
=> echo 'deadline' > /sys/block/sr0/queue/scheduler
=> exit

安装GP并设置设备

unset OPENSSL_CONF
gpseginstall -f /home/gpadmin/20150523exp/newnodes -u gpadmin -p p@ssword
gpssh -f /root/20150523exp/newhosts ll $GPHOME

编译发布uuid

如果使用了一些第三方的包,需要在新的seg host进行编译发布,此处以uuid进行举例:

source /usr/local/greenplum-db/greenplum_path.sh
gpscp -f /home/gpadmin/20150523exp/newhosts /home/gpadmin/uuid-1.6.2.tar.gz =:/home/gpadmin
gpssh -f /home/gpadmin/20150523exp/newhosts
=> source /usr/local/greenplum-db/greenplum_path.sh
=> cd /home/gpadmin
=> tar zxvf uuid-1.6.2.tar.gz
=> cd uuid-1.6.2
=> ./configure --prefix=/usr/local/greenplum-db --with-pgsql
=> make
=> make install
=> chown -R gpadmin:gpadmin /usr/local/greenplum-db-4.3.5.0
=> ll /usr/local/greenplum-db-4.3.5.0/libuuid*
=> ll /usr/local/greenplum-db-4.3.5.0/lib/postgresql/uuid*
=> echo "source /usr/local/greenplum-db/greenplum_path.sh" >> /home/gpadmin/.bash_profile
=> cat /home/gpadmin/.bash_profile
=> ll $GPHOME
=> exit

检查OS配置和性能

检查所有节点状态

gpcheck -f /root/20150523exp/allnodes

在此过程中可能遇到如下问题:

  • 所有的节点都有如下告警,可忽略:
20150520:15:45:48:034966 gpcheck:mdw:root-[ERROR]:-GPCHECK_ERROR host(sdw25): on device (/dev/sdc2) blockdev readahead value '256' does not match expected value '16384'
  • 有机器的DNS和NTP没有正确配置,可通过脚本解决:
20150520:15:28:03:035830 gpcheck:mdw:root-[ERROR]:-GPCHECK_ERROR host(sdw24): potential NTPD issue.  gpcheck start time (Wed May 20 15:28:00 2015) time on machine (Wed May 20 15:27:36 2015)
gpscp -f /home/gpadmin/20150523exp/allhosts /etc/resolv.conf =:/etc/resolv.conf
gpssh -f /home/gpadmin/20150523exp/allhosts
=> service ntpd stop
=> ntpdate ntp.citicsinfo.com
=> service ntpd start
=> exit
gpssh -h sdw22 -h sdw23 -h sdw24
=> echo server ntp.citicsinfo.com >> /etc/ntp.conf
=> service ntpd stop
=> service ntpd start
=> exit
  • 新增加的机器操作系统版本与已有机器不一致,可忽略
20150520:15:49:15:038134 gpcheck:mdw:root-[ERROR]:-GPCHECK_ERROR host(sdw27): uname -r output different among hosts: sdw25 : 2.6.32-220.el6.x86_64 != sdw27 : 2.6.32-431.el6.x86_64

检查新节点的性能

gpcheckperf -f /home/gpadmin/20150523exp/newnodes -d /data1 -d /data2 -d /data3 -d /data4 -v

检查结果中只要IO都在1GB/s左右,就没有问题

生成扩容所需的输入文件

su - gpadmin
cd /home/gpadmin/20150523exp
gpexpand -f /home/gpadmin/20150523exp/newhosts -D dw

输入两个Y,再输入两个回车;生成文件类似如下名称:gpexpand_inputfile_20150520_161055

数据备份

pg_dump -f /data/dailybak/dw-nodata-$(date +%Y%m%d%H%M%S) -v -F c -C --inserts -s databasename

如果需要恢复,使用如下语句:

pg_restore -F c -d databasename -v -h mdw -p 5432 /data/dailybak/dw####_nodata

你可能感兴趣的:(大数据,PaaS)