天天看点

openGauss数据库维护管理指导(三)

作者:数据库这点事儿

上期我们介绍了openGauss数据库操作系统参数检查、健康状态检查,本期继续介绍数据库性能检查。

3.数据库性能检查

3.1 实验介绍

3.1.1 关于本实验

openGauss 不仅提供了gs_checkperf工具来帮助用户了解openGauss的负载情况。

本实验主要是通过gs_checkperf工具来检查openGauss数据库性能以及通过EXPLAIN来进行SQL语句优化。

3.1.2 实验目的

掌握gs_checkperf工具的基本使用

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用户环境,登录后信息如下。

Welcome to 4.19.90-2003.4.0.0036.oe1.aarch64

System information as of time: Tue Jul 21 09:21:11 CST 2020

System load: 0.01

Processes: 109

Memory used: 6.7%

Swap used: 0.0%

Usage On: 15%

IP address: 192.168.0.96

Users online: 1

[root@ecs-e1b3 ~]# su - omm

Last login: Fri Jul 10 19:05:39 CST 2020 on pts/0

Welcome to 4.19.90-2003.4.0.0036.oe1.aarch64

System information as of time: Tue Jul 21 09:21:25 CST 2020

System load: 0.01

Processes: 111

Memory used: 7.0%

Swap used: 0.0%

Usage On: 15%

IP address: 192.168.0.96

Users online: 1

[omm@ecs-e1b3 ~]$

步骤 2 先启动数据库服务,再用gs_checkperf检查下,再使用gsql客户端以管理员用户身份连接postgres数据库,假设端口号为26000。

先启动数据库服务。

[omm@ecs-e1b3 ~]$ gs_om -t start;

Starting cluster.

=========================================

=========================================

Successfully started.

用gs_checkperf检查下。

[omm@ecs-e1b3 ~]$ gs_checkperf

Cluster statistics information:

Host CPU busy time ratio : .72 %

MPPDB CPU time % in busy time : .33 %

Shared Buffer Hit ratio : 97.33 %

In-memory sort ratio : 0

Physical Reads : 466

Physical Writes : 175

DB size : 47 MB

Total Physical writes : 175

Active SQL count : 3

Session count : 4

确认openGauss数据库服务是否正常。

[omm@ecs-e1b3 ~]$ gs_om -t status;

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

cluster_state : Unavailable

redistributing : No

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

cluster_state : Normal 表示已启动,可以正常使用。如果状态为Unavailable表示不可用

为了实验继续进行,请先启动数据库服务。

启动数据库服务(如果数据库服务是正常的,此步骤可以不执行)。

[omm@ecs-e1b3 ~]$ gs_om -t start;

Starting cluster.

=========================================

=========================================

Successfully started.

然后连接postgres数据库。

[omm@ecs-e1b3 ~]$ gsql -d postgres -p 26000 -r

gsql ((openGauss 1.1.0 build 38a9312a) compiled at 2020-05-27 14:57:08 commit 472 last mr 549 )

Non-SSL connection (SSL connection is recommended when requiring high-security)

Type "help" for help.

postgres=#

步骤 3 对PMK模式下的表进行统计信息收集。

postgres=# **yze pmk.pmk_configuration;

**YZE

postgres=# **yze pmk.pmk_meta_data;

**YZE

postgres=# **yze pmk.pmk_snapshot;

**YZE

postgres=# **yze pmk.pmk_snapshot_datanode_stat;

**YZE

postgres=#

说明:

gs_checkperf工具的监控信息依赖于pmk模式下的表的数据,如果pmk模式下的表未执行**yze操作,则可能导致gs_checkperf工具执行失败。

步骤 4 执行简要性能检查。

用 \q 先退出postgres数据库,然后在操作系统用户 omm 环境下去执行gs_checkperf检查工具,具体如下:

postgres=#

postgres=# \q

[omm@ecs-e1b3 ~]$ gs_checkperf

Cluster statistics information:

Host CPU busy time ratio : 1.66 % -----主机CPU占用率

MPPDB CPU time % in busy time : 2.51 % ----Gauss CPU占用率

Shared Buffer Hit ratio : 99.14 % ----共享内存命中率

In-memory sort ratio : 0 ---内存中排序比率

Physical Reads : 504 ---物理读次数

Physical Writes : 162 ---物理写次数

DB size : 57 MB ---DB大小

Total Physical writes : 162 ---总物理写次数

Active SQL count : 4 ---当前SQL执行数

Session count : 5 ---Session数量

步骤 5 执行详细性能检查。

[omm@ecs-e1b3 ~]$ gs_checkperf --detail

Cluster statistics information:

Host CPU usage rate:

Host total CPU time : 45719980.000 Jiffies

Host CPU busy time : 761060.000 Jiffies

Host CPU iowait time : 6640.000 Jiffies

Host CPU busy time ratio : 1.66 %

Host CPU iowait time ratio : .01 %

MPPDB CPU usage rate:

MPPDB CPU time % in busy time : 5.12 %

MPPDB CPU time % in total time : .09 %

Shared buffer hit rate:

Shared Buffer Reads : 1057

Shared Buffer Hits : 139798

Shared Buffer Hit ratio : 99.25 %

In memory sort rate:

In-memory sort count : 0

In-disk sort count : 0

In-memory sort ratio : 0

I/O usage:

Number of files : 106

Physical Reads : 584

Physical Writes : 362

Read Time : 5794 ms

Write Time : 4046 ms

Disk usage:

DB size : 57 MB

Total Physical writes : 362

Average Physical write : 89471.08

Maximum Physical write : 362

Activity statistics:

Active SQL count : 4

Session count : 5

Node statistics information:

dn_6001:

MPPDB CPU Time : 38960 Jiffies

Host CPU Busy Time : 761060 Jiffies

Host CPU Total Time : 45719980 Jiffies

MPPDB CPU Time % in Busy Time : 5.12 %

MPPDB CPU Time % in Total Time : .09 %

Physical memory : 7144341504 Bytes

DB Memory usage : 14922285056 Bytes

Shared buffer size : 1073741824 Bytes

Shared buffer hit ratio : 99.25 %

Sorts in memory : 0

Sorts in disk : 0

In-memory sort ratio : 0

Number of files : 106

Physical Reads : 584

Physical Writes : 362

Read Time : 5794

Write Time : 4046

Session statistics information(Top 10):

Session CPU statistics:

1 dn_6001-postgres-omm:

Session CPU time : 2

Database CPU time : 39020

Session CPU time % : .01 %

……………

Session Memory statistics:

1 dn_6001-postgres-omm:

Buffer Reads : 1309

Shared Buffer Hit ratio : 93.03

In Memory sorts : 0

In Disk sorts : 0

In Memory sorts ratio : 0

Total Memory Size : 7433136

Used Memory Size : 6443268

………………..

Session IO statistics:

1 dn_6001-postgres-omm:

Physical Reads : 98

Read Time : 1069

2 dn_6001-postgres-omm:

Physical Reads : 13

Read Time : 173

……….........

[omm@ecs-e1b3 ~]$

gs_checkperf 检查实验结束。

继续阅读