openGauss 6.0.0 RC1数据库日常运维

引言

随着数字化时代的快速发展,数据库作为企业信息化的核心,其稳定性和性能对于企业至关重要。openGauss 6.0.0 openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。openGauss内核深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性。凭借其高性能、高可靠、高安全、易运维等特性,赢得了众多企业的青睐。本文将详细介绍openGauss 6.0.0 新版数据库的日常运维,帮助用户更好地管理和维护数据库。

一、启停 openGauss

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

[root@worker1 ~]# su - ommLast login: Fri May 17 16:29:59 CST 2024 on pts/0[omm@worker1 ~]$ 
1、启动openGauss

使用以下命令启动openGauss。

gs_om -t start

实验示例

[omm@worker1 script]$ gs_om -t startStarting cluster.=========================================[SUCCESS] worker1:[2024-06-04 14:04:56.387][76539][][gs_ctl]: gs_ctl started,datadir is /opt/openGauss/install/data/dn1 [2024-06-04 14:04:56.390][76539][][gs_ctl]:  another server might be running; Please use the restart command=========================================Successfully started.[omm@worker1 script]$ 

图片

2、停止openGauss

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

使用以下命令停止openGauss。

gs_om -t stop

实验示例​​​​​​​

[omm@worker1 script]$ gs_om -t stopStopping cluster.=========================================Successfully stopped cluster.=========================================End stop cluster.[omm@worker1 script]$ 

图片

说明: 启停节点及AZ的操作请参见《工具与命令参考》中“服务端工具 > gs_om”章节。

3、错误排查

如果启动openGauss或者停止openGauss服务失败,请根据日志文件中的日志信息排查错误,参见日志参考。

如果是超时导致启动失败,可以执行如下命令,设置启动超时时间,默认超时时间为300s。

gs_om -t start --time-out=300
    [omm@worker1 script]$ gs_om -t start --time-out=300Starting cluster.=========================================[SUCCESS] worker12024-06-04 14:06:51.484 665eaefb.1 [unknown] 139781304941184 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets2024-06-04 14:06:51.484 665eaefb.1 [unknown] 139781304941184 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets=========================================Successfully started.[omm@worker1 script]$ 

    图片

    4、日志类型参考

    在数据库运行过程中,会出现大量日志,既有保证数据库安全可靠的WAL日志(预写式日志,也称为Xlog),也有用于数据库日常维护的运行和操作日志等。在数据库发生故障时,可以参考这些日志进行问题定位和数据库恢复的操作。

    日志类型

    日志类型的详细说明请参见下表。

    *类型* *说明*
    系统日志 数据库系统进程运行时产生的日志,记录系统进程的异常信息。
    操作日志 通过客户端工具(例如gs_guc)操作数据库时产生的日志。
    Trace日志 打开数据库的调试开关后,会记录大量的Trace日志。这些日志可以用来分析数据库的异常信息。
    黑匣子日志 数据库系统崩溃的时候,通过故障现场堆、栈信息可以分析出故障发生时的进程上下文,方便故障定位。黑匣子具有在系统崩溃时,dump出进程和线程的堆、栈、寄存器信息的功能。
    审计日志 开启数据库审计功能后,将数据库用户的某些操作记录在日志中,这些日志称为审计日志。
    WAL日志 又称为REDO日志,在数据库异常损坏时,可以利用WAL日志进行恢复。由于WAL日志的重要性,所以需要经常备份这些日志。
    性能日志 数据库系统在运行时检测物理资源的运行状态的日志,在对外部资源进行访问时的性能日志,例如:磁盘、OBS等。

    二、查看 openGauss 状态

    背景信息
    openGauss支持查看整个openGauss的状态,通过查询结果确认openGauss或者单个主机的运行状态是否正常。

    前提条件
    openGauss已经启动。

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

    1、使用如下命令查询openGauss状态:​​​​​​​
    [omm@worker1 script]$ gs_ctl status[2024-06-04 14:07:34.222][77045][][gs_ctl]: gs_ctl status,datadir is /opt/openGauss/install/data/dn1 gs_ctl: server is running (PID: 76866)/opt/openGauss/install/app/bin/gaussdb "-D" "/opt/openGauss/install/data/dn1"[omm@worker1 script]$ 

    图片

    2、若要查询某主机上的实例状态:

    请在命令中增加“-h”项。示例如下:​​​​​​​

    [omm@worker1 script]$ gs_om -t status -h worker1-----------------------------------------------------------------------
    cluster_state             : Normalredistributing            : No
    -----------------------------------------------------------------------
    node                      : 1node_name                 : worker1instance_id               : 6001node_ip                   : 172.10.20.121data_path                 : /opt/openGauss/install/data/dn1instance_port             : 15000type                      : Datanodeinstance_state            : Normalaz_name                   : AZ1instance_role             : Normal
    -----------------------------------------------------------------------
    [omm@worker1 script]$ 

    图片

    其中,worker1为待查询主机的名称。

    3、查看openGauss详细状态信息,含实例状态信息。​​​​​​​
    [omm@worker1 script]$ gs_om -t status --detail[   Cluster State   ]
    cluster_state   : Normalredistributing  : Nocurrent_az      : AZ_ALL
    [  Datanode State   ]
        node   node_ip         port      instance                                state--------------------------------------------------------------------------------------------------1  worker1 172.10.20.121    15000      6001 /opt/openGauss/install/data/dn1   P Primary Normal[omm@worker1 script]$ 

    图片

    三、openGauss 例行维护

    1、日维护检查项
    1.1 检查openGauss状态

    通过openGauss提供的工具查询数据库和实例状态,确认数据库和实例都处于正常的运行状态,可以对外提供数据服务。

    检查实例状态​​​​​​​

    [omm@worker1 script]$ gs_check -U omm -i CheckClusterStateParsing the check items config file successfullyDistribute the context file to remote hosts successfullyStart to health check for the cluster. Total Items:1 Nodes:1
    Checking...               [=========================] 1/1Start to analysis the check resultCheckClusterState...........................OKThe item run on 1 nodes.  success: 1 
    Analysis the check result successfullySuccess.  All check items run completed. Total:1   Success:1    For more information please refer to /opt/openGauss/install/tool/script/gspylib/inspection/output/CheckReport_202406045113977563.tar.gz[omm@worker1 script]$ 

    图片

    1.2 检查锁信息

    锁机制是数据库保证数据一致性的重要手段,检查相关信息可以检查数据库的事务和运行状况。

    查询数据库中的锁信息​​​​​​​

    openGauss=# SELECT * FROM pg_locks;  locktype  | database | relation | page | tuple | bucket | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction |       pid       |    sessionid    |      mode       | granted | fastpath |      locktag      | global_sessionid ------------+----------+----------+------+-------+--------+------------+---------------+---------+-------+----------+--------------------+-----------------+-----------------+-----------------+---------+----------+-------------------+------------------ relation   |    15737 |    12191 |      |       |        |            |               |         |       |          | 10/361             | 139774354519808 | 139774354519808 | AccessShareLock | t       | t        | 3d79:2f9f:0:0:0:0 | 0:0#0</
    评论 3
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包

    打赏作者

    Gauss松鼠会

    你的鼓励将是我创作的最大动力

    ¥1 ¥2 ¥4 ¥6 ¥10 ¥20
    扫码支付:¥1
    获取中
    扫码支付

    您的余额不足,请更换扫码支付或充值

    打赏作者

    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

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

    余额充值