G026-DB-GS-INS-03 OpenEuler 部署 OpenGauss(1主2备或多备)

Posted CloudCS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了G026-DB-GS-INS-03 OpenEuler 部署 OpenGauss(1主2备或多备)相关的知识,希望对你有一定的参考价值。

1 您需要了解

2 环境规划

主机名 IP地址 角色
cloudcsp 192.168.200.174 Primary 主库
cloudcss 192.168.200.175 Standby 备库 1
cloudcsc 192.168.200.176 Standby 备库 2
cloudcsx 192.168.200.xxx Standby 备库 n

3 系统环境配置

3.1 IP及主机名

# 主节点添加IP及主机名,并拷贝至其他备节点

[root@cloudcsp ~]# echo 192.168.200.174 cloudcsp >> /etc/hosts
[root@cloudcsp ~]# echo 192.168.200.175 cloudcss >> /etc/hosts
[root@cloudcsp ~]# echo 192.168.200.176 cloudcsc >> /etc/hosts
[root@cloudcsp ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.174 cloudcsp
192.168.200.175 cloudcss
192.168.200.176 cloudcsc

# 拷贝其他备节点
[root@cloudcsp ~]# scp /etc/hosts root@cloudcss:/etc/
The authenticity of host cloudcss (192.168.200.175) cant be established.
ECDSA key fingerprint is SHA256:FVfPVwBVqMPXZtdNP+IQ3QATCntfOkHn1Yhc0CK6VkI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added cloudcss,192.168.200.175 (ECDSA) to the list of known hosts.

Authorized users only. All activities may be monitored and reported.
root@cloudcsss password: 
hosts                                                                                           100%  233   226.9KB/s   00:00    
[root@cloudcsp ~]# scp /etc/hosts root@cloudcsc:/etc/
The authenticity of host cloudcsc (192.168.200.176) cant be established.
ECDSA key fingerprint is SHA256:LL/MPSQ+nmW8Sa000D+EzfBt0asc+68YOdUBBzG+ZDk.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added cloudcsc,192.168.200.176 (ECDSA) to the list of known hosts.

Authorized users only. All activities may be monitored and reported.
root@cloudcscs password: 
hosts                                                                                           100%  233   270.8KB/s   00:00

3.2 关闭防火墙(主备节点)

# 主节点
[root@cloudcsp ~]# systemctl stop firewalld
[root@cloudcsp ~]# systemctl disable firewalld
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.

# 备1节点
[root@cloudcss ~]# systemctl stop firewalld
[root@cloudcss ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

# 备2节点
[root@cloudcsc ~]# systemctl stop firewalld
[root@cloudcsc ~]# systemctl disable firewalld
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.

3.3 设置字符集及其他环境变量(主备节点)

备1节点

[root@cloudcss ~]# vi /etc/profile
[root@cloudcss ~]# cat /etc/profile |grep export |tail -n 3
export LANG=en_US.UTF-8
export packagePath=/opt/software/openGauss
export LD_LIBRARY_PATH=$packagePath/script/gspylib/clib:$LD_LIBRARY_PATH

备2节点

[root@cloudcsc ~]# cat /etc/profile |grep export |tail -n 3
export LANG=en_US.UTF-8
export packagePath=/opt/software/openGauss
export LD_LIBRARY_PATH=$packagePath/script/gspylib/clib:$LD_LIBRARY_PATH


## 3.4 取消内存限制参数(主备节点)

```shell
# 主节点
[root@cloudcsp ~]# vi /etc/profile.d/performance.sh
[root@cloudcsp ~]# cat /etc/profile.d/performance.sh
#sysctl -w vm.min_free_kbytes=112640 &> /dev/null

# 备1节点
[root@cloudcss ~]# vi /etc/profile.d/performance.sh
[root@cloudcss ~]# cat /etc/profile.d/performance.sh
#sysctl -w vm.min_free_kbytes=112640 &> /dev/null

# 备2节点
[root@cloudcsc ~]# vi /etc/profile.d/performance.sh
[root@cloudcsc ~]# cat /etc/profile.d/performance.sh
#sysctl -w vm.min_free_kbytes=112640 &> /dev/null

3.5 更换python版本(主备节点)

备1节点

[root@cloudcss ~]# python -V
Python 2.7.18
[root@cloudcss ~]# mv /usr/bin/python /usr/bin/python.bak
[root@cloudcss ~]# ln -s /usr/bin/python3 /usr/bin/python
[root@cloudcss ~]# python -V
Python 3.7.9

备2节点

[root@cloudcsc ~]# python -V
Python 2.7.18
[root@cloudcsc ~]# mv /usr/bin/python /usr/bin/python.bak
[root@cloudcsc ~]# ln -s /usr/bin/python3 /usr/bin/python
[root@cloudcsc ~]# python -V
Python 3.7.9


## 3.6 安装相关软件包(主备节点)

```shell
# 主节点
yum install -y libaio* \\
tar \\
vim \\
net*

# 备1节点
yum install -y libaio* \\
tar \\
vim \\
net*

# 备2节点
yum install -y libaio* \\
tar \\
vim \\
net*

4 安装 openGauss 数据库

4.1 上传并解压软件

[root@cloudcsp openGauss]# mkdir -p /opt/software/openGauss

# 上传软件至此目录

[root@cloudcsp ~]# cd /opt/software/openGauss
[root@cloudcsp openGauss]# tar -zxvf openGauss-2.1.0-openEuler-64bit-all.tar.gz
[root@cloudcsp openGauss]# tar -zxvf openGauss-2.1.0-openEuler-64bit-om.tar.gz

4.2 创建 XML 文件

4.2.1 1主2备配置

# 创建 XML 文件,并将配置内容写入 XML 文件
[root@cloudcsp openGauss]# vim clusterconfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <CLUSTER>
        <PARAM name="clusterName" value="ClusterPSS" />
        <PARAM name="nodeNames" value="cloudcsp,cloudcss,cloudcsc" />
        <PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
        <PARAM name="gaussdbLogPath" value="/var/log/omm" />
        <PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
        <PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
        <PARAM name="corePath" value="/opt/huawei/corefile"/>
        <PARAM name="backIp1s" value="192.168.200.174,192.168.200.175,192.168.200.176"/>
    </CLUSTER>
    <DEVICELIST>
        <DEVICE sn="cloudcsp">
            <PARAM name="name" value="cloudcsp"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <PARAM name="backIp1" value="192.168.200.174"/>
            <PARAM name="sshIp1" value="192.168.200.174"/>
        <!--dn-->
        <PARAM name="dataNum" value="1"/>
        <PARAM name="dataPortBase" value="26000"/>
        <PARAM name="dataNode1" value="/opt/huawei/install/data/dnp,cloudcss,/opt/huawei/install/data/dns1,cloudcsc,/opt/huawei/install/data/dns2"/>
        <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>
        <DEVICE sn="cloudcss">
            <PARAM name="name" value="cloudcss"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <PARAM name="backIp1" value="192.168.200.175"/>
            <PARAM name="sshIp1" value="192.168.200.175"/>
    </DEVICE>
        <DEVICE sn="cloudcsc">
            <PARAM name="name" value="cloudcsc"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <PARAM name="backIp1" value="192.168.200.176"/>
            <PARAM name="sshIp1" value="192.168.200.176"/>
    </DEVICE>
    </DEVICELIST>
</ROOT>

4.2.2 1主3备配置

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
        <!-- 数据库名称 -->
        <PARAM name="clusterName" value="Cluster_template" />
        <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="node1_hostname,node2_hostname,node3_hostname,node4_hostname" />
        <!-- 数据库安装目录-->
        <PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
        <!-- 日志目录-->
        <PARAM name="gaussdbLogPath" value="/var/log/omm" />
        <!-- 临时文件目录-->
        <PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
        <!-- 数据库工具目录-->
        <PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
        <!-- 数据库core文件目录-->
        <PARAM name="corePath" value="/opt/huawei/corefile"/>
        <!-- 节点IP,与数据库节点名称列表一一对应 -->
        <PARAM name="backIp1s" value="192.168.0.1,192.168.0.2,192.168.0.3,192.168.0.4"/>    
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- 节点1上的节点部署信息 -->
        <DEVICE sn="node1_hostname">
            <!-- 节点1的主机名称 -->
            <PARAM name="name" value="node1_hostname"/>
            <!-- 节点1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.1"/>
            <PARAM name="sshIp1" value="192.168.0.1"/>

        <!--dn-->
            <PARAM name="dataNum" value="1"/>
        <PARAM name="dataPortBase" value="26000"/>
        <PARAM name="dataNode1" value="/opt/huawei/install/data/dn,node2_hostname,/opt/huawei/install/data/dn,node3_hostname,/opt/huawei/install/data/dn,node4_hostname,/opt/huawei/install/data/dn"/>
            <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>

        <!-- 节点2上的部署信息 -->
        <DEVICE sn="node2_hostname">
            <!-- 节点2的主机名称 -->
            <PARAM name="name" value="node2_hostname"/>
            <!-- 节点2所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.2"/>
            <PARAM name="sshIp1" value="192.168.0.2"/>
    </DEVICE>

        <!-- 节点3上的部署信息 -->
        <DEVICE sn="node3_hostname">
            <!-- 节点3的主机名称 -->
            <PARAM name="name" value="node3_hostname"/>
            <!-- 节点3所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点3的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.3"/>
            <PARAM name="sshIp1" value="192.168.0.3"/>
    </DEVICE>

        <!-- 节点4上的部署信息 -->
        <DEVICE sn="node4_hostname">
            <!-- 节点4的主机名称 -->
            <PARAM name="name" value="node4_hostname"/>
            <!-- 节点4所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点4的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.4"/>
            <PARAM name="sshIp1" value="192.168.0.4"/>
    </DEVICE>
    </DEVICELIST>
</ROOT>

4.2.3 1主4备配置

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
        <!-- 数据库名称 -->
        <PARAM name="clusterName" value="Cluster_template" />
        <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="node1_hostname,node2_hostname,node3_hostname,node4_hostname,node5_hostname" />
        <!-- 数据库安装目录-->
        <PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
        <!-- 日志目录-->
        <PARAM name="gaussdbLogPath" value="/var/log/omm" />
        <!-- 临时文件目录-->
        <PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
        <!-- 数据库工具目录-->
        <PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
        <!-- 数据库core文件目录-->
        <PARAM name="corePath" value="/opt/huawei/corefile"/>
        <!-- 节点IP,与数据库节点名称列表一一对应 -->
        <PARAM name="backIp1s" value="192.168.0.1,192.168.0.2,192.168.0.3,192.168.0.4,192.168.0.5"/>      
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- 节点1上的节点部署信息 -->
        <DEVICE sn="node1_hostname">
            <!-- 节点1的主机名称 -->
            <PARAM name="name" value="node1_hostname"/>
            <!-- 节点1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.1"/>
            <PARAM name="sshIp1" value="192.168.0.1"/>

        <!--dn-->
            <PARAM name="dataNum" value="1"/>
        <PARAM name="dataPortBase" value="15400"/>
        <PARAM name="dataNode1" value="/opt/huawei/install/data/dn,node2_hostname,/opt/huawei/install/data/dn,node3_hostname,/opt/huawei/install/data/dn,node4_hostname,/opt/huawei/install/data/dn,node5_hostname,/opt/huawei/install/data/dn"/>
            <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>

        <!-- 节点2上的部署信息 -->
        <DEVICE sn="node2_hostname">
            <!-- 节点2的主机名称 -->
            <PARAM name="name" value="node2_hostname"/>
            <!-- 节点2所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.2"/>
            <PARAM name="sshIp1" value="192.168.0.2"/>
    </DEVICE>

        <!-- 节点3上的部署信息 -->
        <DEVICE sn="node3_hostname">
            <!-- 节点3的主机名称 -->
            <PARAM name="name" value="node3_hostname"/>
            <!-- 节点3所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点3的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.3"/>
            <PARAM name="sshIp1" value="192.168.0.3"/>
    </DEVICE>

        <!-- 节点4上的部署信息 -->
        <DEVICE sn="node4_hostname">
            <!-- 节点4的主机名称 -->
            <PARAM name="name" value="node4_hostname"/>
            <!-- 节点4所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点4的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.4"/>
            <PARAM name="sshIp1" value="192.168.0.4"/>

    </DEVICE>

        <!-- 节点5上的部署信息 -->
        <DEVICE sn="node5_hostname">
            <!-- 节点5的主机名称 -->
            <PARAM name="name" value="node5_hostname"/>
            <!-- 节点5所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点5的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.5"/>
            <PARAM name="sshIp1" value="192.168.0.5"/>
    </DEVICE>
    </DEVICELIST>
</ROOT>

4.3 配置用户和组及互信

[root@cloudcsp openGauss]# python /opt/software/openGauss/script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml

# 输出

Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Are you sure you want to create trust for root (yes/no)? yes
Please enter password for root.
Password: 
Creating SSH trust for the root permission user.
Checking network information.
All nodes in the network are Normal.
Successfully checked network information.
Creating SSH trust.
Creating the local key file.
Successfully created the local key files.
Appending local ID to authorized_keys.
Successfully appended local ID to authorized_keys.
Updating the known_hosts file.
Successfully updated the known_hosts file.
Appending authorized_key on the remote node.
Successfully appended authorized_key on all remote node.
Checking common authentication file content.
Successfully checked common authentication content.
Distributing SSH trust file to all node.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for the root permission user.
Setting pssh path
Successfully set core path.
Distributing package.
Begin to distribute package to tool path.
Successfully distribute package to tool path.
Begin to distribute package to package path.
Successfully distribute package to package path.
Successfully distributed package.
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Please enter password for cluster user.
Password: 
Please enter password for cluster user again.
Password: 
Successfully created [omm] user on all nodes.
Preparing SSH service.
Successfully prepared SSH service.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [omm] user.
Checking network information.
All nodes in the network are Normal.
Successfully checked network information.
Creating SSH trust.
Creating the local key file.
Successfully created the local key files.
Appending local ID to authorized_keys.
Successfully appended local ID to authorized_keys.
Updating the known_hosts file.
Successfully updated the known_hosts file.
Appending authorized_key on the remote node.
Successfully appended authorized_key on all remote node.
Checking common authentication file content.
Successfully checked common authentication content.
Distributing SSH trust file to all node.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for [omm] user.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating clusters path.
Successfully created clusters path.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/opt/software/openGauss/script/gs_checkos -i A -h cloudcsp,cloudcss,cloudcsc --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.

4.4 创建数据库

[root@cloudcsp openGauss]# chmod -R 755 /opt/software/openGauss/script/
[root@cloudcsp openGauss]# su - omm
[omm@cloudcsp ~]$ cd /opt/software/openGauss/script/
[omm@cloudcsp script]$ gs_install -X /opt/software/openGauss/clusterconfig.xml

# 输出

Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Successful check consistence of memCheck and coresCheck on all nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Successfully started cluster.
Successfully installed application.
end deploy..

4.5 查看集群状态

[omm@cloudcsp script]$ gs_om -t status --detail
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node    node_ip         port      instance                              state
-------------------------------------------------------------------------------------------------
1  cloudcsp 192.168.200.174 26000      6001 /opt/huawei/install/data/dnp    P Primary Normal
2  cloudcss 192.168.200.175 26000      6002 /opt/huawei/install/data/dns1   S Standby Normal
3  cloudcsc 192.168.200.176 26000      6003 /opt/huawei/install/data/dns2   S Standby Normal

  • END

以上是关于G026-DB-GS-INS-03 OpenEuler 部署 OpenGauss(1主2备或多备)的主要内容,如果未能解决你的问题,请参考以下文章

Rancher RFO 正式 GA

10G/40G/100G光模块的类型和应用

再解炸弹人,dfs&bfs

编码g.711 g.168 g.729 g.723 哪个好

二手iPad 价格

g:formatDate 作为 g:textField 上的值