
字数 1918,阅读大约需 10 分钟
该套数据库巡检脚本多数为纯SQL脚本开发,如下所示:


1、可以巡检
Oracle、MySQL(包括Mariadb)、SQL Server、PostgreSQL、Greenplum、OceanBase、TiDB、openGauss、DB2、达梦、人大金仓(KES+KADB)、万里GreatDB、TDSQL_for_PG(原 TBase)、MogDB、OushuDB、PolarDB_for_PG、神通、南大通用GBase 8a+8c、StarRocks、YMatrix、YashanDB等21种数据库,也可以巡检Linux操作系统(后续会免费逐步增加MongoDB、Redis等数据库) 2、脚本为绿色版、免安装、纯SQL文本 3、跨平台,只要有sqlplus(Oracle)、mysql(MySQL、Mariadb、TiDB、OceanBase、万里GreatDB、南大通用GBase 8a、StarRocks)、sqlcmd(SSMS、Navicat皆可)、psql(PG、Greenplum、openGauss、人大金仓KES+KADB、TBase、MogDB、OushuDB、PolarDB_for_PG、南大通用GBase 8c、YMatrix)、gsql(openGauss、GaussDB、MogDB、南大通用GBase 8c)、disql(国产达梦)、db2(DB2数据库)、obclient(OceanBase)、ksql(人大金仓KES)、isql(神舟通用)、gccli(南大通用GBase 8a)、yasql(崖山数据库)环境即可运行脚本 4、脚本内容可视化,可以看到脚本内容,因此可供学习数据库使用 5、兼容Oracle 10g、11g、12c、18c、19c、21c、23ai等高版本Oracle数据库 6、对Oracle 10g、11g、12c、18c、19c、21c、23ai等版本分别提供了只读版(只对数据库查询,不做DDL和DML操作) 7、MySQL最低支持5.5版本,小于5.5版本未进行测试 8、SQL Server最低支持2005版本 9、增删监控项非常方便,只需要提供相关SQL即可 10、一次购买,所有脚本终身免费升级 11、检查内容非常全面 12、针对每种数据库,只有1个SQL脚本,不存在嵌套调用脚本等其它问题 13、最终生成html文件格式的健康检查结果 14、Oracle数据库对巡检结果进行过滤,列出了数据库有问题的内容 15、对OS的信息提供了收集(单独脚本) 16、对Oracle、MySQL、SQL Server、PG、GreenPlum提供英文版
需要有psql客户端,运行方式如下:
psql -U postgres -h 192.168.66.35 -p 54324 -d postgres -W -H -q -f D:\DB_PG_HC_lhr_v7.0.0.sql > d:\a.html输入密码,回车即可。
注意: 1、该脚本的字符集为utf8,若修改文件内容请使用utf8格式打开该文件。 2、巡检内容“WAL日志切换频率(需要手动修改脚本路径)”部分的“
/pg13/pgdata/pg_wal”路径需要手动修改为自己环境真实的路径,否则会报错:ERROR: absolute path not allowed
由于用户环境的版本或插件问题,如下的报错请忽略,不影响最终的结果:
[pg94@lhrpgall ~]$ psql -W -H -f DB_PG_HC_lhr_v7.0.0.sql> a.html
Password:
psql:DB_PG_HC_lhr_v7.0.0.sql:291: ERROR: column p.prokind does not exist
LINE 2: CASE p.prokind
^
psql:DB_PG_HC_lhr_v7.0.0.sql:359: ERROR: column "total_exec_time" does not exist
LINE 3: round(total_exec_time::numeric, 2) AS total_time,
^
psql:DB_PG_HC_lhr_v7.0.0.sql:368: ERROR: column "mean_time" does not exist
LINE 4: round(mean_time::numeric, 2) AS mean_time,
^
psql:DB_PG_HC_lhr_v7.0.0.sql:385: ERROR: column "total_exec_time" does not exist
LINE 3: round(total_exec_time::numeric, 2) AS total_time,
^
psql:DB_PG_HC_lhr_v7.0.0.sql:401: ERROR: pg_stat_statements must be loaded via shared_preload_libraries
psql:DB_PG_HC_lhr_v7.0.0.sql:423: ERROR: relation "pg_stat_wal_receiver" does not exist
LINE 1: select*from pg_stat_wal_receiver;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:430: ERROR: function pg_current_wal_lsn() does not exist
LINE 3: pg_current_wal_lsn() AS A(c1)
^
HINT: Nofunctionmatches the given name and argument types. You might need toadd explicit type casts.
psql:DB_PG_HC_lhr_v7.0.0.sql:450: ERROR: relation "pg_publication" does not exist
LINE 1: select*from pg_publication;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:453: ERROR: relation "pg_publication_tables" does not exist
LINE 1: select*from pg_publication_tables;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:460: ERROR: relation "pg_stat_subscription" does not exist
LINE 1: select*from pg_stat_subscription;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:464: ERROR: relation "pg_subscription" does not exist
LINE 1: select*from pg_subscription;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:468: ERROR: relation "pg_subscription_rel" does not exist
LINE 1: select*,srrelid::regclass from pg_subscription_rel;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:490: ERROR: relation "pg_file_settings" does not exist
LINE 1: select*from pg_file_settings;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:528: ERROR: relation "pg_hba_file_rules" does not exist
LINE 1: select*from pg_hba_file_rules;
^
psql:DB_PG_HC_lhr_v7.0.0.sql:588: ERROR: absolute path not allowed
psql:DB_PG_HC_lhr_v7.0.0.sql:589: ERROR: could notopen directory "/pg13/pgdata/pg_wal": Permission denied
psql:DB_PG_HC_lhr_v7.0.0.sql:666: ERROR: relation "pg_config" does not exist
LINE 1: SELECT*FROM pg_config ;
^
这里只列出部分结果,其它的详细内容可以参考:https://share.weiyun.com/FQY9zcm0




英文版界面:


其它不再列举。
请参考:https://www.dbaup.com/shujukuxunjianjiaoben.html