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

文章目录

  • OpenGauss一主一从搭建(全网最详细,最简单)
    • 1.开始搭建:
      • 1.1主机脚本
      • 1.2从机脚本
      • 1.3主库上准备集群参数文件clusterconfig.xml (路径在 /soft 下 需要修改ip)
      • 1.4主库预安装:注意目录权限即可 chown -R omm:dbgrp /gaussdb
      • 1.5主库正式安装:
      • 1.6主库安装完检查:
      • 1.7备库操作:
      • 1.8备库做切换操作

搭建步骤:

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; thenecho never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; thenecho 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; thenecho never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; thenecho 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=# \lList of databasesName    | Owner | Encoding  | Collate | Ctype | Access privileges
-----------+-------+-----------+---------+-------+-------------------postgres  | omm   | SQL_ASCII | C       | C     | template0 | omm   | SQL_ASCII | C       | C     | =c/omm           +|       |           |         |       | omm=CTc/ommtemplate1 | 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 programsPATH=$PATH:$HOME/.local/bin:$HOME/binexport 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 programsPATH=$PATH:$HOME/.local/bin:$HOME/binexport 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                     : Primarystatic_connections             : 1db_state                       : Normaldetail_information             : NormalSenders info:       sender_pid                     : 14674local_role                     : Primarypeer_role                      : Standbypeer_state                     : Normalstate                          : Streamingsender_sent_location           : 0/4002388sender_write_location          : 0/4002388sender_flush_location          : 0/4002388sender_replay_location         : 0/4002388receiver_received_location     : 0/4002388receiver_write_location        : 0/4002388receiver_flush_location        : 0/4002388receiver_replay_location       : 0/4002388sync_percent                   : 100%sync_state                     : Asyncsync_priority                  : 0sync_most_available            : Offchannel                        : 192.168.52.143:26001-->192.168.52.144:54004Receiver 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 programsPATH=$PATH:$HOME/.local/bin:$HOME/binexport PATHexport 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                     : Standbystatic_connections             : 1db_state                       : Normaldetail_information             : NormalSenders info:
No information Receiver info:      receiver_pid                   : 9017local_role                     : Standbypeer_role                      : Primarypeer_state                     : Normalstate                          : Normalsender_sent_location           : 0/40024A0sender_write_location          : 0/40024A0sender_flush_location          : 0/40024A0sender_replay_location         : 0/40024A0receiver_received_location     : 0/40024A0receiver_write_location        : 0/40024A0receiver_flush_location        : 0/40024A0receiver_replay_location       : 0/40024A0sync_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

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

  1. Office Online Server搭建(全网最详细)

    前言 最近换新公司了,一直挺忙的,好久没正儿八经的吹牛逼了!新公司技术部门有定期学习计划,和技术储备计划,这不来了个在线预览文档的活么,作为公司技术储备,需求产生的背景:公司Word.Excel.PD ...

  2. 【BIM模型生成点云数据】revit转obj格式,全网最详细最简单的步骤了!

    最近,学习到了一种新方法,用于制作点云数据集,那就是----用BIM三维模型转obj格式之后导入到cloudcompare生成点云数据.该方式适合做仿真实验,也可以用于三维建模的精度对比. 关键性问题 ...

  3. 【四】gym搭建自己的环境,全网最详细版本,3分钟你就学会了!

    相关文章: [一]gym环境安装以及安装遇到的错误解决 [二]gym初次入门一学就会-简明教程 [三]gym简单画图 [四]gym搭建自己的环境,全网最详细版本,3分钟你就学会了! [五]gym搭建自 ...

  4. Hadoop全分布式集群搭建(全网最详细,保姆级教程)

    在上一篇Hadoop环境搭建(全网最详细,保姆级教程)中已经搭建好了一个单机Hadoop环境,接下来搭建全分布式Hadoop集群 首先对Hadoop全分布示集群进行简单介绍和规划 一个集群由一个主机, ...

  5. 全网最详细的大数据集群环境下如何正确安装并配置多个不同版本的Cloudera Hue(图文详解)...

    不多说,直接上干货! 为什么要写这么一篇博文呢? 是因为啊,对于Hue不同版本之间,其实,差异还是相对来说有点大的,具体,大家在使用的时候亲身体会就知道了,比如一些提示和界面. 全网最详细的大数据集群 ...

  6. 快速成为idc服务商----全网最详细教程----1

    本次要讲述的就如题目表述,成为idc服务商教程,而且是速成!成本肯定是有的,但是肯定低于收益! 如果您对idc不了解,我在这里给您简单介绍下: idc服务商 是什么?您知道服务器吗?如果您连服务器都不 ...

  7. “是男人就下一百层”h5游戏全网最详细教学、全代码,js操作

    "是男人就下一百层"h5游戏全网最详细教学.全代码,js操作 博主的话 游戏展示 编程工具介绍 游戏代码 代码讲解 js 第一步 切换div的显示与隐藏 js 第二步 在菜单页面用 ...

  8. 全网最详细的Windows里Anaconda-Navigator启动后闪退的解决方案(图文详解)

    全网最详细的Windows里Anaconda-Navigator启动后闪退的解决方案(图文详解) 参考文章: (1)全网最详细的Windows里Anaconda-Navigator启动后闪退的解决方案 ...

  9. WindowsServer2012 R2 64位中文标准版(IIS8.5)下手动搭建PHP环境详细图文教程(二)安装IIS8.5...

    //来源:http://www.imaoye.com/Technology/WindowsServer2012R264IIS85.html 阿里云服务器ECS Windows Server 2012 ...

最新文章

  1. 「图文直播」CSDN 二十年,AI 赋能全新出发
  2. 一直在构建版本_球鞋 | 一鞋两穿?AJ1十孔版本登场,拉链设计还是真香了?
  3. 力扣(LeetCode)78
  4. python把数据写入excel_Python读写sqlite3数据库的方法并且将数据写入Excel的实例详解...
  5. 两节点的最小公共祖先LCA
  6. java.library.path属性在代码中设置不生效问题
  7. oracle服务端安装和下载,oracle 11g 服务端下载地址及安装说明
  8. 第二轮冲次会议第三次
  9. 贪吃蛇大战 java小游戏百度云源码
  10. ansible 建 kubernetes 证书签名请求_Java中的微信支付(2):API V3 微信平台证书的获取与刷新...
  11. win7睡眠,休眠的区别
  12. 结构梁配筋最牛插件_牛肉食用指南(五):日式烧肉的由来,各部位怎么烤最好吃?...
  13. win7/win10 密码忘了?没关系,利用5次shift,9步轻松破解密码
  14. mysql电商数据库结构_高性能可扩展MySQL数据库设计及架构优化——电商实例数据库结构...
  15. 【收藏防丢】rar压缩包忘记密码怎么办?手把手教你轻松解决
  16. opencv边缘检测加提取(圆形和矩形)
  17. ICMPv6与NDP
  18. oracle数据库常用操作
  19. css3的@media
  20. C:警告:warning: unknown escape sequence: ‘.‘

热门文章

  1. 企业邮箱如何申请?如何用手机号注册邮箱?
  2. 亚马逊、eBay、敦煌、wish、Lazada、阿里国际卖家有一套自养号测评技术多重要
  3. html练习--写信
  4. 云顶之弈机器人法爆_云顶之弈AP机器人打法,一爪2466伤害,六贵族双凯尔也顶不住!...
  5. 实用网站/好网站/冷门网站
  6. JAVA面向对象程序设计-FeiGe快递系统-封装
  7. Linux 命令 常用总结(一)
  8. 【观察】亚马逊云科技发布中国战略背后,是“在中国”到“懂中国”的蜕变...
  9. 栈和队列——构造数组的MaxTree(java实现)
  10. Python :销售提成