fbpx

如何在 Pivotal Greenplum Database 擴充節點

gpexpand Lab (以下遮蔽系統訊息方便閱讀)

擴容前的環境 擴容後的環境
1Master +2 Segment 1Master +4 Segment
mdw
sdw1
sdw2
 
mdw
sdw1
sdw2
sdw3
sdw4

於正式環境需經過完整的規劃及考量,並通過 (gpcheck)(gpcheckperf)等等驗證.
 

hostfile加入下列主機 newhostfile加入下列主機
mdw
sdw1
sdw2
sdw3
sdw4
sdw3
sdw4
 

[gpadmin@mdw ~]$ gpssh-exkeys -f hostfile  
(重新交換金鑰)
[gpadmin@mdw ~]$gpssh –f newhostfile
(透過gpssh部署環境在新節點)

  • mkdir /data1/mirror
  • mkdir /data2/mirror
  • mkdir /data1/primary
  • mkdir /data2/primary

[gpadmin@mdw ~]$ gpseginstall -f newhostfile
(安裝greenplum db於新增節點)
[gpadmin@mdw ~]$ gpexpand -f newhost
…….
Please refer to the Admin Guide for more information.
Would you like to initiate a new System Expansion Yy|Nn (default=N):

  • Y

請選擇Y,否則會跳出此次命令
…….
How many new primary segments per host do you want to add? (default=0):

  • 0

是否希望提升每個節點的primary segment ,預設為0
Please review the file and make sure that it is correct then re-run
with: gpexpand -i gpexpand_inputfile_20150715_103959 -D gpadmin
….
將會產生一個gpexpand_inputfile_20150715_103959配置文件 
確認設定檔沒有問題後,進行gpexpand
[gpadmin@mdw ~]$ gpexpand -i gpexpand_inputfile_20150715_103959 -D gpadmin 
-D為指定gpexpand schema存放在哪個DB
(注意此時資料庫將會鎖定備份/data/master下的資料,目標位置hostname 必須正確 /etc/sysconfig/network)
如果失敗了並發現錯誤訊息,修正錯誤後進行rollback
[gpadmin@mdw ~]$ gpstart -m
(只啟動Master)
[gpadmin@mdw ~]$ gpexpand –rollback
[gpadmin@mdw ~]$ gpstart
順利完成後依照指式進行資料打散的任務
[gpadmin@mdw ~]$ gpexpand -d 60:00:00
(指定60小時內完成,執行過程中最消耗資源的表單資料重分佈,系統將會在比較空閒時執行)
[gpadmin@mdw ~]$ psql -c ‘ select * from pg_stat_activity’
(查詢現在正在運行的SQL)
[gpadmin@mdw ~]$ psql -c ‘select * from gpexpand.status_detail’ -d gpadmin
(表單分佈狀態)
以下為gpexpand schema所產生的視圖

  • status 起始時間
  • status_detail 完成哪幾個表單及哪幾個表單尚未開始
  • expansion_progress 資料平衡的總進度

當gpexpand -d 意外停止時,可以在重新開始執行將會繼續未完成的表單
確認任務都完成後進行gpexpand schema清除
[gpadmin@mdw ~]$ gpexpand -c
—————————————————————————————————————————-

擴容常見問題列表及注意事項

  1. 確認 /data/master 空間會增加一倍 (需注意metadata的存放空間)
  2. 確認 /data/master/gpseg-1/gppermon/data 檔案數量可能到千萬,將會造成gpexpan -i 無法完成.

[gpadmin@mdw ~]$ cd /data/master/gpseg-1/gppermon/data
[gpadmin@mdw ~]$ ls -1|wc -l 算檔案數量
[gpadmin@mdw ~]$ rm -rf *
如果檔案數太多刪不掉 需使用 xargs rm
[gpadmin@mdw ~]$ find . -name ‘*’ | xargs rm

  1. gpexpand:mdw:gpadmin-[ERROR]:-gpexpand failed: Invalid database ‘template1’ specified. Cannot use a template database.

Please set the environment variable PGDATABASE to a different database or use the -D option to specify a database and re-run
[gpadmin@mdw ~]$ export PGDATABASE=gpadmin
指定您的PGDATABASE

4.在有Mirror的狀態下Greenplum只允許一次擴容兩個節點以上,可參考如何擴充單一節點並手動搬移Mirror.

相關文章