跳转至

seabox inspect

seabox inspect

集群运维工具

语法

``` bash seabox inspect toolkit.

Usage: seabox inspect [OPTIONS]

Options: -o, –output cluster inspection report output file path -e, –expect inspect expect file -F, –format TEXT inspection report file format style -f, –full perform a complete inspect -S, –shrink pick files from log dir, shrink and move to log_shrink dir -n, –limit print the first K lines of the result -c, –check specified check item whose name is given in -l

-i –ignore ignore check item whose name is given in -i -v, –verbose output verbose message -l, –list list all check items

–start_time start_time start time for duration_query_check or shrink log, format by YYYY-mm-dd –end_time end_time end time for duration_query_check or shrink log, format by YYYY-mm-dd –write_lag write_lag write_lag for replication_lag_check, unit:second, format 0.000100 –flush_lag flush_lag flush_lag for replication_lag_check, unit:second, format 0.000100 –age_remain age_remain age_remain for database_age_check or relation_age_check, a integer value –time_consuming time_consuming time_consuming for active_xact_time_consuming_check, unit:second, a integer value –indexno indexno indexno for index_number_check, max number of index belong to one relation –relsize relsize relsize for index_number_check, unit:byte, max relation size –idxscan idxscan idxscan for index_use_check, times of idxscan, a integer value –idxsize idxsize idxsize for index_use_check, unit:byte, max index size –rollback_ratio rollback_ratio rollback_ratio for execute_stat_check, a float value –hit_ratio hit_ratio hit_ratio for execute_stat_check, a float value –conflicts conflicts conflicts for execute_stat_check, a integer value –deadlocks deadlocks deadlocks for execute_stat_check, a integer value –exact_size exact_size take longer to get an exact check –bloat_rate bloat_rate relation bloat rate –cv cv table size coefficient of variation –duration duration sql duration threshold, unit:seconds –audit_host audit_host sdaudit hostname –audit_port audit_port sdaudit port –audit_user audit_user sdaudit username –audit_pass audit_pass sdaudit user password –audit_dbname audit_dbname sdaudit database name -h, –help show this help, then exit

```

描述

集群运维工具集,包括集群巡检和审计日志处理等功能

  • 注意:如有注意事项,补充
选项

该命令支持选项说明如下:

Options

命令支持的选项

-o, --output TEXT
生成的巡检报告路径,如不指定则默认为SDHOME/inspect_report
-e, --expect TEXT
预期文件路径
-F, --format TEXT
指定输出格式,默认为纯文本格式报告,可指定为json格式
-f, --full
执行完全巡检,包含耗时较长的检查
-S, --shrink
处理审计日志,提取重要日志并存放到log_shrink文件夹中
-n, --limit TEXT
输出结果的前n行
-c, --check TEXT
自定义巡检检查项,可指定多个检查项
-v, --verbose
详细的输出模式
-i --ignore
跳过某项检查
-l, --list
查看巡检中的所有检查项,用于-c
--start_time TIME --end_time TIME
duration_query_check和shrink log检查项用来设置开始和结束时间,时间格式为YYYY-mm-dd,只在上述两项检查生效,可拆分指定
--write_lag LAG --flush_lag LAG
在replication_lag_check中指定write_lag和flush_lag的阈值,单位为秒,格式为数字,例如0.000100,只在上述检查生效,可拆分指定
--age_remain AGE
在database_age_check和relation_age_check用来设置age_remain的阈值,格式为整数值,只在上述两项检查生效
--time_consuming TIME
在active_xact_time_consuming_check用来设置time_consuming阈值,单位为秒,格式为整型,只在上述检查生效
--indexno NO --relsize SIZE
在index_number_check中用来设置indexno和relsize的阈值,格式为整型数值,relsize的单位为byte,只在上述检查生效,可拆分指定
--idxscan SCAN --idxsize SIZE
在index_use_check中用来设置idxscan和idxsize的阈值,格式为整型数值,idxsize单位为byte,只在上述检查生效,可拆分指定
--rollback_ratio R1 --hit_ratio R2 --conflicts C1 --deadlocks D1
在execute_stat_check用来指定以上四项指标的阈值,rollback_ratio和hit_ratio的格式为float类型,conflicts和deadlocks为整型数值,只在上述检查生效,可拆分指定
--exact_size VAL
指定relation_size_check的模式,当VAL为真时,会获取更准确的表容量,但是会花费更多的时间
--bloat_rate RATE
在relation_bloat_check中指定bloat_rate的阈值,格式为浮点型,只在上述检查生效
--cv VAL
在data_skew_check中设置变异系数的阈值,格式为浮点型,只在上述检查生效
--duration
sql持续时间阀值,单位:秒
--audit_host
sdaudit 主机名
--audit_port
sdaudit 段口号
--audit_user
sdaudit 用户名
--audit_pass
sdaudit 用户密码
--audit_dbname
sdaudit 数据库名称
示例

以下是seabox inspect --help的执行结果:

seabox inspect toolkit.

Usage: 
  seabox inspect [OPTIONS]

Options:
  -o, --output                    cluster inspection report output file path
  -e, --expect                    inspect expect file
  -F, --format TEXT               inspection report file format style
  -f, --full                      perform a complete inspect
  -S, --shrink                    pick files from log dir, shrink and move to
                                  log_shrink dir
  -n, --limit                     print the first K lines of the result
  -c, --check                     specified check item whose name is given in
                                  -l
  -i, --ignore                    ignore check item whose name is given in -i
  -v, --verbose                   output verbose message
  -l, --list                      list all check items
  --start_time start_time         start time for duration_query_check or
                                  shrink log, format by YYYY-mm-dd
  --end_time end_time             end time for duration_query_check or shrink
                                  log, format by YYYY-mm-dd
  --write_lag write_lag           write_lag for replication_lag_check,
                                  unit:second, format 0.000100
  --flush_lag flush_lag           flush_lag for replication_lag_check,
                                  unit:second, format 0.000100
  --age_remain age_remain         age_remain for database_age_check or
                                  relation_age_check, a integer value
  --time_consuming time_consuming
                                  time_consuming for
                                  active_xact_time_consuming_check,
                                  unit:second, a integer value
  --indexno indexno               indexno for index_number_check, max number
                                  of index belong to one relation
  --relsize relsize               relsize for index_number_check, unit:byte,
                                  max relation size
  --idxscan idxscan               idxscan for index_use_check, times of
                                  idxscan, a integer value
  --idxsize idxsize               idxsize for index_use_check, unit:byte, max
                                  index size
  --rollback_ratio rollback_ratio
                                  rollback_ratio for execute_stat_check, a
                                  float value
  --hit_ratio hit_ratio           hit_ratio for execute_stat_check, a float
                                  value
  --conflicts conflicts           conflicts for execute_stat_check, a integer
                                  value
  --deadlocks deadlocks           deadlocks for execute_stat_check, a integer
                                  value
  --exact_size exact_size         take longer to get an exact check
  --bloat_rate bloat_rate         relation bloat rate
  --cv cv                         table size coefficient of variation
  --duration duration             sql duration threshold, unit:seconds
  --audit_host audit_host         sdaudit hostname
  --audit_port audit_port         sdaudit port
  --audit_user audit_user         sdaudit username
  --audit_pass audit_pass         sdaudit user password
  --audit_dbname audit_dbname     sdaudit database name
  -h, --help                      show this help, then exit

执行默认巡检,使用默认预期文件

seabox inspect -o report.out

执行默认巡检,指定预期文件和巡检报告路径

seabox inspect -e expect.yml -o report.out

执行完全巡检,指定预期文件和巡检报告路径

seabox inspect -e expect.yml -o report.out

执行默认巡检,指定输出json格式报告

seabox inspect -o report.out -F json

查看巡检中的所有检查项

seabox inspect -l

base_info_check                         数据库基本信息检查
key_dir_size_check                      关键目录空间占用检查
etcd_space_check                        ETCD空间占用检查
key_config_diff_check                   关键参数一致性检查
active_xact_time_consuming_check        活跃事务耗时检查
database_age_check                      数据库年龄分析
cluster_connection_check                数据库连接分析
junk_data_check                         数据库垃圾数据分析
execute_stat_check                      数据库执行状态检查
replication_lag_check                   节点流复制延迟检查
replication_state_check                 节点流复制状态检查
bgwriter_stat_check                     后台写状态检查
index_number_check                      索引数量检查
index_use_check                         索引使用检查
relation_age_check                      数据库表年龄分析
relation_bloat_check                    数据库表膨胀分析
duration_query_check                    慢SQL检查
data_skew_check                         数据倾斜检查
schema_space_check                      schema空间占用分析
database_space_check                    数据库空间占用分析
tablespace_space_check                  表空间空间占用分析
relation_size_check                     数据库表容量分析
relation_index_exsits_check             无索引表分析
relation_primarykey_exsits_check        无主键表分析

自定义检查项执行巡检

seabox inspect -e expect.yml -o report.out -c base_info_check key_dir_size_check key_config_diff_check

base_info_check                         ... normal (0.788s)
key_dir_size_check                      ... normal (0.734s)
key_config_diff_check                   ... normal (2.924s)

seabox inspect passed

收缩n天前的审计日志

# 1. 配置巡检文件,指定 ndays_ago: n
# 2. 执行收缩审计日志命令
seabox inspect -S

相关命令