openGauss5.1数据库管理指南:资源池化同城双中心部署

2023年 10月 24日 40.8k 0

  • 磁阵操作步骤

    1. 登录主集群DeviceManager,选择服务->LUN组->创建 来创建主集群LUN组;

    2. 登录主集群DeviceManager,选择数据保护->LUN->远程复制Pair->创建 为xlog卷创建远程复制Pair,执行完成后DeviceManager会在对端自动创建一个与本端xlog卷有同步复制关系的卷;

    3. 点击创建好的远程复制Pair,通过操作->分裂 将上一步建立的远程复制Pair分裂,此步骤是为了先分别拉起主备集群。

    4. 登录备集群DeviceManager,执行相同的创建LUN的操作,在创建的LUN组中点击成员LUN->增加,然后选择主集群上已经创建的xlog卷,添加xlog盘,并在备集群存储创建并映射剩余的3个lun。

    5. 在备集群DeviceManager中选择数据保护->LUN->远程复制Pair,然后搜索已经创建的远程复制Pair,通过操作->取消从资源保护使从端可读写。

    6. 在服务->LUN组->LUN中搜索刚才创建的LUN名称,查询本端WWN,用来在服务器上映射到对应的盘符。在服务器root用户下,执行rescan-scsi-bus.sh脚本扫描创建的LUN组,执行 ll /dev/disk/by-id | grep xxx 查询对应的盘符。

    第二步: 主存储上准备xml文件。

    在《文档->安装指南->企业版安装->安装openGauss->创建XML配置文件->配置数据库名称及各项目录》中有配置说明, https://docs.opengauss.org/zh/docs/5.0.0/docs/InstallationGuide/%E5%88%9B%E5%BB%BAXML%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.html

    根据配置说明准备资源池化集群需要的xml文件,以一主一备举例:

    将xml保存在/opt/software/openGauss/cluster_config.xml中

    Tips: 用户需要修改节点名称、节点IP、目录、盘符、端口号

    第三步: 在主存储上执行如下操作安装部署主集群,安装用户omm。

    执行《文档->安装指南->企业版安装->安装openGauss->初始化安装环境》中的步骤, https://docs.opengauss.org/zh/docs/5.0.0/docs/InstallationGuide/%E5%88%9D%E5%A7%8B%E5%8C%96%E5%AE%89%E8%A3%85%E7%8E%AF%E5%A2%83.html

    简化步骤如下:

    su - root
    mkdir -p /opt/software/openGauss
    chmod 755 -R /opt/software
    将下载的安装包放置/opt/software/openGauss目录下

    cd /opt/software/openGauss
    tar -zxvf openGauss-x.x.x-openEuler-64bit-all.tar.gz
    tar -zxvf openGauss-x.x.x-openEuler-64bit-om.tar.gz

    cd /opt/software/openGauss/script
    ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml --sep-env-file=/home/omm/env

    su - omm
    source /home/omm/env
    gs_install -X /opt/software/openGauss/cluster_config.xml --dorado-cluster-mode="primary"

    参数解释:

    • sep-env-file 分离环境变量,参数取值是一个安装用户omm可以访问到的文件目录
    • dorado-cluster-mode 主机群or备集群
    • omm 操作系统用户
    • dbgrp 操作系统用户属组

    第四步: 查询主集群状态。

    建立容灾关系之后就是主集群,未建立容灾关系之前还是资源池化单集群。

    [huawei@node1 dn_6001]$ cm_ctl query -Cvidp
    [ CMServer State ]

    node node_ip instance state
    -------------------------------------------------------------------------
    1 node1 10.0.0.10 1 /opt/huawei/install/cm/cm_server Primary
    2 node2 10.0.0.20 2 /opt/huawei/install/cm/cm_server Standby

    [ Defined Resource State ]

    node node_ip res_name instance state
    ---------------------------------------------------------
    1 node1 10.0.0.10 dms_res 6001 OnLine
    2 node2 10.0.0.20 dms_res 6002 OnLine
    1 node1 10.0.0.10 dss 20001 OnLine
    2 node2 10.0.0.20 dss 20002 OnLine

    [ 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 node1 10.0.0.10 6001 25400 /opt/huawei/install/data/dn P Primary Normal | 2 node2 10.0.0.20 6002 25400 /opt/huawei/install/data/dn S Standby Normal

    第五步: 在备存储上准备lun和xml文件。同第1步和第2步一样。

    Tips: 用户需要修改节点名称、节点IP、目录、盘符、端口号

    第六步: 在备存储上集群(建立容灾关系之后就是备集群)上执行如下操作安装部署备集群,安装用户omm。

    简化步骤如下:

    su - root
    mkdir -p /opt/software/openGauss
    chmod 755 -R /opt/software
    将下载的安装包放置/opt/software/openGauss目录下

    cd /opt/software/openGauss
    tar -zxvf openGauss-x.x.x-openEuler-64bit-all.tar.gz
    tar -zxvf openGauss-x.x.x-openEuler-64bit-om.tar.gz

    cd /opt/software/openGauss/script
    gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml --sep-env-file=/home/omm/env

    su - omm
    gs_install -X /opt/software/openGauss/cluster_config.xml --dorado-cluster-mode="standby"

    第七步: 查询备存储上集群(建立容灾关系之后就是备集群)状态。

    建立容灾关系之后就是备集群,未建立容灾关系之前还是资源池化单集群。
    [omm@node1 dn_6001]$ cm_ctl query -Cvidp
    [ CMServer State ]

    node node_ip instance state
    -------------------------------------------------------------------------
    1 node1 20.0.0.10 1 /opt/huawei/install/cm/cm_server Primary
    2 node2 20.0.0.20 2 /opt/huawei/install/cm/cm_server Standby

    [ Defined Resource State ]

    node node_ip res_name instance state
    ---------------------------------------------------------
    1 node1 20.0.0.10 dms_res 6001 OnLine
    2 node2 20.0.0.20 dms_res 6002 OnLine
    1 node1 20.0.0.10 dss 20001 OnLine
    2 node2 20.0.0.20 dss 20002 OnLine

    [ 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 node1 20.0.0.10 6001 25400 /opt/huawei/install/data/dn P Primary Normal | 2 node2 20.0.0.20 6002 25400 /opt/huawei/install/data/dn S Standby Normal

    第八步: 停止主集群,配置容灾参数,重新拉起主集群

    cm_ctl stop

    主节点
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "application_name = 'dn_master_0'"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo1='localhost=10.0.0.10 localport=25400 remotehost=20.0.0.10 remoteport=25400'"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo2='localhost=10.0.0.10 localport=25400 remotehost=20.0.0.20 remoteport=25400'"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "ha_module_debug = off"

    gs_guc set -N node1 -D /opt/mpp/install/data/dn -h "host all all 20.0.0.10/32 trust"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -h "host all all 20.0.0.20/32 trust"

    备节点
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "application_name = 'dn_master_1'"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo1='localhost=10.0.0.20 localport=25400 remotehost=20.0.0.10 remoteport=25400'"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo2='localhost=10.0.0.20 localport=25400 remotehost=20.0.0.20 remoteport=25400'"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "ha_module_debug = off"

    gs_guc set -N node2 -D /opt/mpp/install/data/dn -h "host all all 20.0.0.10/32 trust"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -h "host all all 20.0.0.20/32 trust"

    设置主集群cm参数
    cm_ctl set --param --agent -k dorado_cluster_mode=1

    启动主集群
    cm_ctl start

    参数解释:

    • cross_cluster_replconninfo 主备集群建立连接信息,localport为数据库HA端口(上述示例用的xml里的dataPortBase,当开启线程池enable_thread_pool时,需配置为实际HAPort)

    Tips: gs_guc为openGauss提供的修改配置文件工具,也可以通过直接打开/opt/huawei/install/data/dn($PGDATA)下的postgresql.conf与pg_hba.conf文件将上面双引号中的内容手动写入文件中。

    第九步:. 停止备存储上的资源池化单集群(建立容灾关系之后就是备集群),配置容灾参数

    cm_ctl stop

    主节点
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "application_name = 'dn_standby_0'"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo1='localhost=20.0.0.10 localport=25400 remotehost=10.0.0.10 remoteport=25400'"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo2='localhost=20.0.0.10 localport=25400 remotehost=10.0.0.20 remoteport=25400'"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -c "ha_module_debug = off"

    gs_guc set -N node1 -D /opt/mpp/install/data/dn -h "host all all 10.0.0.10/32 trust"
    gs_guc set -N node1 -D /opt/mpp/install/data/dn -h "host all all 10.0.0.20/32 trust"

    备节点
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "application_name = 'dn_standby_1'"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo1='localhost=20.0.0.20 localport=25400 remotehost=10.0.0.10 remoteport=25400'"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "cross_cluster_replconninfo2='localhost=20.0.0.20 localport=25400 remotehost=10.0.0.20 remoteport=25400'"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -c "ha_module_debug = off"

    gs_guc set -N node2 -D /opt/mpp/install/data/dn -h "host all all 10.0.0.10/32 trust"
    gs_guc set -N node2 -D /opt/mpp/install/data/dn -h "host all all 10.0.0.20/32 trust"

    第十步:. 拉起首备dssserver,执行build

    export DSS_MAINTAIN=TRUE // 打开dss手动模式
    dssserver -D /opt/huawei/install/dss_home & // 拉起dssserver,-D 指定$DSS_HOME
    gs_ctl build -D /opt/huawei/install/data/dn -b cross_cluster_full -q
    dsscmd stopdss // 停止手动模式的dssserver

    `Tips`: build必须需要加-q,指build成功后不拉起数据库。

    第十一步: 配置备集群cm参数,重新拉起备集群

    cm_ctl set --param --server -k backup_open=1
    cm_ctl set --param --agent -k agent_backup_open=1
    cm_ctl set --param --agent -k dorado_cluster_mode=2
    在$DSS_HOME/cfg/dss_inst.ini文件中增加一行(备集群所有节点)
    CLUSTER_RUN_MODE=cluster_standby

    切换同步复制关系 分裂改为同步(非常关键)

    cm_ctl start

    第十二步: 查询集群状态

    主集群使用cm_ctl query -Cvidp查询出来同第步一样
    备集群查询结果如下,备集群节点0从没有建立容灾关系时的primary变成建立容灾关系之后的Main Standby

    [mpp@node2 dn_6002]$ cm_ctl query -Cvidp
    [ CMServer State ]

    node node_ip instance state
    -------------------------------------------------------------------------
    1 node1 20.0.0.10 1 /opt/huawei/install/cm/cm_server Primary
    2 node2 20.0.0.20 2 /opt/huawei/install/cm/cm_server Standby

    [ Defined Resource State ]

    node node_ip res_name instance state
    ---------------------------------------------------------
    1 node1 20.0.0.10 dms_res 6001 OnLine
    2 node2 20.0.0.20 dms_res 6002 OnLine
    1 node1 20.0.0.10 dss 20001 OnLine
    2 node2 20.0.0.20 dss 20002 OnLine

    [ 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 node1 20.0.0.10 6001 25400 /opt/huawei/install/data/dn P Main Standby Normal | 2 node2 20.0.0.20 6002 25400 /opt/huawei/install/data/dn S Standby Normal

    第十三步: . 在主集群主机和备集群首备执行查询,可观察到流复制信息

    主集群主节点0
    [omm@node1 dn]$ gs_ctl query -D /opt/huawei/install/data/dn
    [2023-04-18 09:38:34.397][1498175][][gs_ctl]: gs_ctl query ,datadir is /opt/huawei/install/data/dn
    HA state:
    local_role : Primary
    static_connections : 2
    db_state : Normal
    detail_information : Normal

    Senders info:
    sender_pid : 1456376
    local_role : Primary
    peer_role : StandbyCluster_Standby
    peer_state : Normal
    state : Streaming
    sender_sent_location : 2/5C8
    sender_write_location : 2/5C8
    sender_flush_location : 2/5C8
    sender_replay_location : 2/5C8
    receiver_received_location : 2/5C8
    receiver_write_location : 2/5C8
    receiver_flush_location : 2/5C8
    receiver_replay_location : 2/5C8
    sync_percent : 100%
    sync_state : Async
    sync_priority : 0
    sync_most_available : Off
    channel : 10.0.0.10:25400-->20.0.0.10:43350

    Receiver info:
    No information

    备集群首备节点0
    [omm@nodename pg_log]$ gs_ctl query -D /opt/huawei/install/data/dn
    [2023-04-18 11:33:09.288][2760315][][gs_ctl]: gs_ctl query ,datadir is /opt/huawei/install/data/dn
    HA state:
    local_role : Main Standby
    static_connections : 2
    db_state : Normal
    detail_information : Normal

    Senders info:
    No information
    Receiver info:
    receiver_pid : 1901181
    local_role : Standby
    peer_role : Primary
    peer_state : Normal
    state : Normal
    sender_sent_location : 2/5C8
    sender_write_location : 2/5C8
    sender_flush_location : 2/5C8
    sender_replay_location : 2/5C8
    receiver_received_location : 2/5C8
    receiver_write_location : 2/5C8
    receiver_flush_location : 2/5C8
    receiver_replay_location : 2/5C8
    sync_percent : 100%
    channel : 20.0.0.10:43350

  • 相关文章

    Oracle如何使用授予和撤销权限的语法和示例
    Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
    下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
    社区版oceanbase安装
    Oracle 导出CSV工具-sqluldr2
    ETL数据集成丨快速将MySQL数据迁移至Doris数据库

    发布评论