该套数据库巡检脚本多数为纯SQL脚本开发,如下所示:
目前一共包含32个脚本,若脚本的扩展名为“.sql”则表示该脚本为sql脚本;若脚本的扩展名为“.pl”则表示该脚本为perl脚本;若脚本的扩展名为“.sh”则表示该脚本为shell脚本。
对于Oracle的SQL脚本而言,脚本DB_Oracle_HC_lhr_v7.0.0_10g.sql适用于Oracle 10g数据库,脚本DB_Oracle_HC_lhr_v7.0.0_11g.sql适用于Oracle 11g的数据库,脚本DB_Oracle_HC_lhr_v7.0.0_12c.sql适用于Oracle 12c及其以上版本,这3个脚本都是只读版本,这3个脚本只会对数据库做查询操作,不会做DML和DDL操作,这也是很多朋友所期待的功能。
脚本DB_OS_HC_lhr_v7.0.0.pl是perl脚本,执行后会对OS的信息进行收集,并且输出到html中。脚本DB_OS_HC_lhr_v7.0.0.sh是shell脚本,执行后会对OS的信息进行收集。
脚本DB_MySQL_HC_lhr_v7.0.0.sql是MySQL脚本,执行后会产生MySQL的健康检查html报告,该脚本为只读脚本。该脚本也适用于mariadb数据库。
脚本DB_SQLServer_HC_lhr_v7.0.0_2005.sql和DB_SQLServer_HC_lhr_v7.0.0_2008R2.sql是SQL Server脚本,存在部分DDL和DML操作,执行后会产生SQL Server的健康检查html报告。脚本DB_SQLServer_HC_lhr_v7.0.0_2005.sql最低支持2005版本,而脚本DB_SQLServer_HC_lhr_v7.0.0_2008R2.sql最低支持2008R2版本。
脚本DB_PG_HC_lhr_v7.0.0.sql是PG数据库脚本,执行后会产生PostgreSQL数据库的健康检查html报告。
脚本DB_GP_HC_lhr_v7.0.0.sql是Greenplum数据库脚本,执行后会产生Greenplum数据库的健康检查html报告。
脚本DB_DM_HC_lhr_v7.0.0是达梦数据库脚本,执行后会产生达梦数据库的健康检查html报告。
脚本DB_TiDB_HC_lhr_v7.0.0.sql是TiDB数据库脚本,执行后会产生TiDB数据库的健康检查html报告。
脚本DB_openGauss_HC_lhr_v7.0.0.sql是openGauss数据库脚本,执行后会产生openGauss数据库的健康检查html报告。
脚本DB_DB2_HC_lhr_v7.0.0.sql是DB2数据库脚本,执行后会产生DB2数据库的健康检查html报告。
脚本DB_OceanBase_HC_lhr_v7.0.0.sql是DB2数据库脚本,执行后会产生OceanBase数据库的健康检查html报告。
脚本DB_kingbase_HC_lhr_v7.0.0.sql是人大金仓OLTP数据库KES脚本,执行后会产生人大金仓数据库KES版的健康检查html报告。
脚本DB_kingbase_kadb_HC_lhr_v7.0.0.sql是人大金仓分析型数据库KingbaseAnalyticsDB及KADB数据库脚本,执行后会产生人大金仓KADB数据库的健康检查html报告。
脚本DB_GreatDB_HC_lhr_v7.0.0.sql是万里GreatDB数据库脚本,执行后会产生万里GreatDB数据库的健康检查html报告。
脚本DB_TBase_HC_lhr_v7.0.0.sql是TDSQL_for_PG(原 TBase)数据库脚本,执行后会产生TDSQL_for_PG(原 TBase)数据库的健康检查html报告。
脚本DB_MogDB_HC_lhr_v7.0.0.sql是MogDB数据库脚本,执行后会产生云和恩墨MogDB数据库的健康检查html报告。
脚本DB_OushuDB_HC_lhr_v7.0.0.sql是OushuDB数据库脚本,执行后会产生OushuDB数据库的健康检查html报告。
脚本DB_PolarDB_for_PG_HC_lhr_v7.0.0.sql是PolarDB_for_PG数据库脚本,执行后会产生PolarDB_for_PG数据库的健康检查html报告。
脚本DB_OSCAR_HC_lhr_v7.0.0.sql是神舟通用数据库脚本,执行后会产生神通数据库的健康检查html报告。
脚本DB_GBase8a_HC_lhr_v7.0.0.sql是南大通用GBase 8a数据库脚本,执行后会产生南大通用GBase 8a数据库的健康检查html报告。
脚本DB_GBase8c_HC_lhr_v7.0.0.sql是南大通用GBase 8c数据库脚本,执行后会产生南大通用GBase 8c数据库的健康检查html报告。
脚本DB_StarRocks_HC_lhr_v7.0.0.sql是StarRocks数据库脚本,执行后会产生StarRocks数据库的健康检查html报告。
脚本DB_YMatrix_HC_lhr_v7.0.0.sql是matrixdb数据库脚本,执行后会产生YMatrix数据库的健康检查html报告。
脚本DB_YashanDB_HC_lhr_v7.0.0.sql是YashanDB数据库脚本,执行后会产生崖山数据库的健康检查html报告。
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、20c、21c等高版本Oracle数据库
6、对Oracle 10g、11g、12c、18c、19c、20c、21c等版本分别提供了只读版(只对数据库查询,不做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的信息提供了收集(单独脚本)
这里只列出部分结果,其它的详细内容可以参考:https://share.weiyun.com/5lb2U2M
鼠标经过相关连接时会有相应的解释,如下图所示:
该脚本检查的内容较多,所以我对结果进行了过滤,如下:
点击链接即可查看结果:
数据库基本信息一目了然:
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
13、万里GreatDB数据库
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
其它不再列举。
这里只列出部分结果,其它的详细内容可以参考:https://share.weiyun.com/5lb2U2M
其它不再列举。
其它不再列举。
其它不再截图。
其它不再截图。
只要有sqlplus的客户端即可。
为了防止乱码,需要先配置环境变量。
1# Linux环境设置
2export LANG=en_US.GB2312
3export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
4
5# Windows环境配置
6set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
服务器端直接运行:
1sqlplus / as sysdba @DB_Oracle_HC_lhr_v7.0.0_12c.sql
sqlplus客户端运行:
1sqlplus sys/lhr@192.168.59.130:1521/orcl as sysdba @DB_Oracle_HC_lhr_v7.0.0_12c.sql
1、若脚本卡在告警日志部分,则可以考虑使用精简版
1DB_Oracle_HC_lhr_v7.0.0_11g_精简版.sql
2DB_Oracle_HC_lhr_v7.0.0_12c_精简版.sql
只要有mysql客户端即可,使用MariaDB的客户端也可以,如下:
1mysql -uroot -plhr -P3306 -s -f < DB_MySQL_HC_lhr_v7.0.0.sql > lhr_mysql_check.html
该脚本也适用于mariadb数据库。
由于版本问题,如下的报错请忽略,不影响最终的结果:
1C:\Users\lhrxxt>mysql -uroot -plhr -h192.168.1.35 -P3415 -s -f < D:\DB_MySQL_HC_lhr_v7.0.0.sql > d:\tmp.html
2mysql: [Warning] Using a password on the command line interface can be insecure.
3ERROR 1193 (HY000) at line 159: Unknown system variable 'show_compatibility_56'
4ERROR 1146 (42S02) at line 205: Table 'performance_schema.global_variables' doesn't exist
5ERROR 1193 (HY000) at line 370: Unknown system variable 'innodb_page_size'
6ERROR 1146 (42S02) at line 509: Table 'performance_schema.global_variables' doesn't exist
7ERROR 1146 (42S02) at line 546: Table 'performance_schema.hosts' doesn't exist
8ERROR 1054 (42S22) at line 634: Unknown column 'a.type' in 'where clause'
9ERROR 1054 (42S22) at line 662: Unknown column 'a.type' in 'where clause'
10ERROR 1054 (42S22) at line 732: Unknown column 'trx_is_read_only' in 'field list'
11ERROR 1146 (42S02) at line 811: Table 'performance_schema.metadata_locks' doesn't exist
12ERROR 1146 (42S02) at line 872: Table 'performance_schema.metadata_locks' doesn't exist
13ERROR 1146 (42S02) at line 905: Table 'sys.processlist' doesn't exist
14ERROR 1146 (42S02) at line 919: Table 'sys.schema_table_lock_waits' doesn't exist
15ERROR 1146 (42S02) at line 940: Table 'performance_schema.global_status' doesn't exist
16ERROR 1146 (42S02) at line 979: Table 'performance_schema.events_stages_current' doesn't exist
17ERROR 1146 (42S02) at line 995: Table 'performance_schema.events_statements_summary_by_digest' doesn't exist
18ERROR 1146 (42S02) at line 1027: Table 'sys.session' doesn't exist
19ERROR 1146 (42S02) at line 1040: Table 'sys.session' doesn't exist
20ERROR 1146 (42S02) at line 1053: Table 'performance_schema.events_statements_summary_by_digest' doesn't exist
21ERROR 1146 (42S02) at line 1080: Table 'sys.statement_analysis' doesn't exist
22ERROR 1146 (42S02) at line 1096: Table 'performance_schema.events_statements_summary_by_digest' doesn't exist
23ERROR 1146 (42S02) at line 1149: Table 'sys.statement_analysis' doesn't exist
24ERROR 1146 (42S02) at line 1165: Table 'performance_schema.table_io_waits_summary_by_index_usage' doesn't exist
25ERROR 1146 (42S02) at line 1187: Table 'performance_schema.events_statements_summary_by_digest' doesn't exist
26ERROR 1146 (42S02) at line 1222: Table 'performance_schema.events_statements_summary_by_digest' doesn't exist
27ERROR 1146 (42S02) at line 1276: Table 'sys.schema_unused_indexes' doesn't exist
28ERROR 1146 (42S02) at line 1295: Table 'mysql.innodb_index_stats' doesn't exist
29ERROR 1146 (42S02) at line 1349: Table 'performance_schema.global_variables' doesn't exist
30ERROR 1146 (42S02) at line 1386: Table 'performance_schema.global_status' doesn't exist
31ERROR 1054 (42S22) at line 1411: Unknown column 'a.PROCESSLIST_COMMAND' in 'where clause'
32ERROR 1146 (42S02) at line 1470: Table 'performance_schema.replication_group_members' doesn't exist
33ERROR 1146 (42S02) at line 1514: Table 'performance_schema.replication_connection_configuration' doesn't exist
34ERROR 1146 (42S02) at line 1539: Table 'performance_schema.clone_status' doesn't exist
35ERROR 1146 (42S02) at line 1550: Table 'performance_schema.clone_progress' doesn't exist
36ERROR 1146 (42S02) at line 1619: Table 'performance_schema.global_status' doesn't exist
37
38C:\Users\lhrxxt>mysql -uroot -plhr -h192.168.1.35 -P3416 -s -f < D:\DB_MySQL_HC_lhr_v7.0.0.sql > d:\tmp.html
39mysql: [Warning] Using a password on the command line interface can be insecure.
40ERROR 1193 (HY000) at line 159: Unknown system variable 'show_compatibility_56'
41ERROR 1146 (42S02) at line 205: Table 'performance_schema.global_variables' doesn't exist
42ERROR 1146 (42S02) at line 509: Table 'performance_schema.global_variables' doesn't exist
43ERROR 1054 (42S22) at line 634: Unknown column 'HISTORY' in 'field list'
44ERROR 1054 (42S22) at line 662: Unknown column 'HISTORY' in 'field list'
45ERROR 1146 (42S02) at line 811: Table 'performance_schema.metadata_locks' doesn't exist
46ERROR 1146 (42S02) at line 872: Table 'performance_schema.metadata_locks' doesn't exist
47ERROR 1146 (42S02) at line 905: Table 'sys.processlist' doesn't exist
48ERROR 1146 (42S02) at line 919: Table 'sys.schema_table_lock_waits' doesn't exist
49ERROR 1146 (42S02) at line 940: Table 'performance_schema.global_status' doesn't exist
50ERROR 1054 (42S22) at line 979: Unknown column 'WORK_COMPLETED' in 'field list'
51ERROR 1146 (42S02) at line 995: Table 'sys.x$ps_digest_95th_percentile_by_avg_us' doesn't exist
52ERROR 1146 (42S02) at line 1027: Table 'sys.session' doesn't exist
53ERROR 1146 (42S02) at line 1040: Table 'sys.session' doesn't exist
54ERROR 1305 (42000) at line 1053: FUNCTION sys.format_statement does not exist
55ERROR 1146 (42S02) at line 1080: Table 'sys.statement_analysis' doesn't exist
56ERROR 1305 (42000) at line 1096: FUNCTION sys.format_statement does not exist
57ERROR 1146 (42S02) at line 1149: Table 'sys.statement_analysis' doesn't exist
58ERROR 1305 (42000) at line 1165: FUNCTION sys.format_time does not exist
59ERROR 1305 (42000) at line 1187: FUNCTION sys.format_statement does not exist
60ERROR 1305 (42000) at line 1222: FUNCTION sys.format_statement does not exist
61ERROR 1146 (42S02) at line 1276: Table 'sys.schema_unused_indexes' doesn't exist
62ERROR 1146 (42S02) at line 1349: Table 'performance_schema.global_variables' doesn't exist
63ERROR 1146 (42S02) at line 1386: Table 'performance_schema.global_status' doesn't exist
64ERROR 1054 (42S22) at line 1411: Unknown column 'HISTORY' in 'field list'
65ERROR 1146 (42S02) at line 1470: Table 'performance_schema.replication_group_members' doesn't exist
66ERROR 1146 (42S02) at line 1514: Table 'performance_schema.replication_connection_configuration' doesn't exist
67ERROR 1146 (42S02) at line 1539: Table 'performance_schema.clone_status' doesn't exist
68ERROR 1146 (42S02) at line 1550: Table 'performance_schema.clone_progress' doesn't exist
69ERROR 1146 (42S02) at line 1619: Table 'performance_schema.global_status' doesn't exist
70
71C:\Users\lhrxxt>mysql -uroot -plhr -h192.168.1.35 -P3418 -s -f < D:\DB_MySQL_HC_lhr_v7.0.0.sql > d:\tmp.html
72mysql: [Warning] Using a password on the command line interface can be insecure.
73ERROR 1193 (HY000) at line 159: Unknown system variable 'show_compatibility_56'
74ERROR 1109 (42S02) at line 214: Unknown table 'GLOBAL_VARIABLES' in information_schema
75ERROR 1109 (42S02) at line 518: Unknown table 'GLOBAL_VARIABLES' in information_schema
76ERROR 1109 (42S02) at line 699: Unknown table 'INNODB_LOCKS' in information_schema
77ERROR 1109 (42S02) at line 719: Unknown table 'INNODB_LOCK_WAITS' in information_schema
78ERROR 1109 (42S02) at line 747: Unknown table 'INNODB_LOCK_WAITS' in information_schema
79ERROR 1109 (42S02) at line 949: Unknown table 'GLOBAL_STATUS' in information_schema
80ERROR 1109 (42S02) at line 1358: Unknown table 'GLOBAL_VARIABLES' in information_schema
81ERROR 1109 (42S02) at line 1395: Unknown table 'GLOBAL_STATUS' in information_schema
82ERROR 1146 (42S02) at line 1539: Table 'performance_schema.clone_status' doesn't exist
83ERROR 1146 (42S02) at line 1550: Table 'performance_schema.clone_progress' doesn't exist
84ERROR 1109 (42S02) at line 1628: Unknown table 'GLOBAL_STATUS' in information_schema
85
86C:\Users\lhrxxt> mysql -uroot -plhr -h192.168.1.35 -P3419 -s -f < DB_MySQL_HC_lhr_v7.0.0.sql > mariadb.html
87ERROR 1193 (HY000) at line 159: Unknown system variable 'show_compatibility_56'
88ERROR 1146 (42S02) at line 205: Table 'performance_schema.global_variables' doesn't exist
89ERROR 1146 (42S02) at line 509: Table 'performance_schema.global_variables' doesn't exist
90ERROR 1054 (42S22) at line 732: Unknown column 'trx_adaptive_hash_latched' in 'field list'
91ERROR 1146 (42S02) at line 905: Table 'sys.processlist' doesn't exist
92ERROR 1146 (42S02) at line 919: Table 'sys.schema_table_lock_waits' doesn't exist
93ERROR 1146 (42S02) at line 995: Table 'sys.x$ps_digest_95th_percentile_by_avg_us' doesn't exist
94ERROR 1146 (42S02) at line 1027: Table 'sys.session' doesn't exist
95ERROR 1146 (42S02) at line 1040: Table 'sys.session' doesn't exist
96ERROR 1305 (42000) at line 1053: FUNCTION sys.format_statement does not exist
97ERROR 1146 (42S02) at line 1080: Table 'sys.statement_analysis' doesn't exist
98ERROR 1305 (42000) at line 1096: FUNCTION sys.format_statement does not exist
99ERROR 1146 (42S02) at line 1149: Table 'sys.statement_analysis' doesn't exist
100ERROR 1305 (42000) at line 1165: FUNCTION sys.format_time does not exist
101ERROR 1305 (42000) at line 1187: FUNCTION sys.format_statement does not exist
102ERROR 1305 (42000) at line 1222: FUNCTION sys.format_statement does not exist
103ERROR 1146 (42S02) at line 1276: Table 'sys.schema_unused_indexes' doesn't exist
104ERROR 1146 (42S02) at line 1349: Table 'performance_schema.global_variables' doesn't exist
105ERROR 1146 (42S02) at line 1470: Table 'performance_schema.replication_group_members' doesn't exist
106ERROR 1146 (42S02) at line 1514: Table 'performance_schema.replication_connection_status' doesn't exist
107ERROR 1146 (42S02) at line 1539: Table 'performance_schema.clone_status' doesn't exist
108ERROR 1146 (42S02) at line 1550: Table 'performance_schema.clone_progress' doesn't exist
脚本DB_SQLServer_HC_lhr_v7.0.0_2005.sql和DB_SQLServer_HC_lhr_v7.0.0_2008R2.sql是SQL Server脚本,存在部分DDL和DML操作,执行后会产生SQL Server的健康检查html报告。脚本DB_SQLServer_HC_lhr_v7.0.0_2005.sql最低支持2005版本,而脚本DB_SQLServer_HC_lhr_v7.0.0_2008R2.sql最低支持2008R2版本。
1-- 在本机直接运行
2sqlcmd -d tempdb -y 0 -m 1 -i D:\DB_SQLServer_HC_lhr_v7.0.0_2008R2.sql -o D:\SQLServer_CHECK_LHR_20210914.html
3
4-- 远程运行
5sqlcmd -S 192.168.1.28 -U sa -P lhr -d tempdb -y 0 -m 1 -i D:\DB_SQLServer_HC_lhr_v7.0.0_2008R2.sql -o D:\SQLServer_CHECK_LHR_20210914.html
需要使用SQL Server Management Studio (SSMS)或Navicat for SQLServer客户端软件,直接运行脚本,然后将输出结果保存为html文件即可。
若是有乱码,需要将连接到的数据库配置为Chinese_PRC_BIN
排序规则,然后重新运行脚本:
1-- 修改lhrdb数据库的排序规则
2alter database lhrdb COLLATE Chinese_PRC_BIN
3
4-- 然后脚本的第8行修改为
5use lhrdb;
需要有psql客户端,运行方式如下:
1psql -U postgres -h 192.168.8.8 -p 54324 -d postgres -W -H -q -f D:\DB_PG_HC_lhr_v7.0.0.sql > d:\lhr_PG_check.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,若修改文件内容请使用utf8格式打开该文件。
2、巡检内容“WAL日志切换频率(需要手动修改脚本路径)”部分的“
/pg13/pgdata/pg_wal
”路径需要手动修改为自己环境真实的路径,否则会报错:ERROR: absolute path not allowed
由于用户环境的版本或插件问题,如下的报错请忽略,不影响最终的结果:
1[pg94@lhrpgall ~]$ psql -W -H -f DB_PG_HC_lhr_v7.0.0.sql > d:\lhr_PG_check.html
2Password:
3psql:DB_PG_HC_lhr_v7.0.0.sql:291: ERROR: column p.prokind does not exist
4LINE 2: CASE p.prokind
5 ^
6psql:DB_PG_HC_lhr_v7.0.0.sql:359: ERROR: column "total_exec_time" does not exist
7LINE 3: round(total_exec_time::numeric, 2) AS total_time,
8 ^
9psql:DB_PG_HC_lhr_v7.0.0.sql:368: ERROR: column "mean_time" does not exist
10LINE 4: round(mean_time::numeric, 2) AS mean_time,
11 ^
12psql:DB_PG_HC_lhr_v7.0.0.sql:385: ERROR: column "total_exec_time" does not exist
13LINE 3: round(total_exec_time::numeric, 2) AS total_time,
14 ^
15psql:DB_PG_HC_lhr_v7.0.0.sql:401: ERROR: pg_stat_statements must be loaded via shared_preload_libraries
16
17psql:DB_PG_HC_lhr_v7.0.0.sql:423: ERROR: relation "pg_stat_wal_receiver" does not exist
18LINE 1: select * from pg_stat_wal_receiver;
19 ^
20psql:DB_PG_HC_lhr_v7.0.0.sql:430: ERROR: function pg_current_wal_lsn() does not exist
21LINE 3: pg_current_wal_lsn() AS A(c1)
22 ^
23HINT: No function matches the given name and argument types. You might need to add explicit type casts.
24psql:DB_PG_HC_lhr_v7.0.0.sql:450: ERROR: relation "pg_publication" does not exist
25LINE 1: select * from pg_publication;
26 ^
27psql:DB_PG_HC_lhr_v7.0.0.sql:453: ERROR: relation "pg_publication_tables" does not exist
28LINE 1: select * from pg_publication_tables;
29 ^
30psql:DB_PG_HC_lhr_v7.0.0.sql:460: ERROR: relation "pg_stat_subscription" does not exist
31LINE 1: select * from pg_stat_subscription;
32 ^
33psql:DB_PG_HC_lhr_v7.0.0.sql:464: ERROR: relation "pg_subscription" does not exist
34LINE 1: select * from pg_subscription;
35 ^
36psql:DB_PG_HC_lhr_v7.0.0.sql:468: ERROR: relation "pg_subscription_rel" does not exist
37LINE 1: select *,srrelid::regclass from pg_subscription_rel;
38 ^
39psql:DB_PG_HC_lhr_v7.0.0.sql:490: ERROR: relation "pg_file_settings" does not exist
40LINE 1: select * from pg_file_settings;
41 ^
42psql:DB_PG_HC_lhr_v7.0.0.sql:528: ERROR: relation "pg_hba_file_rules" does not exist
43LINE 1: select * from pg_hba_file_rules;
44 ^
45psql:DB_PG_HC_lhr_v7.0.0.sql:588: ERROR: absolute path not allowed
46psql:DB_PG_HC_lhr_v7.0.0.sql:589: ERROR: could not open directory "/pg13/pgdata/pg_wal": Permission denied
47psql:DB_PG_HC_lhr_v7.0.0.sql:666: ERROR: relation "pg_config" does not exist
48LINE 1: SELECT * FROM pg_config ;
49 ^
在Windows下运行:
1disql -S SYSDBA/SYSDBA@192.168.1.35 `d:\DB_DM_HC_lhr_v7.0.0.sql
在Linux下运行:
1disql -S SYSDBA/SYSDBA \`/home/dmdba/DB_DM_HC_lhr_v7.0.0.sql > /dev/null
注意:
1、若不能出结果,则多半是字符集的问题,请将脚本修改为UTF8格式的文件(或使用
DB_DM_HC_lhr_v7.0.0_utf8.sql
脚本),然后再运行脚本。
只要有mysql客户端即可,使用MariaDB的客户端也可以,如下:
1mysql -uroot -plhr -P4000 -s -f < DB_TiDB_HC_lhr_v7.0.0.sql > lhr_mysql_check.html
需要有华为的gsql客户端,或PostgreSQL数据库的psql客户端都可以,运行方式如下:
若是openGauss或华为的GaussDB数据库的gsql客户端,则执行:
1gsql -U gaussdb -h 192.168.8.8 -p 15432 -d postgres -W'lhr@123XXT' -H -f D:\DB_openGauss_HC_lhr_v7.0.0.sql > d:\openGauss_health_check.html
若是PostgreSQL数据库的psql客户端,则执行:
1psql -U gaussdb -h 192.168.8.8 -p 54324 -d postgres -W -H -f D:\DB_openGauss_HC_lhr_v7.0.0.sql > d:\openGauss_health_check.html
psql需要输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
2、建议使用omm用户在服务器本地跑脚本。
需要有db2数据库客户端,运行方式如下:
① 客户端在Windows平台,连接到本地db2数据库:
1db2cmd
2db2 connect to lhrdb && db2 -txf D:\DB_DB2_HC_lhr_v7.0.0.sql > d:\lhr_db2_health_check.html
② 客户端在Linux平台,连接到本地db2数据库:
1db2 connect to lhrdb; db2 -txf DB_DB2_HC_lhr_v7.0.0.sql > lhr_db2_health_check_`date +'%Y%m%d%H%M%S'`.html
③ 客户端在Windows平台,需要连接到远程的linux服务器:
1db2cmd
2db2 connect to test user db2inst1 using lhr && db2 -txf D:\DB_DB2_HC_lhr_v7.0.0.sql > D:\lhr_db2_health_check.html
注意:
1、建议直接在服务端运行,因为个别巡检命令只支持在服务端运行。
2、该脚本只能对当前的数据库进行检测,若需要检查其它数据库,请重新跑脚本,并修改连接到的数据库名称,例如:db2 connect to test
;
有mysql客户端或者obclient都可以,如下:
1-- 使用obclient客户端
2obclient -uroot@sys -p -h192.168.8.8 -P2883 -f --silent < DB_OceanBase_HC_lhr_v7.0.0.sql > lhr_OceanBase_check.html
3
4-- 使用mysql客户端
5mysql -uroot@sys -p -h192.168.8.8 -P2883 -f --silent < DB_OceanBase_HC_lhr_v7.0.0.sql > lhr_OceanBase_check.html
操作系统信息的收集是perl脚本,运行方式如下所示。
1[root@OCPLHR lhr]# ll
2total 28
3-rw-r--r-- 1 oracle oinstall 25791 Jul 10 17:15 DB_OS_HC_lhr_v7.0.0.pl
4[root@OCPLHR lhr]# perl DB_OS_HC_lhr_v7.0.0.pl
5[root@OCPLHR lhr]# ll
6total 56
7-rw-r--r-- 1 oracle oinstall 25791 Jul 10 17:15 DB_OS_HC_lhr_v7.0.0.pl
8-rw-r--r-- 1 root root 26289 Jul 10 17:19 LHR_OSCHECK_REPORT_OCPLHR_20190710171939.html
9[root@OCPLHR lhr]#
10[root@OCPLHR lhr]# sh DB_OS_HC_lhr_v7.0.0.sh
11检查结果:./HostDailyCheck--20220825.txt
若运行报如下的错误:
1[root@ecs-9b83 ~]# sh DB_OS_HC_lhr_v7.0.0.sh
2DB_OS_HC_lhr_v7.0.0.sh: line 9: $'\r': command not found
3: No such file or directorye 13: /etc/profile
4[root@ecs-9b83 ~]# chmod +x DB_OS_HC_lhr_v7.0.0.sh
5[root@ecs-9b83 ~]# ./DB_OS_HC_lhr_v7.0.0.sh
6-bash: ./DB_OS_HC_lhr_v7.0.0.sh: /bin/bash^M: bad interpreter: No such file or directory则需要使用dos2unix进行格式化:
1[root@ecs-9b83 ~]# dos2unix DB_OS_HC_lhr_v7.0.0.sh
2dos2unix: converting file DB_OS_HC_lhr_v7.0.0.sh to Unix format ...
3[root@ecs-9b83 ~]# ./DB_OS_HC_lhr_v7.0.0.sh
4检查结果:./HostDailyCheck--20220825.txt
和PostgreSQL数据库相似,需要有psql客户端,运行方式如下:
1psql -U gpadmin -h 192.168.8.8 -p 64340 -d lhrgpdb -W -H -f D:\DB_GP_HC_lhr_v7.0.0.sql > d:\a.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
和PostgreSQL数据库相似,需要有psql客户端或者有人大金仓的ksql客户端都可以,运行方式如下:
1ksql -U kingbase -h 192.168.8.8 -p 54321 -d test -W -H -f D:\DB_kingbase_HC_lhr_v7.0.0.sql > d:\a.html
2psql -U kingbase -h 192.168.8.8 -p 54321 -d test -W -H -f D:\DB_kingbase_HC_lhr_v7.0.0.sql > d:\a.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
和GreenPlum数据库相似,需要有psql客户端,运行方式如下:
1psql -U mppadmin -h 192.168.8.8 -p 5432 -d lhrgpdb -W -H -f D:\DB_kingbase_kadb_HC_lhr_v7.0.0.sql > d:\a.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
只要有mysql客户端即可,使用MariaDB的客户端也可以,如下:
1mysql -uroot -plhr -P3306 -s -f < DB_GreatDB_HC_lhr_v7.0.0.sql > lhr_GreatDB_check.html
需要有psql客户端,运行方式如下:
1psql -U tbase -h 192.168.8.8 -p 30004 -d postgres -W -H -f D:\DB_TBase_HC_lhr_v7.0.0.sql > D:\TBase_health_check.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
需要有华为的gsql客户端,或PostgreSQL数据库的psql客户端都可以,运行方式如下:
若是openGauss或华为的GaussDB数据库的gsql客户端,则执行:
1gsql -U lhr -h 192.168.8.8 -p 25432 -d postgres -W'lhr@123XXT' -H -f D:\DB_MogDB_HC_lhr_v7.0.0.sql > d:\MogDB_health_check.html
若是PostgreSQL数据库的psql客户端,则执行:
1psql -U lhr -h 192.168.8.8 -p 25432 -d postgres -W -H -f D:\DB_MogDB_HC_lhr_v7.0.0.sql > d:\MogDB_health_check.html
psql需要输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
2、建议使用omm用户在服务器本地跑脚本。
需要有psql客户端,运行方式如下:
1psql -U gpadmin -h 192.168.8.8 -p 5432 -d postgres -H -f D:\DB_OushuDB_HC_lhr_v7.0.0.sql > d:\DB_OushuDB_check.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
需要有psql客户端,运行方式如下:
1psql -U postgres -h 192.168.8.8 -p 5432 -d postgres -H -f D:\DB_PolarDB_for_PG_HC_lhr_v7.0.0.sql > d:\PolarDB_for_PG_health_check.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
需要有神舟通用数据库的专用isql客户端,运行方式如下:
1isql -U sysdba/lhr -h 192.168.8.8 -p 2003 -q -t -f d:\DB_OSCAR_HC_lhr_v7.0.0.sql > d:\a.html
回车即可。
只要有南大通用GBase 8a的默认客户端gccli或gbase或mysql客户端即可,使用MariaDB的客户端也可以,如下:
1-- 使用gccli命令行
2gccli -uroot -plhr -h192.168.8.8 -P5258 -f -s < DB_GBase8a_HC_lhr_v7.0.0 > lhr_GBase8a_check.html
3
4-- 使用gbase命令行
5gbase -uroot -plhr -h192.168.8.8 -P5258 -f -s < DB_GBase8a_HC_lhr_v7.0.0 > lhr_GBase8a_check.html
6
7
8-- Windows上,可以使用MySQL客户端,使用5.7版本,否则会报错:ERROR 1043 (08S01): Bad handshake
9D:\db\MySQL\mysql-5.7.30-winx64\bin\mysql -uroot -plhr -h192.168.8.8 -P5258 -f -s < DB_GBase8a_HC_lhr_v7.0.0 > lhr_GBase8a_check.html
需要有GBase 8c的gsql客户端,或PostgreSQL数据库的psql客户端都可以,运行方式如下:
若是GBase 8c或华为的GaussDB数据库的gsql客户端,则执行:
1gsql -U gha -h 192.168.8.8 -p 5432 -d postgres -W'lhr@123XXT' -H -f D:\DB_GBase8c_HC_lhr_v7.0.0.sql > d:\GBase8c_health_check.html
若是PostgreSQL数据库的psql客户端,则执行:
1psql -U gha -h 192.168.8.8 -p 5432 -d postgres -W -H -f D:\DB_GBase8c_HC_lhr_v7.0.0.sql > d:\GBase8c_health_check.html
psql需要输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
2、建议使用gbase用户在服务器本地跑脚本。
只要有mysql客户端即可,使用MariaDB的客户端也可以,如下:
1mysql -uroot -p -P3306 -s -f < DB_StarRocks_HC_lhr_v7.0.0.sql > lhr_StarRocks_check.html
和PostgreSQL数据库相似,需要有psql客户端,运行方式如下:
1psql -U mxadmin -h 192.168.8.8 -p 64340 -d postgres -W -H -f D:\DB_YMatrix_HC_lhr_v7.0.0.sql > d:\lhr_YMatrix_check.html
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
需要有yasql客户端,运行方式如下:
1 yasql / as sysdba -f DB_YashanDB_HC_lhr_v7.0.0.sql > /dev/null
输入密码,回车即可。
注意:
1、该脚本的字符集为utf8,请使用utf8格式打开该文件。
请看视频《小麦苗数据库健康检查脚本使用说明.wmv》或阅读《【DB健康巡检(Oracle+MySQL+MSSQL+OS)】小麦苗巡检脚本使用说明_LHR.pdf》,下载地址为:https://share.weiyun.com/5lb2U2M 。
视频观看地址:https://www.bilibili.com/video/BV1K54y1U7CE
小麦苗编写的该巡检系统已申请“中华人民共和国国家版权局计算机软件著作权登记证书”,请购买的朋友不要随意传播,否则将追究法律责任,并且收回脚本,不再提供免费更新,谢谢。
相关证书见下图:
对于小的bug更新不再此列出,直接修改脚本:
1、2015.10月推出Oracle巡检脚本,中间经过N次更新,2018.12.06更新一次,支持12c
2、2019.07.02重大更新,添加了10g、11g、12c版本的只读版本
3、2019.07.10加上了OS信息的收集
4、2019.07.12加上了对MySQL数据库的巡检
5、2019.09.24对Oracle的展示做了优化,修改了个别内容
6、2020.09.30加上了对SQL Server数据库的巡检
7、2020.12.16加上了对PostgreSQL数据库的巡检
8、2021.10.13加上了对达梦数据库的巡检
9、2021.10.18加上了对TiDB数据库的巡检
10、2021.10.23加上了对TiDB数据库的巡检
11、2021.10.29加上了对db2数据库的巡检
12、2021.10.31加上了对OceanBase数据库的巡检,并且去掉了MySQL和TiDB之前只能在Linux上运行的限制
13、2022.3.8加上了对Greenplum数据库的巡检
14、2022.3.28加上了对人大金仓KES数据库的巡检
15、2022.4.8加上了对万里数据库GreatDB的巡检
16、2022.4.11加上了对TDSQL_for_PG(原 TBase)数据库的巡检
17、2022.4.18加上了对MogDB数据库的巡检
18、2022.4.20加上了对OushuDB数据库的巡检
19、2022.4.21加上了对TDSQL_for_PG数据库的巡检
20、2022.4.22加上了对PolarDB_for_PG数据库的巡检
21、2023.3.6加上了对南大通用GBase 8a数据库的巡检
22、2023.3.18加上了对南大通用GBase 8a数据库的巡检
23、2023.3.29加上了对StarRocks数据库的巡检
24、2023.4.6加上了对YMatrix数据库的巡检
25、2023.7.6加上了对人大金仓KADB数据库的巡检
26、2023.11.21加上了对崖山YashanDB数据库的巡检
目前售价99元,包括Oracle + MySQL + SQL Server + PostgreSQL + Greenplum + 达梦 + 人大金仓(KES、KADB) + 万里GreatDB + OceanBase + TiDB + openGauss + TDSQL_for_PG(原 TBase) + DB2 + MogDB + OushuDB + PolarDB_for_PG + 神舟通用 + 南大通用GBase(8a、8c) + OS + StarRocks + YMatrix + YashanDB
的脚本,可以巡检21种数据库,后续免费优化,加量不加价,支持以下购买方式:
1、微信红包,请加我微信:db_bao,或用微信扫描以下二维码加麦老师微信:
2、QQ红包,请加我QQ:646634621,或用QQ扫以下二维码加我QQ:
3、微店购买连接:https://k.weidian.com/o5iECboc
我的微店的二维码如下所示:
1、该脚本系列不讲价,不答疑,不解惑。若不会使用,请参考本文的脚本运行方式;若还不会使用请付费答疑,参考:https://www.xmmup.com/xiaomaimiaoshujukuchengjieyewujieshao.html#fu_fei_zi_xun_ye_wu
2、99元包括所有脚本吗?答:是的,99元包括数据库巡检所有脚本,且免费更新!!!
3、脚本支持单个脚本售卖吗?答:支持,可以只买Oracle,或只买MySQL脚本等等,单个脚本售价20元,不讲价,且不支持免费更新!!!
4、乱码问题,请自行解决。可以考虑配置变量或修改sql文件的编码格式为UTF8(在windows上,新建一个utf8格式的文件,然后复制粘贴即可)。例如,Oracle或达梦的乱码问题,若实在解决不了,请在Windows环境下的客户端上跑吧。最后若还不行,可以使用付费答疑,参考:https://www.xmmup.com/xiaomaimiaoshujukuchengjieyewujieshao.html#fu_fei_zi_xun_ye_wu
5、除了Oracle有针对特定版本的脚本外,其它数据库都没有针对某个版本的脚本。所以,不同数据库的版本,运行可能会有个别错误显示在界面上(例如某个视图不存在等问题,例如MySQL、PG、GreenPlum等数据库脚本),但是,不会影响最终html的格式效果!参考:https://www.xmmup.com/mysqlshujukuxunjianjiaoben.html#zhu_yi
6、脚本放在腾讯的微云里,下载的时候别用迅雷,也别打包下载,否则下载不了或下载完成后用不了,请单个文件下载,或转存到自己的微云里用微云客户端下载!!!若微云(https://www.weiyun.com、http://share.weiyun.com)访问不了,则肯定是你的DNS的问题,请修改为114.114.114.114
再尝试,或关闭360等杀毒软件,或用DNS修复器修复DNS。
7、脚本里的个人信息或跑马灯信息是可以修改的,自己使用文本工具打开脚本,搜索相关内容进行替换即可。
8、后续更新怎么获取?答:购买后会发一个下载地址,后期更新也会在该地址,自己自行下载更新脚本即可。注意:购买单个脚本不支持免费更新。
9、何时更新?答:请关注麦老师朋友圈或公众号(DB宝),会进行通知。