openEuler-22.03-LTS安装、卸载OpenGuasss 5.0.1 主备库

操作系统 openeuler 22.0.3 tls,系统自带python3.9

系统版本

[root@openeuler161 script]# cat /etc/openEuler-latest 
openeulerversion=openEuler-22.03-LTS
compiletime=2022-03-30-16-23-56
gccversion=10.3.1-10.oe2203
kernelversion=5.10.0-60.18.0.50.oe2203
openjdkversion=1.8.0.312.b07-11.oe2203

依赖包安装

yum -y install lksctp*
yum -y install psmisc
yum -y install bzip2
yum -y install unzip
yum -y install gcc
yum -y install gcc-c++
yum -y install perl
yum -y install libxml2-devel
yum -y install libaio-devel
yum -y install flex
yum -y install bison
yum -y install ncurses-devel
yum -y install glibc-devel
yum -y install patch
yum -y install readline-devel
yum -y install redhat-lsb-core
yum -y install openssh
yum -y install expect
yum -y install tcl

安装缺失python包

如果没有话,运行scripts中脚本会无限死循环 添加链接描述

pip3 install paramiko==3.4.0

[root@openeuler161 script]# pip3 list 
Package             Version
------------------- -------
bcrypt              4.1.3
cffi                1.16.0
configobj           5.0.6
cryptography        42.0.7
decorator           5.0.9
distro              1.6.0
gpg                 1.16.0
libcomps            0.1.18
nftables            0.1
paramiko            3.4.0
perf                0.1
pip                 21.3.1
pycairo             1.20.0
pycparser           2.22
PyGObject           3.42.0
PyNaCl              1.5.0
pyparsing           3.0.6
python-dateutil     2.8.2
python-linux-procfs 0.6.3
pyudev              0.22.0
rpm                 4.17.0
schedutils          0.6
setuptools          59.4.0
six                 1.16.0
SSSDConfig          2.6.1

下载包放在 opt/software/openGauss目录下并解压openGauss-5.0.1-openEuler-64bit-cm.tar.gz

-rwxr-xr-x  1 omm dbgrp  108 May 12 05:47 openGauss-5.0.1-openEuler-64bit-cm.sha256
-rwxr-xr-x  1 omm dbgrp  22M May 12 05:47 openGauss-5.0.1-openEuler-64bit-cm.tar.gz
-rwxrwxr-x  1 omm dbgrp   65 May 12 05:47 openGauss-5.0.1-openEuler-64bit-om.sha256
-rwxrwxr-x  1 omm dbgrp  11M May 12 05:47 openGauss-5.0.1-openEuler-64bit-om.tar.gz
-rwxrwxr-x  1 omm dbgrp   65 May 12 05:47 openGauss-5.0.1-openEuler-64bit.sha256
-rwxrwxr-x  1 omm dbgrp  97M May 12 05:47 openGauss-5.0.1-openEuler-64bit.tar.bz2
-rw-------  1 omm dbgrp 135M May 12 07:37 openGauss-Package-bak_33b035fd.tar.gz
tar -xvf  openGauss-5.0.1-openEuler-64bit-cm.tar.gz

创建集群xml文件

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

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

运行gs_preinstall 预安装环境配置

[root@openeuler161 script]# ./gs_preinstall -U omm -G dbgrp -X ../cluster_ms.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: 
Successfully created SSH trust for the root permission user.
Setting host ip env
Successfully set host ip env.
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.
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 openeuler161,openeuler162 --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.
[root@openeuler161 script]# 

[root@openeuler162 openGauss]# ll /data
total 24K
drwx------ 10 omm dbgrp 4.0K May 12 08:14 app_33b035fd
drwxr-x---  2 omm dbgrp 4.0K May 12 07:52 corefile
drwx------ 20 omm dbgrp 4.0K May 12 08:15 data
drwx------  5 omm dbgrp 4.0K May 12 07:53 om
drwxr-x---  3 omm dbgrp 4.0K May 12 07:52 omm
drwx------  3 omm dbgrp 4.0K May 12 08:13 tmp

gs_preinstall 做了哪些工作?

1、配置环境linux (列如:/etc/sysctl.ctl, /etc/security/limit.conf 等)

2、创建默认用户、组的创建(omm.dbgrp)

3、创建xml文件指定的路径

4、创建互信 (提前创建了可以不用创建)

环境检查

[root@openeuler161 script]# /opt/software/openGauss/script/gs_checkos -i A -h openeuler161,openeuler162 --detail
Checking items:
    A1. [ OS version status ]                                   : Normal     
        [openeuler161]
        openEuler_22.03_64bit
        [openeuler162]
        openEuler_22.03_64bit

    A2. [ Kernel version status ]                               : Normal     
        The names about all kernel versions are same. The value is "5.10.0-60.18.0.50.oe2203.x86_64".
    A3. [ Unicode status ]                                      : Normal     
        The values of all unicode are same. The value is "LANG=en_US.UTF-8".
    A4. [ Time zone status ]                                    : Normal     
        The informations about all timezones are same. The value is "+0800".
    A5. [ Swap memory status ]                                  : Warning    
        [openeuler161]
SwapMemory 4152356864 TotalMemory 3478061056

        [openeuler162]
SwapMemory 4152356864 TotalMemory 3478061056


    A6. [ System control parameters status ]                    : Warning    
        [openeuler161]
        Warning reason: variable 'net.ipv4.tcp_retries1' RealValue '3' ExpectedValue '5'.
        Warning reason: variable 'net.ipv4.tcp_syn_retries' RealValue '6' ExpectedValue '5'.
        Check_SysCtl_Parameter warning.

        [openeuler162]
        Warning reason: variable 'net.ipv4.tcp_retries1' RealValue '3' ExpectedValue '5'.
        Warning reason: variable 'net.ipv4.tcp_syn_retries' RealValue '6' ExpectedValue '5'.
        Check_SysCtl_Parameter warning.


    A7. [ File system configuration status ]                    : Normal     
        Both soft nofile and hard nofile are correct.      
    A8. [ Disk configuration status ]                           : Normal     
        The value about XFS mount parameters is correct.   
    A9. [ Pre-read block size status ]                          : Normal     
        The value about Logical block size is correct.     
    A10.[ IO scheduler status ]                                 : Normal     
        The value of IO scheduler is correct.              
    A11.[ Network card configuration status ]                   : Warning    
        [openeuler161]
BondMode Null
        Warning reason: network 'enp0s8' 'mtu' RealValue '1500' ExpectedValue '8192'

        [openeuler162]
BondMode Null
        Warning reason: network 'enp0s8' 'mtu' RealValue '1500' ExpectedValue '8192'


    A12.[ Time consistency status ]                             : Warning    
        [openeuler161]
        The NTPD not detected on machine and local time is "2024-05-12 08:07:07".
        [openeuler162]
        The NTPD not detected on machine and local time is "2024-05-12 08:07:05".

    A13.[ Firewall service status ]                             : Normal     
        The firewall service is stopped.                   
    A14.[ THP service status ]                                  : Normal     
        The THP service is stopped.                        
Total numbers:14. Abnormal numbers:0. Warning numbers:4.
[root@openeuler161 script]# 

没有abnormal

执行安装

登录openguass主机,确保文件路径的权限,并切换omm用户

chmod 775 -R /opt/software/
su - omm
[omm@openeuler161 ~]$ cd /opt/software/openGauss/script/

[omm@openeuler161 script]$ ./gs_install -X /opt/software/openGauss/cluster_ms.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 /data/app/share/sslcert/om
NO cm_server instance, no need to create CA for CM.
Non-dss_ssl_enable, no need to create CA for DSS
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.
The cluster status is Normal.
Successfully started cluster.
Successfully installed application.
end deploy..
[omm@openeuler161 script]$ 

安装验证

检查库状态

[omm@openeuler162 ~]$ gs_om -t view
NodeHeader:
version:301
time:1715472858
nodeCount:2
node:2
============================================================
azName:AZ1
azPriority:1
node :1
nodeName:openeuler161
ssh channel :
sshChannel 1:192.168.99.161
datanodeCount :1
datanodeInstanceType :primary
datanode 1:
datanodeLocalDataPath :/data/data
datanodeXlogPath :
datanodeListenIP 1:192.168.99.161
datanodePort :15400
datanodeLocalHAIP 1:192.168.99.161
datanodeLocalHAPort :15401
dn_replication_num: 2
datanodePeer0DataPath :/data/data
datanodePeer0HAIP 1:192.168.99.162
datanodePeer0HAPort :15401
============================================================
azName:AZ1
azPriority:1
node :2
nodeName:openeuler162
ssh channel :
sshChannel 1:192.168.99.162
datanodeCount :1
datanodeInstanceType :standby
datanode 1:
datanodeLocalDataPath :/data/data
datanodeXlogPath :
datanodeListenIP 1:192.168.99.162
datanodePort :15400
datanodeLocalHAIP 1:192.168.99.162
datanodeLocalHAPort :15401
dn_replication_num: 2
datanodePeer0DataPath :/data/data
datanodePeer0HAIP 1:192.168.99.161
datanodePeer0HAPort :15401



[omm@openeuler161 script]$ gs_om -t query
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node        node_ip         port      instance     state
----------------------------------------------------------------------------
1  openeuler161 192.168.99.161  15400      6001       P Primary Normal
2  openeuler162 192.168.99.162  15400      6002       S Standby Normal

登录库并创建数据库mydb

[omm@openeuler161 script]$ gsql -U omm postgres -p 15400
gsql ((openGauss 5.0.1 build 33b035fd) compiled at 2023-12-15 19:51:49 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
CREATE DATABASE
openGauss=# \l
                          List of databases
   Name    | Owner | Encoding  | Collate | Ctype | Access privileges 
-----------+-------+-----------+---------+-------+-------------------
 mydb      | omm   | GBK       | C       | C     | 
 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
(4 rows)

检查备库

[omm@openeuler162 ~]$ gsql -U omm postgres -p 15400
gsql ((openGauss 5.0.1 build 33b035fd) compiled at 2023-12-15 19:51:49 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
ERROR:  syntax error at or near "openGauss"
LINE 1: openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' templat...
        ^
openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0; 
ERROR:  cannot execute CREATE DATABASE in a read-only transaction
openGauss=# \l
                          List of databases
   Name    | Owner | Encoding  | Collate | Ctype | Access privileges 
-----------+-------+-----------+---------+-------+-------------------
 mydb      | omm   | GBK       | C       | C     | 
 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
(4 rows)

卸载openGauss

执行卸载

操作步骤

以操作系统用户omm登录数据库主节点。

使用gs_uninstall卸载openGauss。

gs_uninstall --delete-data

或者在openGauss中每个节点执行本地卸载。

gs_uninstall --delete-data -L

[omm@openeuler161 ~]$ gs_uninstall --delete-data
Checking uninstallation.
Successfully checked uninstallation.
Stopping the cluster.
Successfully stopped the cluster.
Successfully deleted instances.
Uninstalling application.
Successfully uninstalled application.
Uninstallation succeeded.
[omm@openeuler161 ~]$ gs_om -t status
[GAUSS-50300] : User installation path of designated user omm does not exist. Maybe the user is not right.
[omm@openeuler161 ~]$ ls -l /data/data/
total 0
[omm@openeuler161 ~]$ ls -l /data/app_33b035fd/
total 0
[omm@openeuler161 ~]$ 

一键式环境清理--清理环境

在openGauss卸载完成后,如果不需要在环境上重新部署openGauss,可以运行脚本gs_postuninstall对openGauss服务器上环境信息做清理。openGauss环境清理是对环境准备脚本gs_preinstall所做设置的清理。

前提条件

openGauss卸载执行成功。
root用户互信可用。
只能使用root用户执行gs_postuninstall命

操作检查互信

[root@openeuler161 .ssh]# vi known_hosts 
[root@openeuler161 .ssh]# ssh openeuler161 date
Sun May 12 09:11:45 AM CST 2024
[root@openeuler161 .ssh]# ssh openeuler162 date
Sun May 12 09:11:45 AM CST 2024
[root@openeuler161 .ssh]# ssh openeuler162

Authorized users only. All activities may be monitored and reported.
Last login: Sun May 12 09:08:00 2024 from 192.168.99.162


Welcome to 5.10.0-60.18.0.50.oe2203.x86_64

System information as of time: 	Sun May 12 09:11:56 AM CST 2024

System load: 	0.00
Processes: 	115
Memory used: 	14.8%
Swap used: 	.1%
Usage On: 	12%
IP address: 	192.168.66.162
IP address: 	192.168.99.162
Users online: 	3


[root@openeuler162 ~]# ssh openeuler161 date
Sun May 12 09:12:06 AM CST 2024
[root@openeuler162 ~]# ssh openeuler162 date
Sun May 12 09:12:07 AM CST 2024

使用gs_postuninstall进行清理

[root@openeuler161 script]# pwd
/opt/software/openGauss/script
[root@openeuler161 script]# ./gs_postuninstall -U omm -X /opt/software/openGauss/cluster_ms.xml  --delete-user --delete-group
Parsing the configuration file.
Successfully parsed the configuration file.
Creating SSH trust for the root permission user.
Are you sure you want to create trust for root (yes/no)?no
Check log file path.
Successfully checked log file path.
Checking unpreinstallation.
Successfully checked unpreinstallation.
Deleting the instance's directory.
Successfully deleted the instance's directory.
Deleting the temporary directory.
Successfully deleted the temporary directory.
Deleting remote OS user.
Successfully deleted remote OS user.
Deleting software packages and environmental variables of other nodes.
Successfully deleted software packages and environmental variables of other nodes.
Deleting logs of other nodes.
Successfully deleted logs of other nodes.
Deleting software packages and environmental variables of the local node.
Successfully deleted software packages and environmental variables of the local nodes.
Deleting local OS user.
Successfully deleted local OS user.
Deleting local node's logs.
Successfully deleted local node's logs.
Successfully cleaned environment.
[root@openeuler161 script]# id omm
id: 'omm': no such user
相关推荐
零炻大礼包1 小时前
【SQL server】数据库远程连接配置
数据库
zmgst1 小时前
canal1.1.7使用canal-adapter进行mysql同步数据
java·数据库·mysql
随心............1 小时前
python操作MySQL以及SQL综合案例
数据库·mysql
€☞扫地僧☜€1 小时前
docker 拉取MySQL8.0镜像以及安装
运维·数据库·docker·容器
CopyDragon1 小时前
设置域名跨越访问
数据库·sqlite
xjjeffery1 小时前
MySQL 基础
数据库·mysql
写bug的小屁孩1 小时前
前后端交互接口(三)
运维·服务器·数据库·windows·用户界面·qt6.3
恒辉信达1 小时前
hhdb数据库介绍(8-4)
服务器·数据库·mysql
齐 飞2 小时前
MongoDB笔记01-概念与安装
前端·数据库·笔记·后端·mongodb
云空2 小时前
《Python 与 SQLite:强大的数据库组合》
数据库·python·sqlite