您的位置:  首页 > 技术 > 数据库 > 正文

AI4DB:人工智能之慢SQL根因分析

2022-04-18 17:00 https://my.oschina.net/gaussdb/blog/5515391 Gauss松鼠会 次阅读 条评论

AI4DB: 慢SQL根因分析

概述

慢SQL一直是数据运维中的痛点问题,如何有效诊断慢SQL根因是当前一大难题,工具结合openGauss自身特点融合了现网DBA慢SQL诊断经验,该工具可以支持慢SQL根因15+,能同时按照可能性大小输出多个根因并提供针对性的建议。

环境部署

  • 数据库运行正常。
  • 指标采集系统运行正常。

使用指导

假设用户已经初始化配置文件目录confpath,则可以通过下述命令实现本特性的功能:

  • 仅启动慢SQL诊断功能(输出Top3根因),启动命令如下(更多用法参考对service子命令的说明):
gs_dbmind service start -c confpath --only-run slow_query_diagnosis

  • 用户交互式慢SQL诊断,命令如下:
gs_dbmind component slow_query_diagnosis show -c confpath --query SQL --start-time timestamps0 --end-time timestamps1

  • 用户手动清理历史预测结果,命令如下:
gs_dbmind component slow_query_diagnosis clean -c confpath --retention-days DAYS

  • 停止已启动的服务,命令如下:
gs_dbmind service stop -c confpath

获取帮助

模块命令行说明:

gs_dbmind component slow_query_diagnosis --help

usage:  [-h] -c DIRECTORY [--query SLOW_QUERY]
        [--start-time TIMESTAMP_IN_MICROSECONDS]
        [--end-time TIMESTAMP_IN_MICROSECONDS] [--retention-days DAYS]
        {show,clean}

Slow Query Diagnosis: Analyse the root cause of slow query

positional arguments:
  {show,clean}          choose a functionality to perform

optional arguments:
  -h, --help            show this help message and exit
  -c DIRECTORY, --conf DIRECTORY
                        set the directory of configuration files
  --query SLOW_QUERY    set a slow query you want to retrieve
  --start-time TIMESTAMP_IN_MICROSECONDS
                        set the start time of a slow SQL diagnosis result to
                        be retrieved
  --end-time TIMESTAMP_IN_MICROSECONDS
                        set the end time of a slow SQL diagnosis result to be
                        retrieved
  --retention-days DAYS
                        clear historical diagnosis results and set the maximum
                        number of days to retain data

命令参考

参数参数说明取值范围
-h, –help帮助命令-
action动作参数show:结果展示,clean:清理结果
-c,–conf配置目录-
–query慢SQL文本*
–start-time显示开始时间的时间戳,单位毫秒非负整数
–end-time显示结束时间的时间戳,单位毫秒非负整数
–retention-days清理天数级结果非负实数

常见问题处理

  • 如果用户对没有执行过的慢SQL执行交互式诊断命令,则无法给出诊断结果。
  • exporter指标采集功能没有启动时运行慢SQL诊断功能,此时功能无法正常运行。
  • 配置文件中的参数重新设置后,需要重新启动服务进程才能生效。
展开阅读全文
  • 0
    感动
  • 0
    路过
  • 0
    高兴
  • 0
    难过
  • 0
    搞笑
  • 0
    无聊
  • 0
    愤怒
  • 0
    同情
热度排行
友情链接