opengauss雙region流式容災搭建
本文出處:https://www.modb.pro/db/626197
一、主備雙叢集部署
架構:主叢集:一主一備;災備叢集:一主一備
1. 安裝叢集 1
主節點:...41 備節點:..***.***45
xml 檔案參考:
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CLUSTER>
<PARAM name="clusterName" value="openGauss" />
<PARAM name="nodeNames" value="OPGS1COM,OPGS2COM" />
<PARAM name="backIp1s" value="***.***.***.***41,***.***.***.***45"/>
<PARAM name="gaussdbAppPath" value="/gauss/openGauss/app" />
<PARAM name="gaussdbLogPath" value="/gaussarch/log" />
<PARAM name="tmpMppdbPath" value="/gauss/openGauss/tmp" />
<PARAM name="gaussdbToolPath" value="/gauss/openGauss/om" />
<PARAM name="corePath" value="/gaussarch/corefile"/>
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<DEVICELIST>
<DEVICE sn="1000001">
<PARAM name="name" value="OPGS1COM"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="***.***.***.***41"/>
<PARAM name="sshIp1" value="***.***.***.***41"/>
<!--CM節點部署資訊-->
<PARAM name="cmsNum" value="1"/>
<PARAM name="cmServerPortBase" value="15000"/>
<PARAM name="cmServerPortStandby" value="16000"/>
<PARAM name="cmServerListenIp1" value="***.***.***.***41,***.***.***.***45"/>
<PARAM name="cmServerHaIp1" value="***.***.***.***41,***.***.***.***45"/>
<PARAM name="cmServerlevel" value="1"/>
<PARAM name="cmServerRelation" value="OPGS1COM,OPGS2COM "/>
<PARAM name="cmDir" value="/gauss/openGauss/cm"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/gaussdata/openGauss/db1,OPGS2COM,/gaussdata/openGauss/db1"/>
<PARAM name="dataNode1_syncNum" value="1"/>
<PARAM name="localStreamIpmap1" value="(***.***.***.***41, ***.***.***.***41),(***.***.***.***45, ***.***.***.***45)"/>
<PARAM name="remoteStreamIpmap1" value="(***.***.***.***42, ***.***.***.***42),(***.***.***.***43, ***.***.***.***43)"/>
<PARAM name="remotedataPortBase" value="26000"/>
</DEVICE>
<DEVICE sn="1000002">
<PARAM name="name" value="OPGS2COM"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="***.***.***.***45"/>
<PARAM name="sshIp1" value="***.***.***.***45"/>
<!--CM-->
<PARAM name="cmDir" value="/gauss/openGauss/cm"/>
</DEVICE>
</DEVICELIST>
</ROOT>
2. 安裝叢集 2
主節點:...42 備節點:..***.***43
xml 檔案參考:
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CLUSTER>
<PARAM name="clusterName" value="openGauss" />
<PARAM name="nodeNames" value="OPGS3COM,OPGS4COM" />
<PARAM name="backIp1s" value="***.***.***.***42,***.***.***.***43"/>
<PARAM name="gaussdbAppPath" value="/gauss/openGauss/app" />
<PARAM name="gaussdbLogPath" value="/gaussarch/log" />
<PARAM name="tmpMppdbPath" value="/gauss/openGauss/tmp" />
<PARAM name="gaussdbToolPath" value="/gauss/openGauss/om" />
<PARAM name="corePath" value="/gaussarch/corefile"/>
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<DEVICELIST>
<DEVICE sn="1000001">
<PARAM name="name" value="OPGS3COM"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="***.***.***.***42"/>
<PARAM name="sshIp1" value="***.***.***.***42"/>
<!--CM節點部署資訊-->
<PARAM name="cmsNum" value="1"/>
<PARAM name="cmServerPortBase" value="17000"/>
<PARAM name="cmServerPortStandby" value="18000"/>
<PARAM name="cmServerListenIp1" value="***.***.***.***42,***.***.***.***43"/>
<PARAM name="cmServerHaIp1" value="***.***.***.***42,***.***.***.***43"/>
<PARAM name="cmServerlevel" value="1"/>
<PARAM name="cmServerRelation" value="OPGS3COM,OPGS4COM "/>
<PARAM name="cmDir" value="/gauss/openGauss/cm"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/gaussdata/openGauss/db1,OPGS4COM,/gaussdata/openGauss/db1"/>
<PARAM name="dataNode1_syncNum" value="1"/>
<PARAM name="localStreamIpmap1" value="(***.***.***.***42, ***.***.***.***42),(***.***.***.***43, ***.***.***.***43)"/>
<PARAM name="remoteStreamIpmap1" value="(***.***.***.***41, ***.***.***.***41),(***.***.***.***45, ***.***.***.***45)"/>
<PARAM name="remotedataPortBase" value="26000"/>
</DEVICE>
<DEVICE sn="1000002">
<PARAM name="name" value="OPGS4COM"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="***.***.***.***43"/>
<PARAM name="sshIp1" value="***.***.***.***43"/>
<!--CM-->
<PARAM name="cmDir" value="/gauss/openGauss/cm"/>
</DEVICE>
</DEVICELIST>
</ROOT>
3. 在主叢集建立容災使用者
gsql -d postgres -p PORT -c "create user DR_USERNAME with replication password '**_*********';"
4. 將叢集 1 啟動為主叢集
gs_sdr -t start -m primary -X XMLFILE [-U DR_USERNAME [-W **_*********]] [--time-out=SECS]
5. 將叢集 2 啟動為備叢集
gs_sdr -t start -m disaster_standby -U USER -W PASSWORD -X XMLFILE [-U DR_USERNAME [-W **_*********]] [--time-out=SECS]
6. 查詢
gs_sdr -t query
主叢集:
備叢集:
以上:
-U 容災使用者名稱,-W 容災使用者密碼,為可選引數,如果未攜帶需要在搭建過程中互動輸入;
–time-out 超時時間,為可選引數,預設為 1200 秒。
二、搭建容災關係前後引數對比
1. 方案
搭建前後將流複製相關引數匯入檔案,使用 diff 對比
2. 步驟
gsql -p 26000 -d postgres -c "select name,reset_val from pg_settings where category ='Write-Ahead Log / Settings'">settings1.log
gsql -p 26000 -d postgres -c "select name,reset_val from pg_settings where category ='Write-Ahead Log / Checkpoints'" >>settings1.log
gsql -p 26000 -d postgres -c "select name,reset_val from pg_settings where category ='Replication / Sending Servers'" >>settings1.log
gsql -p 26000 -d postgres -c "select name,reset_val from pg_settings where category ='Resource usage / Recovery'" >>settings1.log
gsql -p 26000 -d postgres -c "select name,reset_val from pg_settings where category ='Replication / Master Server'" >>settings1.log
gsql -p 26000 -d postgres -c "select name,reset_val from pg_settings where category ='Replication / Standby Servers'" >>settings1.log
- 對比結果
前
< replconninfo1| localhost=***.***.***.***41 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=***.***.***.***45 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004
< replconninfo2|
< replconninfo3|
後
> replconninfo1| localhost=***.***.***.***41 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=***.***.***.***45 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004 iscascade=true iscrossregion=false
> replconninfo2| localhost=***.***.***.***41 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=***.***.***.***42 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004 iscascade=false iscrossregion=true
> replconninfo3| localhost=***.***.***.***41 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=***.***.***.***43 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004 iscascade=false iscrossregion=true
前
< wal_keep_segments | 16
後
> wal_keep_segments | 128
注:主叢集搭建後 wal_keep_segments=128,備叢集搭建後 wal_keep_segments=16
前
< most_available_sync | off
後
> most_available_sync | on
後(新增)
opgs1com/opgs2com
stream_cluster_run_mode = 'cluster_primary'
opgs3com/opgs4com
stream_cluster_run_mode = 'cluster_standby'