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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章