open Gauss 数据库-03 openGauss数据库维护管理指导手册

发文章是为了证明自己真的掌握了一个知识,同时给他人带来帮助,如有问题,欢迎指正,祝大家万事胜意!

目录

前言

openGauss数据库维护管理

1 操作系统参数检查

1.1 实验介绍

1.2 场景设置及操作步骤

2 openGauss 运行健康状态检查

2.1 实验介绍

2.2 场景设置及操作步骤

3 数据库性能检查

3.1 实验介绍

3.2 通过 gs_checkperf 工具来检查数据库性能

3.3 通过 EXPLAIN 进行 SQL 语句优化

4 日志检查

4.1 实验介绍

4.2 通过 gs_collector 工具来收集日志信息

5 最大连接数设置

5.1 实验介绍

5.2 场景设置及操作步骤

6 例行表、索引的维护

6.1 实验介绍

6.2 场景设置及操作步骤

前言

本实验主要内容为操作系统参数检查、 openGauss 健康状态检查、数据库性能检查、日志检查
和清理、时间一致性检查、应用连接数检查、例行维护表等
我的环境:
设备名称 设备型号 软件版本
虚拟机 VMware VMware-workstation-full-17.5.1
操作系统 openEuler    openEuler 22.3LTS
数据库 openGauss   openGauss 5.0.0

 需要的工具,大家不用现在下,后面用到了再下也可以,如果需要相关文件,可以评论,其实大多数都是可以去官网下的哈,因为我只能通过网盘给大家,文件又有点大,网盘的速度大家都是清楚的哈哈,所以还是推荐大家去官网,如果实在找不到可以找我

openGauss数据库维护管理

1 操作系统参数检查

1.1 实验介绍

gs_checkos 工具用来帮助检查操作系统、控制参数、磁盘配置等内容,并对系统控制参数、 I/O
配置、网络配置和 THP 服务等信息进行配置。
本实验主要是通过 gs_checkos 工具来检查操作系统参数设置是否合理。先进行场景设置,然后
根据检查结果进行参数调整。

1.2 场景设置及操作步骤

 步骤 1 ROOT 用户登录装有 openGauss 数据库服务的操作系统,登录后信息如下:

Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64

System information as of time: 	2024年 03月 25日 星期一 19:09:30 CST

System load: 	0.02
Processes: 	195
Memory used: 	39.3%
Swap used: 	13.3%
Usage On: 	25%
IP address: 	192.168.28.131
Users online: 	1

 步骤 2 ROOT 用户下执行 gs_checkos 先对系统参数进行检查。

[root@node0 ~]# gs_checkos -i A
Checking items:
    A1. [ OS version status ]                                   : Normal
    A2. [ Kernel version status ]                               : Normal
    A3. [ Unicode status ]                                      : Normal
    A4. [ Time zone status ]                                    : Normal
    A5. [ Swap memory status ]                                  : Warning
    A6. [ System control parameters status ]                    : Warning
    A7. [ File system configuration status ]                    : Normal
    A8. [ Disk configuration status ]                           : Normal
    A9. [ Pre-read block size status ]                          : Normal
BondMode Null
    A11.[ Network card configuration status ]                   : Normal
    A12.[ Time consistency status ]                             : Warning
    A13.[ Firewall service status ]                             : Normal
    A14.[ THP service status ]                                  : Normal
Total numbers:13. Abnormal numbers:0. Warning numbers:3.

2 openGauss 运行健康状态检查

2.1 实验介绍

gs_check 能够帮助用户在 openGauss 运行过程中,全量的检查 openGauss 运行环境,操作系
统环境,网络环境及数据库执行环境,也有助于在 openGauss 重大操作之前对各类环境进行全
面检查,有效保证操作执行成功。
本实验主要是通过 gs_check 工具来检查 openGauss 数据库运行状态。先进行场景设置,然后
根据检查结果进行数据库调整。

2.2 场景设置及操作步骤

步骤 1 ROOT 用户登录装有 openGauss 数据库服务的操作系统然后用 su – omm 命令切换至
OMM 用户环境,登录后信息如下。
[root@node0 ~]# su - omm
Last login: Mon Mar 25 18:47:31 CST 2024 on pts/0


Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64

System information as of time: 	2024年 03月 25日 星期一 19:31:35 CST

System load: 	0.30
Processes: 	195
Memory used: 	39.0%
Swap used: 	14.3%
Usage On: 	25%
IP address: 	192.168.28.131
Users online: 	1
To run a command as administrator(user "root"),use "sudo <command>".
步骤 2 确认 openGauss 数据库服务是否启动。

[omm@node0 ~]$ gs_om -t status
-----------------------------------------------------------------------

cluster_name    : dbCluster
cluster_state   : Normal
redistributing  : No

-----------------------------------------------------------------------
cluster_state : Normal 表示已启动,可以正常使用。如果状态为非 Normal 表示不可用
为了实验场景设置,如果数据库服务已经启动,请执行步骤 3 先关闭服务。
步骤 3 关闭 openGauss 数据库服务。
[omm@node0 ~]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
步骤 4 检查 openGauss 实例连接。
[omm@node0 ~]$ gs_check -i CheckDBConnection -L

2024-03-25 19:37:53 [NAM] CheckDBConnection
2024-03-25 19:37:53 [STD] 检查能否连接数据库,如果连接成功则检查项通过,否则检查项不通过
2024-03-25 19:37:53 [RST] NG
The database can not be connected.
2024-03-25 19:37:53 [RAW]
说明:
CheckDBConnection...........................NG 表示连接检查项无用;
The database can not be connected. 表示实例不能连接;
Failed. All check items run completed. Total:1 NG:1 表示共检查 1 项并且检查结果未通过。

步骤 5 启动 openGauss 数据库服务。

[omm@node0 ~]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] node0
......
=========================================
Successfully started.
步骤 6 确认 openGauss 数据库服务已启动。
[omm@node0 ~]$ gs_om -t status;
-----------------------------------------------------------------------

cluster_name    : dbCluster
cluster_state   : Normal
redistributing  : No

-----------------------------------------------------------------------
步骤 7 再次检查 openGauss 实例连接。
[omm@node0 ~]$ gs_check -i CheckDBConnection -L

2024-03-25 19:46:27 [NAM] CheckDBConnection
2024-03-25 19:46:27 [STD] 检查能否连接数据库,如果连接成功则检查项通过,否则检查项不通过
2024-03-25 19:46:27 [RST] OK
The database connection is normal.
2024-03-25 19:46:27 [RAW]

source '/home/omm/.bashrc' && gsql -m -d postgres -p 15400 -c 'select pg_sleep(1);'

说明:
CheckDBConnection...........................OK 表示连接检查项正常;
Success. All check items run completed. Total:1 Success:1 表示共检查 1 项并且检查结
果成功。
openGauss 数据库运行健康状态检查实验结束

3 数据库性能检查

3.1 实验介绍

openGauss 提供了 gs_checkperf 工具来帮助用户了解 openGauss 的负载情况。
本实验主要是通过 gs_checkperf 工具来检查 openGauss 数据库性能以及通过 EXPLAIN 来进行
SQL 语句优化。

3.2 通过 gs_checkperf 工具来检查数据库性能

说明:
gs_checkperf 可以对以下级别进行检查:
  openGauss 级别(主机 CPU 占用率、 Gauss CPU 占用率、 I/O 使用情况等)、
  节点级别( CPU 使用情况、内存使用情况、 I/O 使用情况)、
  会话 / 进程级别( CPU 使用情况、内存使用情况、 I/O 使用情况)、
  SSD 性能(写入、读取性能)
其中检查 SSD 性能要用 root 用户执行,检查 openGauss 性能要用 openGauss 安装用户执行
本实验为检查 openGauss 性能。
步骤 1 ROOT 用户登录装有 openGauss 数据库服务的操作系统然后用 su – omm 命令切换至
OMM 用户环境,登录后信息如下。
[root@node0 ~]# su - omm
Last login: Mon Mar 25 18:47:31 CST 2024 on pts/0


Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64

System information as of time: 	2024年 03月 25日 星期一 19:31:35 CST

System load: 	0.30
Processes: 	195
Memory used: 	39.0%
Swap used: 	14.3%
Usage On: 	25%
IP address: 	192.168.28.131
Users online: 	1
To run a command as administrator(user "root"),use "sudo <command>".
步骤 2 先启动数据库服务,再用 gs_checkperf 检查下,再使用 gsql 客户端以管理员用户身份连接
postgres 数据库,假设端口号为 15400
先启动数据库服务。
[omm@node0 ~]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] node0:
[2024-03-25 19:53:25.112][42128][][gs_ctl]: gs_ctl started,datadir is /opt/huawei/install/data/dn 
[2024-03-25 19:53:25.129][42128][][gs_ctl]:  another server might be running; Please use the restart command
=========================================
Successfully started.
gs_checkperf 检查下。
[omm@node0 ~]$ gs_checkperf
Cluster statistics information:
    Host CPU busy time ratio                     :    1.79       %
    MPPDB CPU time % in busy time                :    8.68       %
    Shared Buffer Hit ratio                      :    99.56      %
    In-memory sort ratio                         :    0
    Physical Reads                               :    759
    Physical Writes                              :    124
    DB size                                      :    50         MB
    Total Physical writes                        :    124
    Active SQL count                             :    4
    Session count                                :    8
然后连接 postgres 数据库。
[omm@node0 ~]$ gsql -d postgres -p 15400 -r
gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:37:13 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

步骤 3 PMK 模式下的表进行统计信息收集。
openGauss=#  analyze pmk.pmk_configuration;
ANALYZE
openGauss=#  analyze pmk.pmk_meta_data;
ANALYZE
openGauss=#  analyze pmk.pmk_snapshot;
ANALYZE
openGauss=#  analyze pmk.pmk_snapshot_datanode_stat;
ANALYZE
gs_checkperf 工具的监控信息依赖于 pmk 模式下的表的数据,如果 pmk 模式下的表未执
analyze 操作,则可能导致 gs_checkperf 工具执行失败。
步骤 4 执行简要性能检查。
\q 先退出 postgres 数据库,然后在操作系统用户 omm 环境下去执行 gs_checkperf 检查
工具,具体如下:
openGauss=# \q
[omm@node0 ~]$ gs_checkperf
Cluster statistics information:
    Host CPU busy time ratio                     :    2.02       %
    MPPDB CPU time % in busy time                :    16.25      %
    Shared Buffer Hit ratio                      :    99.67      %
    In-memory sort ratio                         :    0
    Physical Reads                               :    777
    Physical Writes                              :    335
    DB size                                      :    51         MB
    Total Physical writes                        :    335
    Active SQL count                             :    4
    Session count                                :    8
步骤 5 执行详细性能检查。
[omm@node0 ~]$ gs_checkperf --detail
Cluster statistics information:
Host CPU usage rate:
    Host total CPU time                          :    26998790.000 Jiffies
    Host CPU busy time                           :    594830.000 Jiffies
    Host CPU iowait time                         :    5920.000   Jiffies
    Host CPU busy time ratio                     :    2.20       %
    Host CPU iowait time ratio                   :    .02        %
MPPDB CPU usage rate:
    MPPDB CPU time % in busy time                :    16.57      %
    MPPDB CPU time % in total time               :    .37        %
Shared buffer hit rate:
    Shared Buffer Reads                          :    1232
    Shared Buffer Hits                           :    430218
    Shared Buffer Hit ratio     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值