首先確保關閉防火牆,修改全部的服務器節點的hosts文件,準備包含全部服務器IP的extra_pg_hba.conf做爲額外的參數。node
1.配置ssh免登錄sql
ssh-keygen -t rsa 【不輸入密碼】bash
cat id_rsa.pub > authorized_keys服務器
scp authorized_keys postgres@192.168.97.102:/home/postgres/.ssh/ssh
chmod 700 .ssh/ 【兩臺機器都須要】post
chmod 700 .ssh/authorized_keys 【兩臺機器都須要】測試
ssh postgres@192.168.97.102 【測試登陸是否須要輸入密碼】it
service firewalld stopast
2.安裝pgxc_ctl模塊class
3..bashrc中配置環境變量:
export dataDirRoot$HOMNE/pgxl/nodes
export PGHOME=/usr/local/pgsql
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
export PATH=$PATH:$HOME/bin:$PGHOME/bin
4.在pgxc_ctl命令下建立空的配置文件:prepare config empty
5.新增GTM master:PGXC$add gtm master gtm localhost 20001 $dataDirRoot/gtm
monitor all 【查看服務運行狀態】
6.初始化coornode和datanode:
add coordinator master coord1 localhost 30001 30011 $dataDirRoot/coord_master.1 none none
add coordinator master coord2 localhost 30002 30012 $dataDirRoot/coord_master.2 none none
add datanode master dn1 localhost 40001 40011 $dataDirRoot/dn_master.1 none none none
add datanode master dn2 localhost 40002 40012 $dataDirRoot/dn_master.2 none none none
【查看狀態: monitor all】