任何分布式系统都要面对的事儿就包括扩容,不然分布式系统存在的意义就大打折扣了,这篇就介绍一下对GP进行扩容的准备过程,事实上,扩容的实施是个非常简单的过程,主要要做的就是准备。
用GP管理员OS用户gpadmin创建6个主机信息文件:
sdw1
sdw1-1
sdw1-2
sdw2
sdw2-1
sdw2-2
...
#!/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
chmod 755 /root/uetchosts20150523.sh
gpscp -f /home/gpadmin/currenthosts uetchosts20150523.sh =:/root/
gpssh -f /home/gpadmin/currenthosts /root/uetchosts20150523.sh
root登陆mdw,按照提示输入新服务器的root密码
source /usr/local/greenplum-db/greenplum_path.sh
gpssh-exkeys -e /home/gpadmin/20150523exp/currentnodes -x /home/gpadmin/20150523exp/newnodes
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
unset OPENSSL_CONF
gpseginstall -f /home/gpadmin/20150523exp/newnodes -u gpadmin -p p@ssword
gpssh -f /root/20150523exp/newhosts ll $GPHOME
如果使用了一些第三方的包,需要在新的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
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'
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