OpenGauss一主一从搭建(全网最详细,最简单)

OpenGauss一主一从搭建(全网最详细,最简单)

搭建步骤:

1.准备环境脚本,设置配置参数等:主库下载软件即可,备库无需下载软件(安装时从主库自动分发)
2.主库准备目录和xml脚本
3.主库预安装
4.主库安装
5.主备库检查和切换操作测试

(亲自踩雷搭建一主一从,被炸的体无完肤。。。。这篇文章有我遇到的几个小问题,如opengauss版本和系统版本不匹配的解决方案,如 omm权限不足等问题 希望对大家有帮助)

1.开始搭建:

1.1主机脚本

sh master.sh

#!/bin/bash  
## Author:       
## Date: 
## 2021-09-22 modified by jyc
## OS: CentOS7.6 [最小硬件配置:2c/4G] /centos 7.9   
## Database:openGauss 2.0.1 
## Description:一键式实现操作系统环境配置、openGauss软件下载、openGauss软件安装等步骤,帮助大家提升安装openGauss数据库效率   
## Tips:     请确保操作系统可以连接外网 
  
## 0.关闭virbr0网卡 [本地虚拟机标准化安装openEuler系统会默认存在virbr0网卡,删除该网卡以避免干扰数据库的安装] 
## virsh net-destroy default 
## virsh net-list 
## echo "Net device virbr0 is disabled."
  
## 0.定义主机信息[请根据实际情况修改]   
export MY_HOSTNAME=omm02 ## 主机名 两台主机名不要一样哦
export MY_HOSTIP=192.168.52.143 ## IP地址  
export MY_SOFTWARE_DIRECTORY=/soft/openGauss ## 软件包所在目录 
export MY_XML=/soft/openGauss/clusterconfig.xml   ## 集群配置文件XML
export openGauss_Download_url=https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.1/x86/openGauss-2.0.1-CentOS-64bit-all.tar.gz  ## openGauss软件包下载地址
  
## 1. 设置主机名并配置hosts文件   
hostnamectl set-hostname $MY_HOSTNAME   
sed -i '/$MY_HOSTIP/d' /etc/hosts 
echo "$MY_HOSTIP  $MY_HOSTNAME   #Gauss OM IP Hosts Mapping" >> /etc/hosts
cat /etc/hosts    
echo "1.Configure /etc/hosts completed."
echo -e "\n" 
  
## 2. 关闭防火墙  
systemctl disable firewalld.service     
systemctl stop firewalld.service  
echo "Firewalld " `systemctl status firewalld|grep Active`
echo "2.Disable firewalld service completed."   
echo -e "\n" 
  
## 3. 关闭SELinux 
sed -i '/^SELINUX=/d' /etc/selinux/config 
echo "SELINUX=disabled" >> /etc/selinux/config  
cat /etc/selinux/config|grep "SELINUX=disabled" 
echo "3.Disable SELINUX completed."     
echo -e "\n" 
  
## 4. 设置操作系统字符集编码 
echo "LANG=en_US.UTF-8" >> /etc/profile 
source /etc/profile     
echo $LANG   
echo "4.Configure encoding completed."  
echo -e "\n" 
  
## 5. 设置操作系统时区  
rm -fr /etc/localtime   
ln -s /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime   
date -R 
hwclock 
echo "5.Configure Timezone completed."  
echo -e "\n" 
  
## 6. 关闭SWAP分区 [对于2G内存的设备,建议待安装完毕后再打开SWAP以间接 “扩容内存容量”]
sed -i '/swap/s/^/#/' /etc/fstab  
swapoff -a   
free -m 
echo "6.Close swap partition completed."
echo -e "\n" 
  
## 7. 配置SSH服务,关闭Banner,允许root远程登录 
sed -i '/Banner/s/^/#/'  /etc/ssh/sshd_config   
sed -i '/PermitRootLogin/s/^/#/'  /etc/ssh/sshd_config    
echo -e "\n" >> /etc/ssh/sshd_config    
echo "Banner none " >> /etc/ssh/sshd_config     
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config  
cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRoot|Banner'    
echo "7.Configure SSH Service completed." 
echo -e "\n" 
  
## 8. 配置YUM源、安装依赖包、修改默认Python3版本
yum install -y wget     
mkdir /etc/yum.repos.d/bak   
mv /etc/yum.repos.d/*.repo  /etc/yum.repos.d/bak/   
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
yum clean all
yum install -y bzip2 python3 
yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel net-tools tar
mv /usr/bin/python  /usr/bin/python2_bak
ln -s /usr/bin/python3 /usr/bin/python  
python -V    
echo "8.Configure Install Packages and change default Python version completed."   
echo -e "\n" 
  
## 9. 配置 sysctl.conf 和 performance.sh
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
EOF 
sysctl -p
echo "9.Configure sysctl.conf and performance.sh completed."
echo -e "\n"

## 10. 配置资源限制
echo "* soft stack 3072" >> /etc/security/limits.conf
echo "* hard stack 3072" >> /etc/security/limits.conf
echo "* soft nofile 1000000" >> /etc/security/limits.conf
echo "* hard nofile 1000000" >> /etc/security/limits.conf
echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf
tail -n 4 /etc/security/limits.conf
tail -n 1 /etc/security/limits.d/90-nproc.conf
echo "10.Configure resource limits completed."
echo -e "\n"

## 11. 关闭透明大页[Only for CentOS]
cat >>/etc/rc.d/rc.local<<EOF
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF
chmod +x /etc/rc.d/rc.local
/usr/bin/sh /etc/rc.d/rc.local
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
echo "11.Close transparent_hugepage completed."
echo -e "\n"

## 12. 禁用RemoveIPC[Only for openEuler]
## sed -i '/^RemoveIPC/d' /etc/systemd/logind.conf
## sed -i '/^RemoveIPC/d' /usr/lib/systemd/system/systemd-logind.service
## echo "RemoveIPC=no"  >> /etc/systemd/logind.conf
## echo "RemoveIPC=no"  >> /usr/lib/systemd/system/systemd-logind.service
## systemctl daemon-reload
## systemctl restart systemd-logind
## loginctl show-session | grep RemoveIPC
## systemctl show systemd-logind | grep RemoveIPC
## echo "12.Disable RemoveIPC completed."
## echo -e "\n"

## 13. 下载openGauss软件包
mkdir -p $MY_SOFTWARE_DIRECTORY
cd $MY_SOFTWARE_DIRECTORY
wget $openGauss_Download_url
echo "13.openGauss software download completed."
echo -e "\n"    
 
  
## 14. 解压安装包并修改目录权限   
echo "Begin to Uncompress openGauss Package and Modify directory permissions:"
cd $MY_SOFTWARE_DIRECTORY
tar -zxvf *all.tar.gz
tar -zxvf *om.tar.gz
ls -l
chmod -R 777 $MY_SOFTWARE_DIRECTORY/../
echo "15.Uncompress openGauss Package completed."
echo -e "\n"

1.2从机脚本

sh slave.sh

#!/bin/bash  
## Author:  贾军锋     
## Date:    2021-04-15 
## 2021-09-22 modified by jyc
## OS: CentOS7.6 [最小硬件配置:2c/4G]    
## Database:openGauss 2.0.1 
## Description:一键式实现操作系统环境配置、openGauss软件下载、openGauss软件安装等步骤,帮助大家提升安装openGauss数据库效率   
## Tips:     请确保操作系统可以连接外网 
  
## 0.关闭virbr0网卡 [本地虚拟机标准化安装openEuler系统会默认存在virbr0网卡,删除该网卡以避免干扰数据库的安装] 
## virsh net-destroy default 
## virsh net-list 
## echo "Net device virbr0 is disabled."
  
## 0.定义主机信息[请根据实际情况修改]   
export MY_HOSTNAME=omm03 ## 主机名    
export MY_HOSTIP=192.168.52.144 ## IP地址  
export MY_SOFTWARE_DIRECTORY=/soft/openGauss ## 软件包所在目录 
export MY_XML=/soft/openGauss/clusterconfig.xml   ## 集群配置文件XML
export openGauss_Download_url=https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.1/x86/openGauss-2.0.1-CentOS-64bit-all.tar.gz  ## openGauss软件包下载地址
  
## 1. 设置主机名并配置hosts文件   
hostnamectl set-hostname $MY_HOSTNAME   
sed -i '/$MY_HOSTIP/d' /etc/hosts 
echo "$MY_HOSTIP  $MY_HOSTNAME   #Gauss OM IP Hosts Mapping" >> /etc/hosts
cat /etc/hosts    
echo "1.Configure /etc/hosts completed."
echo -e "\n" 
  
## 2. 关闭防火墙  
systemctl disable firewalld.service     
systemctl stop firewalld.service  
echo "Firewalld " `systemctl status firewalld|grep Active`
echo "2.Disable firewalld service completed."   
echo -e "\n" 
  
## 3. 关闭SELinux 
sed -i '/^SELINUX=/d' /etc/selinux/config 
echo "SELINUX=disabled" >> /etc/selinux/config  
cat /etc/selinux/config|grep "SELINUX=disabled" 
echo "3.Disable SELINUX completed."     
echo -e "\n" 
  
## 4. 设置操作系统字符集编码 
echo "LANG=en_US.UTF-8" >> /etc/profile 
source /etc/profile     
echo $LANG   
echo "4.Configure encoding completed."  
echo -e "\n" 
  
## 5. 设置操作系统时区  
rm -fr /etc/localtime   
ln -s /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime   
date -R 
hwclock 
echo "5.Configure Timezone completed."  
echo -e "\n" 
  
## 6. 关闭SWAP分区 [对于2G内存的设备,建议待安装完毕后再打开SWAP以间接 “扩容内存容量”]
sed -i '/swap/s/^/#/' /etc/fstab  
swapoff -a   
free -m 
echo "6.Close swap partition completed."
echo -e "\n" 
  
## 7. 配置SSH服务,关闭Banner,允许root远程登录 
sed -i '/Banner/s/^/#/'  /etc/ssh/sshd_config   
sed -i '/PermitRootLogin/s/^/#/'  /etc/ssh/sshd_config    
echo -e "\n" >> /etc/ssh/sshd_config    
echo "Banner none " >> /etc/ssh/sshd_config     
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config  
cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRoot|Banner'    
echo "7.Configure SSH Service completed." 
echo -e "\n" 
  
## 8. 配置YUM源、安装依赖包、修改默认Python3版本
yum install -y wget     
mkdir /etc/yum.repos.d/bak   
mv /etc/yum.repos.d/*.repo  /etc/yum.repos.d/bak/   
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
yum clean all
yum install -y bzip2 python3 
yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel net-tools tar
mv /usr/bin/python  /usr/bin/python2_bak
ln -s /usr/bin/python3 /usr/bin/python  
python -V    
echo "8.Configure Install Packages and change default Python version completed."   
echo -e "\n" 
  
## 9. 配置 sysctl.conf 和 performance.sh
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
EOF 
sysctl -p
echo "9.Configure sysctl.conf and performance.sh completed."
echo -e "\n"

## 10. 配置资源限制
echo "* soft stack 3072" >> /etc/security/limits.conf
echo "* hard stack 3072" >> /etc/security/limits.conf
echo "* soft nofile 1000000" >> /etc/security/limits.conf
echo "* hard nofile 1000000" >> /etc/security/limits.conf
echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf
tail -n 4 /etc/security/limits.conf
tail -n 1 /etc/security/limits.d/90-nproc.conf
echo "10.Configure resource limits completed."
echo -e "\n"

## 11. 关闭透明大页[Only for CentOS]
cat >>/etc/rc.d/rc.local<<EOF
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF
chmod +x /etc/rc.d/rc.local
/usr/bin/sh /etc/rc.d/rc.local
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
echo "11.Close transparent_hugepage completed."
echo -e "\n"

## 12. 禁用RemoveIPC[Only for openEuler]
## sed -i '/^RemoveIPC/d' /etc/systemd/logind.conf
## sed -i '/^RemoveIPC/d' /usr/lib/systemd/system/systemd-logind.service
## echo "RemoveIPC=no"  >> /etc/systemd/logind.conf
## echo "RemoveIPC=no"  >> /usr/lib/systemd/system/systemd-logind.service
## systemctl daemon-reload
## systemctl restart systemd-logind
## loginctl show-session | grep RemoveIPC
## systemctl show systemd-logind | grep RemoveIPC
## echo "12.Disable RemoveIPC completed."
## echo -e "\n"

1.3主库上准备集群参数文件clusterconfig.xml (路径在 /soft 下 需要修改ip)

<?xml version="1.0" encoding="UTF-8"?> 
<ROOT> 
    <!-- openGauss整体信息 --> 
    <CLUSTER> 
        <PARAM name="clusterName" value="dbCluster" /> 
        <PARAM name="nodeNames" value="omm02,omm03" /> 
        <PARAM name="backIp1s" value="192.168.52.143,192.168.52.144"/> 
        <PARAM name="gaussdbAppPath" value="/gaussdb/app" /> 
        <PARAM name="gaussdbLogPath" value="/gaussdb/log" /> 
        <PARAM name="gaussdbToolPath" value="/gaussdb/om" /> 
        <PARAM name="corePath" value="/gaussdb/corefile"/> 
    </CLUSTER> 
    <!-- 每台服务器上的节点部署信息 --> 
    <DEVICELIST> 
        <!-- node1上的节点部署信息 --> 
        <DEVICE sn="omm02"> 
            <PARAM name="name" value="omm02"/> 
            <PARAM name="azName" value="AZ1"/> 
            <PARAM name="azPriority" value="1"/> 
            <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP --> 
            <PARAM name="backIp1" value="192.168.52.143"/> 
            <PARAM name="sshIp1" value="192.168.52.143"/>             
            <!--dbnode--> 
            <PARAM name="dataNum" value="1"/> 
            <PARAM name="dataPortBase" value="26000"/> 
            <PARAM name="dataNode1" value="/gaussdb/data/db1,omm03,/gaussdb/data/db1"/> 
            <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE> 
        <!-- node1上的节点部署信息 -->
        <DEVICE sn="omm03">
            <PARAM name="name" value="omm03"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.52.144"/>
            <PARAM name="sshIp1" value="192.168.52.144"/>
        </DEVICE>
    </DEVICELIST>
</ROOT>

1.4主库预安装:注意目录权限即可 chown -R omm:dbgrp /gaussdb

Exception: [GAUSS-51900] : The current OS is not supported. The current system is: centos7.9

如果出现上述问题不要慌我们只需要

 cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
修改为
CentOS Linux release 7.6.1810 (Core)

 vim /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[GAUSS-50202] : The /gaussdb must be empty. Or user [omm] has write permission to directory
 /gaussdb. Because it will create symbolic link [/gaussdb/app] to install 
 path [/gaussdb/app_d97c0e8a] in gs_install process with this user.

注意:出现上述问题是因为 omm的权限不够 以及 还要把/gaussdb 下的文件清空 还要给从库的 omm也提升权限 以及从库/gaussdb 下的文件清空

解决方案:

预安装的时候/gaussdb目录权限有问题导致失败,修复处理
[root@omm03 ~]# chown -R omm:dbgrp /gaussdb
[root@omm03 ~]# ll /gaussdb/
total 0
drwx------. 2 omm dbgrp   6 Sep 22 16:42 app_d97c0e8a
drwx------. 3 omm dbgrp  17 Sep 22 16:42 data
drwxr-x---. 3 omm dbgrp  17 Sep 22 16:42 log
drwxr-xr-x. 5 omm dbgrp 251 Sep 22 16:42 om
[root@omm03 ~]# rm -rf /gaussdb/* 

正式操作:

[root@omm02 soft]# mkdir -p /gaussdb
[root@omm02 soft]# ll /gaussdb/
total 0
[root@omm02 soft]# pwd
/soft
[root@omm02 soft]# cd openGauss/script/
[root@omm02 script]# ./gs_preinstall -U omm -G dbgrp -X /soft/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 cluster is path.
[FAILURE] omm02:
[GAUSS-50202] : The /gaussdb must be empty. Or user [omm] has write permission to directory /gaussdb. Because it will create symbolic link [/gaussdb/app] to install path [/gaussdb/app_d97c0e8a] in gs_install process with this user.
(这里出现问题了)
[SUCCESS] omm03:

[root@omm02 script]# ll /gaussdb/
total 0
drwx------. 2 omm dbgrp  6 Sep 22 16:42 app_d97c0e8a
drwxr-x---. 3 omm dbgrp 17 Sep 22 16:41 log
[root@omm02 script]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.52.143  omm02  #Gauss OM IP Hosts Mapping
192.168.52.144  omm03  #Gauss OM IP Hosts Mapping
[root@omm02 script]# chown -R omm:dbgrp /soft
[root@omm02 script]# chown -R omm:dbgrp /gaussdb
[root@omm02 script]# rm -rf /gaussdb/*
[root@omm02 script]# ./gs_preinstall -U omm -G dbgrp -X /soft/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)? no
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.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Setting SCTP service.
Successfully set SCTP service.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/soft/openGauss/script/gs_checkos -i A -h omm02,omm03 --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.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.
[root@omm02 script]# su - omm
Last login: Wed Sep 22 16:48:52 CST 2021
[omm@omm02 ~]$ cd /soft/
[omm@omm02 soft]$ ll
total 8
-rw-------. 1 omm  dbgrp 1851 Sep 22 16:40 clusterconfig.xml
drwxr-xr-x. 5 root root  4096 Sep 22 16:47 openGauss
[omm@omm02 soft]$ cd openGauss/
[omm@omm02 openGauss]$ cd script/
-bash: cd: script/: Permission denied
[omm@omm02 openGauss]$ exit
logout

1.5主库正式安装:

[root@omm02 script]# chown -R omm:dbgrp /soft
[root@omm02 script]# su - omm
Last login: Wed Sep 22 16:49:05 CST 2021 on pts/0
[omm@omm02 ~]$ cd /soft/openGauss/script/
[omm@omm02 script]$ gs_install -X /soft/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:
[GAUSS-50322] : Failed to encrypt the password for databaseError:
 Invalid password,it must contain at least three kinds of characters
Try "gs_guc --help" for more information.
Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /gaussdb/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..

1.6主库安装完检查:

[omm@omm02 script]$ gs_om -t status --all
-----------------------------------------------------------------------

cluster_state             : Normal
redistributing            : No

-----------------------------------------------------------------------

node                      : 1
node_name                 : omm02
instance_id               : 6001
node_ip                   : 192.168.52.143
data_path                 : /gaussdb/data/db1
type                      : Datanode
instance_state            : Normal
az_name                   : AZ1
static_connections        : 1
HA_state                  : Normal
instance_role             : Primary

-----------------------------------------------------------------------

node                      : 2
node_name                 : omm03
instance_id               : 6002
node_ip                   : 192.168.52.144
data_path                 : /gaussdb/data/db1
type                      : Datanode
instance_state            : Normal
az_name                   : AZ1
instance_role             : Standby
HA_state                  : Streaming
sender_sent_location      : 0/4000140
sender_write_location     : 0/4000140
sender_flush_location     : 0/4000140
sender_replay_location    : 0/4000140
receiver_received_location: 0/4000140
receiver_write_location   : 0/4000140
receiver_flush_location   : 0/4000140
receiver_replay_location  : 0/4000140
sync_percent              : 100%
sync_state                : Async

-----------------------------------------------------------------------

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

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

node     node_ip         instance                  state            | node     node_ip         instance                  state
----------------------------------------------------------------------------------------------------------------------------------------------
1  omm02 192.168.52.143  6001 /gaussdb/data/db1 P Primary Normal | 2  omm03 192.168.52.144  6002 /gaussdb/data/db1 S Standby Normal

[omm@omm02 script]$ gsql -d postgres -p 26000
gsql ((openGauss 2.0.1 build d97c0e8a) compiled at 2021-06-02 19:37:17 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

postgres=# \l
                          List of databases
   Name    | Owner | Encoding  | Collate | Ctype | Access privileges 
-----------+-------+-----------+---------+-------+-------------------
 postgres  | omm   | SQL_ASCII | C       | C     | 
 template0 | omm   | SQL_ASCII | C       | C     | =c/omm           +
           |       |           |         |       | omm=CTc/omm
 template1 | omm   | SQL_ASCII | C       | C     | =c/omm           +
           |       |           |         |       | omm=CTc/omm
(3 rows)

postgres=# create database jyc;
CREATE DATABASE
postgres=# \c jyc
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "jyc" as user "omm".
jyc=# create table test(id int);
CREATE TABLE
jyc=# insert into test values(1);
INSERT 0 1
jyc=# select * from test;
 id 
----
  1
(1 row)

jyc=# \q
[omm@omm02 script]$ gs_ctl switchover
[2021-09-22 16:53:33.510][15535][][gs_ctl]:  no database directory specified and environment variable PGDATA unset
Try "gs_ctl --help" for more information.
[omm@omm02 script]$ echo $PGDATA

[omm@omm02 script]$ vi /home/omm/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
export PGDATA=/gaussdb/data/db1

[omm@omm02 script]$ source /home/omm/.bash_profile
[omm@omm02 script]$ cat /home/omm/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
export PGDATA=/gaussdb/data/db1
[omm@omm02 script]$ gs_ctl switchover
[2021-09-22 16:55:27.848][15546][][gs_ctl]: gs_ctl switchover ,datadir is /gaussdb/data/db1 
[2021-09-22 16:55:27.848][15546][][gs_ctl]: switchover term (1)
[2021-09-22 16:55:27.853][15546][][gs_ctl]: switchover completed (/gaussdb/data/db1)
[omm@omm02 script]$ gs_ctl query
[2021-09-22 16:55:33.484][15548][][gs_ctl]: gs_ctl query ,datadir is /gaussdb/data/db1 
 HA state:           
        local_role                     : Primary
        static_connections             : 1
        db_state                       : Normal
        detail_information             : Normal

 Senders info:       
        sender_pid                     : 14674
        local_role                     : Primary
        peer_role                      : Standby
        peer_state                     : Normal
        state                          : Streaming
        sender_sent_location           : 0/4002388
        sender_write_location          : 0/4002388
        sender_flush_location          : 0/4002388
        sender_replay_location         : 0/4002388
        receiver_received_location     : 0/4002388
        receiver_write_location        : 0/4002388
        receiver_flush_location        : 0/4002388
        receiver_replay_location       : 0/4002388
        sync_percent                   : 100%
        sync_state                     : Async
        sync_priority                  : 0
        sync_most_available            : Off
        channel                        : 192.168.52.143:26001-->192.168.52.144:54004

 Receiver info:      
No information 

1.7备库操作:

[root@omm03 ~]# su - omm
Last login: Wed Sep 22 16:48:53 CST 2021
[omm@omm03 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export PGDATA=/gaussdb/data/db1

".bash_profile" 14L, 226C written
[omm@omm03 ~]$ gs_ctl query
[2021-09-22 16:55:46.332][9211][][gs_ctl]:  no database directory specified and environment variable PGDATA unset
Try "gs_ctl --help" for more information.
[omm@omm03 ~]$ source /home/omm/.bash_profile
[omm@omm03 ~]$ gs_ctl query
[2021-09-22 16:56:04.310][9212][][gs_ctl]: gs_ctl query ,datadir is /gaussdb/data/db1 
 HA state:           
        local_role                     : Standby
        static_connections             : 1
        db_state                       : Normal
        detail_information             : Normal

 Senders info:       
No information 
 Receiver info:      
        receiver_pid                   : 9017
        local_role                     : Standby
        peer_role                      : Primary
        peer_state                     : Normal
        state                          : Normal
        sender_sent_location           : 0/40024A0
        sender_write_location          : 0/40024A0
        sender_flush_location          : 0/40024A0
        sender_replay_location         : 0/40024A0
        receiver_received_location     : 0/40024A0
        receiver_write_location        : 0/40024A0
        receiver_flush_location        : 0/40024A0
        receiver_replay_location       : 0/40024A0
        sync_percent                   : 100%
        channel                        : 192.168.52.144:54004<--192.168.52.143:26001

1.8备库做切换操作

[omm@omm03 ~]$ gs_ctl switchover
[2021-09-22 16:56:18.871][9217][][gs_ctl]: gs_ctl switchover ,datadir is /gaussdb/data/db1 
[2021-09-22 16:56:18.871][9217][][gs_ctl]: switchover term (1)
[2021-09-22 16:56:18.876][9217][][gs_ctl]: waiting for server to switchover............
[2021-09-22 16:56:27.927][9217][][gs_ctl]: done
[2021-09-22 16:56:27.927][9217][][gs_ctl]: switchover completed (/gaussdb/data/db1)
[omm@omm03 ~]$ gs_om -t status --detail
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

node     node_ip         instance                  state            | node     node_ip         instance                  state
----------------------------------------------------------------------------------------------------------------------------------------------
1  omm02 192.168.52.143  6001 /gaussdb/data/db1 P Standby Normal | 2  omm03 192.168.52.144  6002 /gaussdb/data/db1 S Primary Normal
[omm@omm03 ~]$ 
主库状态正常:
[omm@omm02 script]$ gs_om -t status --detail
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

node     node_ip         instance                  state            | node     node_ip         instance                  state
----------------------------------------------------------------------------------------------------------------------------------------------
1  omm02 192.168.52.143  6001 /gaussdb/data/db1 P Standby Normal | 2  omm03 192.168.52.144  6002 /gaussdb/data/db1 S Primary Normal

报错

[GAUSS-51400] : Failed to execute the command: rm -rf '/tmp/step_preinstall_file.dat'. Result:{'ogsc2': 'Failure', 'ogcs1': 'Success'}.
[GAUSS-51400] : Failed to execute the command: source /etc/profile && if [ -f ~/.bashrc ]; then source ~/.bashrc; fi. Result:{'192.168.1.167': 'Failure', '192.168.1.220': 'Success'}.


解决方案
把 StrictHostKeyChecking 关掉

vim /etc/ssh/ssh_config
Host *
 StrictHostKeyChecking no

报错

[GAUSS-51400] : Failed to execute the command: rm -rf '/tmp/step_preinstall_file.dat'. Result:{'omm03': 'Failure', 'omm02': 'Failure'}.
Error:
[FAILURE] omm02:
ssh: symbol lookup error: /lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b
[FAILURE] omm03:
ssh: symbol lookup error: /lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b

解决方案

(1)yum install openssl-devel
(2)yum install krb5-libs
(3)mv libcrypto.so.1.1 bak.libcrypto.so.1.1
(4)mv libcrypto.so bak.libcrypto.so

原文链接

https://www.modb.pro/db/112229

posted @ 2022-11-23 17:56  剑心空明  阅读(30)  评论(0编辑  收藏  举报  来源