PostgreSQL数据库巡检脚本说明
1、PG数据库运行方式
需要有psql客户端,运行方式如下:
psql -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:\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: No function matches the given name and argument types. You might need to add 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 not open 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 ;
^
2、html巡检结果
这里只列出部分结果,完整示例请参考: PostgreSQL数据库巡检结果示例
其它的详细内容可以参考:https://share.weiyun.com/FQY9zcm0