暂无图片
暂无图片
2
暂无图片
暂无图片
暂无图片

openGauss 3.0.3容灾集群搭建

原创 ziyoo0830 2023-05-16
1132

openGauss容灾集群搭建

集群1

集群信息

omm@pghost1~$ cm_ctl query -Cvidp [ CMServer State ] node node_ip instance state --------------------------------------------------------------------- 1 pghost1 192.168.56.10 1 /app/ogdata/data/cm/cm_server Standby 2 pghost2 192.168.56.20 2 /app/ogdata/data/cm/cm_server Standby 3 pghost3 192.168.56.30 3 /app/ogdata/data/cm/cm_server Primary [ Cluster State ] cluster_state : Normal redistributing : No balanced : No current_az : AZ_ALL [ Datanode State ] node node_ip instance state | node node_ip instance state | node node_ip instance state --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 pghost1 192.168.56.10 6001 26000 /app/ogdata/data/dn1 P Standby Normal | 2 pghost2 192.168.56.20 6002 26000 /app/ogdata/data/dn1 S Standby Normal | 3 pghost3 192.168.56.30 6003 26000 /app/ogdata/data/dn1 S Primary Normal

集群2

集群信息

omm@pghost4~$ cm_ctl query -Cvidp [ CMServer State ] node node_ip instance state --------------------------------------------------------------------- 1 pghost4 192.168.56.40 1 /app/ogdata/data/cm/cm_server Primary 2 pghost5 192.168.56.50 2 /app/ogdata/data/cm/cm_server Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : Yes current_az : AZ_ALL [ Datanode State ] node node_ip instance state | node node_ip instance state -------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 pghost4 192.168.56.40 6001 27000 /app/ogdata/data/dn1 P Primary Normal | 2 pghost5 192.168.56.50 6002 27000 /app/ogdata/data/dn1 S Standby Normal

创建容灾用户

只在主集群创建。

omm@pghost3~$ gsql -d postgres -p 26000 -r gsql ((openGauss 3.0.3 build 46134f73) compiled at 2023-01-10 22:43:35 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=# create user dr_user with replication password 'oracle_4U'; NOTICE: The encrypted password contains MD5 ciphertext, which is not secure. CREATE ROLE

准备json配置文件

集群1json文件

{ "remoteClusterConf": { "port": 26500, "shards": [ [ { "ip": "192.168.56.40", "dataIp": "192.168.56.40" }, { "ip": "192.168.56.50", "dataIp": "192.168.56.50" } ] ] }, "localClusterConf": { "port": 26000, "shards": [ [ { "ip": "192.168.56.10", "dataIp": "192.168.56.10" }, { "ip": "192.168.56.20", "dataIp": "192.168.56.20" }, { "ip": "192.168.56.30", "dataIp": "192.168.56.30" } ] ] } }

集群2json文件

{ "localClusterConf": { "port": 26500, "shards": [ [ { "ip": "192.168.56.40", "dataIp": "192.168.56.40" }, { "ip": "192.168.56.50", "dataIp": "192.168.56.50" } ] ] }, "remoteClusterConf": { "port": 26000, "shards": [ [ { "ip": "192.168.56.10", "dataIp": "192.168.56.10" }, { "ip": "192.168.56.20", "dataIp": "192.168.56.20" }, { "ip": "192.168.56.30", "dataIp": "192.168.56.30" } ] ] } }

将集群1启动为主集群

gs_sdr -t start -m primary -X /home/omm/single.xml --json /home/omm/p.json -U dr_user -W oracle_4U omm@pghost3~$ gs_sdr -t start -m primary -X /home/omm/single.xml --json /home/omm/p.json -U dr_user -W oracle_4U -------------------------------------------------------------------------------- Streaming disaster recovery start 6adece36f3c411ed963408002772b626 -------------------------------------------------------------------------------- Start create streaming disaster relationship. Got the step for action:[start]. Start checking disaster recovery user. Successfully check disaster recovery user. Start generate hadr key files. Finished generate and distribute hadr key files. Start encrypt hadr user info. Successfully encrypt hadr user info. Start save hadr user info into database. Successfully save hadr user info into database. Successfully check cluster status is: Normal. Successfully check instance status. Start update pg_hba config. Successfully update pg_hba config. Start prepare secure files. Start copy hadr user key files. Successfully copy secure files. Starting reload wal_keep_segments value: 16384. Successfully reload wal_keep_segments value: 16384. Successfully set [/omm/CMServer/backup_open][0]. Waiting for the main standby connection. Main standby already connected. Successfully check cluster status is: Normal. Starting reload wal_keep_segments value: {'6003': '1024'}. Successfully reload wal_keep_segments value: {'6003': '1024'}. Successfully removed step file. Successfully do streaming disaster recovery start.

将集群2启动为备集群

gs_sdr -t start -m disaster_standby -X /home/omm/single.xml --json /home/omm/s.json -U dr_user -W oracle_4U --time-out=1400

查询

# 主集群 omm@pghost3~$ gs_sdr -t query -------------------------------------------------------------------------------- Streaming disaster recovery query 2aaacacef3c711ed916108002772b626 -------------------------------------------------------------------------------- Start streaming disaster query. Start check archive. Start check recovery. Start check RPO & RTO. Successfully executed streaming disaster recovery query, result: {'hadr_cluster_stat': 'archive', 'hadr_failover_stat': '', 'hadr_switchover_stat': '', 'RPO': '0', 'RTO': '0'} # 备集群 omm@pghost4~$ gs_sdr -t query -------------------------------------------------------------------------------- Streaming disaster recovery query be43f100f3c911edb941080027e6cc51 -------------------------------------------------------------------------------- Start streaming disaster query. Start check archive. Start check recovery. Start check RPO & RTO. Successfully executed streaming disaster recovery query, result: {'hadr_cluster_stat': 'recovery', 'hadr_failover_stat': '', 'hadr_switchover_stat': '', 'RPO': '', 'RTO': ''}
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
1人已赞赏
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论