-- root用户 【所有节点】
-- openGauss默认关闭使用transparent_hugepage服务,并将关闭命令写入操作系统启动文件
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
-- 查看是否关闭:
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
# root 用户 节点一主节点操作
-- 设置lib库
[root@opengauss-db1 ~]# export LD_LIBRARY_PATH=/opt/software/openGauss/script/gspylib/clib:$LD_LIBRARY_PATH
-- 执行预执行
[root@opengauss-db1 ~]# python3 /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 -- 输入yes
Please enter password for root
Password: -- 设置 root 口令
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)? yes -- 输入yes
Please enter password for cluster user.
Password: -- 设置 omm 用户口令
Please enter password for cluster user again.
Password: -- 重复输入 omm 用户口令
Generate cluster user password files successfully.
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.
Please enter password for current user[omm].
Password: -- 输入 omm 用户口令
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.
Distributing trust keys file to all node successfully.
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'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 opengauss-db1,opengauss-db2,opengauss-db3,opengauss-db4 --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 用户
[root@opengauss-db1 ~]# /opt/software/openGauss/script/gs_checkos -i A -h opengauss-db1,opengauss-db2,opengauss-db3,opengauss-db4 --detail
## 执行结果如下
Checking items:
A1. [ OS version status ] : Normal
[opengauss-db2]
centos_7.9.2009_64bit
[opengauss-db1]
centos_7.9.2009_64bit
[opengauss-db3]
centos_7.9.2009_64bit
[opengauss-db4]
centos_7.9.2009_64bit
A2. [ Kernel version status ] : Normal
The names about all kernel versions are same. The value is "3.10.0-693.el7.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 ] : Normal
The value about swap memory is correct.
A6. [ System control parameters status ] : Normal
All values about system control parameters are correct.
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
[opengauss-db1]
BondMode Null
Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192' -- 可忽略
[opengauss-db2]
BondMode Null
Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192' -- 可忽略
[opengauss-db3]
BondMode Null
Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192' -- 可忽略
[opengauss-db4]
BondMode Null
Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192' -- 可忽略
A12.[ Time consistency status ] : Warning
[opengauss-db2]
The NTPD not detected on machine and local time is "2022-11-14 17:08:56".
[opengauss-db1]
The NTPD not detected on machine and local time is "2022-11-14 17:08:56".
[opengauss-db3]
The NTPD not detected on machine and local time is "2022-11-14 17:08:56".
[opengauss-db4]
The NTPD not detected on machine and local time is "2022-11-14 17:08:56".
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:2.
-- 根据执行detail命令结果对预检查告警进行调整
-- 节点一切换到omm用户执行
[root@opengauss-db1 ~]# su - omm
-- 执行如下命令
[omm@opengauss-db1 ~]$ 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: -- 设置数据库 口令 如 Passw0rd@1234
Please repeat for database: -- 再次输入相同口令
begin to create CA cert files
The sslcert will be generated in /opt/gaussdb/install/app/share/sslcert/om
Create CA files for cm beginning.
Create CA files on directory [/opt/gaussdb/install/app_4e931f9a/share/sslcert/cm]. file list: ['client.key.rand', 'server.crt', 'cacert.pem', 'client.crt', 'server.key.rand', 'client.key', 'client.key.cipher', 'server.key', 'server.key.cipher']
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.
Starting cluster.
======================================================================
Successfully started primary instance. Wait for standby instance.
======================================================================
.
Successfully started cluster.
======================================================================
cluster_state : Normal
redistributing : No
node_count : 4
Datanode State
primary : 1
standby : 2
secondary : 0
cascade_standby : 1
building : 0
abnormal : 0
down : 0
Successfully installed application.
end deploy..
3.5.3 数据库状态检查
-- omm 用户
[omm@opengauss-db1 ~]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 1 /opt/gaussdb/install/data/cm/cm_server Primary
2 opengauss-db2 192.168.17.113 2 /opt/gaussdb/install/data/cm/cm_server Standby
3 opengauss-db3 192.168.17.139 3 /opt/gaussdb/install/data/cm/cm_server Standby
4 opengauss-db4 192.168.17.159 4 /opt/gaussdb/install/data/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 6001 /opt/gaussdb/install/data/db1 P Primary Normal
2 opengauss-db2 192.168.17.113 6002 /opt/gaussdb/install/data/db1 S Standby Normal
3 opengauss-db3 192.168.17.139 6003 /opt/gaussdb/install/data/db1 S Standby Normal
4 opengauss-db4 192.168.17.159 6004 /opt/gaussdb/install/data/db1 C Cascade Standby Normal
3.5.4 集群状态检查
-- omm 用户
[omm@opengauss-db1 ~]$ cm_ctl query -v -C -i -d
[ CMServer State ]
node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 1 /opt/gaussdb/install/data/cm/cm_server Primary
2 opengauss-db2 192.168.17.113 2 /opt/gaussdb/install/data/cm/cm_server Standby
3 opengauss-db3 192.168.17.139 3 /opt/gaussdb/install/data/cm/cm_server Standby
4 opengauss-db4 192.168.17.159 4 /opt/gaussdb/install/data/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 6001 /opt/gaussdb/install/data/db1 P Primary Normal
2 opengauss-db2 192.168.17.113 6002 /opt/gaussdb/install/data/db1 S Standby Normal
3 opengauss-db3 192.168.17.139 6003 /opt/gaussdb/install/data/db1 S Standby Normal
4 opengauss-db4 192.168.17.159 6004 /opt/gaussdb/install/data/db1 C Cascade Standby Normal
3.6 查询级联备库日志接收状态
-- omm 用户 级联备库操作
[root@opengauss-db4 ~]# su - omm
Last login: Mon Nov 14 17:05:30 CST 2022
[omm@opengauss-db4 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# \x
Expanded display is on.
openGauss=# select * from pg_stat_get_wal_receiver();
四、集群缩容
4.1 查询集群状态
-- omm 用户
[omm@opengauss-db1 ~]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 1 /opt/gaussdb/install/data/cm/cm_server Primary
2 opengauss-db2 192.168.17.113 2 /opt/gaussdb/install/data/cm/cm_server Standby
3 opengauss-db3 192.168.17.139 3 /opt/gaussdb/install/data/cm/cm_server Standby
4 opengauss-db4 192.168.17.159 4 /opt/gaussdb/install/data/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 6001 /opt/gaussdb/install/data/db1 P Primary Normal
2 opengauss-db2 192.168.17.113 6002 /opt/gaussdb/install/data/db1 S Standby Normal
3 opengauss-db3 192.168.17.139 6003 /opt/gaussdb/install/data/db1 S Standby Normal
4 opengauss-db4 192.168.17.159 6004 /opt/gaussdb/install/data/db1 C Cascade Standby Normal
4.2 缩容节点
-- omm 用户 主节点操作
[omm@opengauss-db1 ~]$ gs_dropnode -U omm -G dbgrp -h 192.168.17.159
-- 执行结果如下
The target node to be dropped is (['opengauss-db4'])
Do you want to continue to drop the target node (yes/no)?yes -- 输入 yes
Drop node start with CM node.
Drop node with CM node is running.
[gs_dropnode]Start to drop nodes of the cluster.
[gs_dropnode]Start to stop the target node opengauss-db4.
[gs_dropnode]End of stop the target node opengauss-db4.
[gs_dropnode]Start to backup parameter config file on opengauss-db1.
[gs_dropnode]End to backup parameter config file on opengauss-db1.
[gs_dropnode]The backup file of opengauss-db1 is /opt/gaussdb/tmp/gs_dropnode_backup20221114182028/parameter_opengauss-db1.tar
[gs_dropnode]Start to parse parameter config file on opengauss-db1.
[gs_dropnode]End to parse parameter config file on opengauss-db1.
[gs_dropnode]Start to parse backup parameter config file on opengauss-db1.
[gs_dropnode]End to parse backup parameter config file opengauss-db1.
[gs_dropnode]Start to set openGauss config file on opengauss-db1.
[gs_dropnode]End of set openGauss config file on opengauss-db1.
[gs_dropnode]Start to backup parameter config file on opengauss-db2.
[gs_dropnode]End to backup parameter config file on opengauss-db2.
[gs_dropnode]The backup file of opengauss-db2 is /opt/gaussdb/tmp/gs_dropnode_backup20221114182030/parameter_opengauss-db2.tar
[gs_dropnode]Start to parse parameter config file on opengauss-db2.
[gs_dropnode]End to parse parameter config file on opengauss-db2.
[gs_dropnode]Start to parse backup parameter config file on opengauss-db2.
[gs_dropnode]End to parse backup parameter config file opengauss-db2.
[gs_dropnode]Start to set openGauss config file on opengauss-db2.
[gs_dropnode]End of set openGauss config file on opengauss-db2.
[gs_dropnode]Start to backup parameter config file on opengauss-db3.
[gs_dropnode]End to backup parameter config file on opengauss-db3.
[gs_dropnode]The backup file of opengauss-db3 is /opt/gaussdb/tmp/gs_dropnode_backup20221114182036/parameter_opengauss-db3.tar
[gs_dropnode]Start to parse parameter config file on opengauss-db3.
[gs_dropnode]End to parse parameter config file on opengauss-db3.
[gs_dropnode]Start to parse backup parameter config file on opengauss-db3.
[gs_dropnode]End to parse backup parameter config file opengauss-db3.
[gs_dropnode]Start to set openGauss config file on opengauss-db3.
[gs_dropnode]End of set openGauss config file on opengauss-db3.
[gs_dropnode]Start of set pg_hba config file on opengauss-db1.
[gs_dropnode]End of set pg_hba config file on opengauss-db1.
[gs_dropnode]Start of set pg_hba config file on opengauss-db2.
[gs_dropnode]End of set pg_hba config file on opengauss-db2.
[gs_dropnode]Start of set pg_hba config file on opengauss-db3.
[gs_dropnode]End of set pg_hba config file on opengauss-db3.
[gs_dropnode]Start to set repl slot on opengauss-db1.
[gs_dropnode]Start to get repl slot on opengauss-db1.
[gs_dropnode]End of set repl slot on opengauss-db1.
Stopping node.
=========================================
Successfully stopped node.
=========================================
End stop node.
Generate drop flag file on drop node opengauss-db4 successfully.
[gs_dropnode]Start to modify the cluster static conf.
[gs_dropnode]End of modify the cluster static conf.
Restart cluster ...
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
Remove dynamic_config_file and CM metadata directory on all nodes.
Starting cluster.
======================================================================
Successfully started primary instance. Wait for standby instance.
======================================================================
.
Successfully started cluster.
======================================================================
cluster_state : Normal
redistributing : No
node_count : 3
Datanode State
primary : 1
standby : 2
secondary : 0
cascade_standby : 0
building : 0
abnormal : 0
down : 0
Failed to reset switchover the cluster. Command: "source /home/omm/.bashrc ; cm_ctl switchover -a -t 0".
Output: "cm_ctl: create ssl connection failed.
cm_ctl: socket is [4], 462 : create ssl failed:
cm_ctl: send switchover msg to cm_server, connect fail node_id:0, data_path:.".
[gs_dropnode] Success to drop the target nodes.
4.3 再次查询集群状态
-- omm 用户
[omm@opengauss-db1 ~]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 1 /opt/gaussdb/install/data/cm/cm_server Primary
2 opengauss-db2 192.168.17.113 2 /opt/gaussdb/install/data/cm/cm_server Standby
3 opengauss-db3 192.168.17.139 3 /opt/gaussdb/install/data/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-------------------------------------------------------------------------------------
1 opengauss-db1 192.168.17.112 6001 /opt/gaussdb/install/data/db1 P Primary Normal
2 opengauss-db2 192.168.17.113 6002 /opt/gaussdb/install/data/db1 S Standby Normal
3 opengauss-db3 192.168.17.139 6003 /opt/gaussdb/install/data/db1 S Standby Normal
4.4 删除SSH互信
-- omm 用户,被缩容节点操作
[root@opengauss-db4 ~]# mv .ssh .ssh_back
[root@opengauss-db4 ~]# su - omm
Last login: Mon Nov 14 17:33:17 CST 2022 on pts/0
[omm@opengauss-db4 ~]$ mv .ssh .ssh_back
4.5 清理备库数据
-- omm 用户 在被清理备库服务器操作
[root@opengauss-db4 ~]# su - omm
Last login: Mon Nov 14 18:28:56 CST 2022 on pts/3
[omm@opengauss-db4 ~]$ gs_uninstall --delete-data -L
This is a node where the gs_dropnode command has been executed. Uninstall a single node instead of the gs_dropnode command.
Checking uninstallation.
Successfully checked uninstallation.
Stopping the cluster.
Successfully stopped local node.
Successfully deleted instances.
Uninstalling application.
Successfully uninstalled application.
Uninstallation succeeded.
4.6 清理备库软件
-- 拷贝主库 /opt/software/openGauss/script 目录至被清理备库
[root@opengauss-db1 ~]# cd /opt/software/openGauss/script/
[root@opengauss-db1 script]# scp * root@opengauss-db4:/opt/software/openGauss/script/
-- root 用户 在被清理备库操作执行清理备库软件及目录
[root@opengauss-db4 ~]# cd /opt/software/openGauss/script/
[root@opengauss-db4 script]# ./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group -L
Parsing the configuration file.
Successfully parsed the configuration file.
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 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.