pgbadger 慢日誌分析工具
測試作業系統:Centos 7.6
測試IP :192.168.112.88
作業系統安裝資訊:最小化安裝
下載地址:
https://github.com/dalibo/pgbadger
https://pgbadger.darold.net/
Official releases:
Official release are published to the GitHub Release page of pgBadger.
Not all release are subject to a notification sent to the pgsql-announce mailling list, this is reserved to the main releases.
Binary packages:
pgBadger may have a binary package corresponding to your distribution. For RPM packages, thanks to the great work of Devrim GÜNDÜZ, you can find the pgBadger package at the PostgreSQL yum repository
Thanks to Christoph BERG packages for Debian and Ubuntu are available in the PostgreSQL apt repository
Development code:
The latest development code can always be found into the pgBadger's GitHub repository
這裡我們選擇 Official releases 下載.
1.解壓檔案.
unzip pgbadger-11.3.zip
2.安裝 perl 以及依賴
yum install perl perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-CPAN
3.安裝pgbadger
3.1 使用編譯的方式進行安裝
[root@PGHOST pgbadger-11.3]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for pgBadger
[root@PGHOST pgbadger-11.3]# make && make install
3.2 使用rpm包方式進行安裝(未測試)
yum install xx.rpm 即可
4.檢視幫助資訊
[root@PGHOST pgbadger-11.3]# ./pgbadger --help
Usage: pgbadger [options] logfile [...]
PostgreSQL log analyzer with fully detailed reports and graphs.
Arguments:
logfile can be a single log file, a list of files, or a shell command
returning a list of files. If you want to pass log content from stdin
use - as filename. Note that input from stdin will not work with csvlog.
Options:
-a | --average minutes : number of minutes to build the average graphs of
queries and connections. Default 5 minutes.
-A | --histo-average min: number of minutes to build the histogram graphs
of queries. Default 60 minutes.
-b | --begin datetime : start date/time for the data to be parsed in log
(either a timestamp or a time)
-c | --dbclient host : only report on entries for the given client host.
-C | --nocomment : remove comments like /* ... */ from queries.
-d | --dbname database : only report on entries for the given database.
-D | --dns-resolv : client ip addresses are replaced by their DNS name.
Be warned that this can really slow down pgBadger.
-e | --end datetime : end date/time for the data to be parsed in log
(either a timestamp or a time)
5.資料庫引數配置
log_destination='csvlog'
logging_collector=on
log_rotation_age=1d
log_rotation_size=128MB
log_min_duration_statement = 0
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0
log_error_verbosity = default
[postgres@PGHOST data]$ pg_ctl reload
server signaled
6.日誌生成html報告
[root@PGHOST log]# pgbadger *.csv -o test.html -f stderr
7.安裝httpd(可在不同機器,後期通過scp或者ftp方式上傳html檔案即可)
[root@PGHOST yum.repos.d]# yum install httpd
[root@PGHOST yum.repos.d]# chkconfig httpd on
[root@PGHOST yum.repos.d]# systemctl start httpd
[root@PGHOST html]# systemctl stop firewalld
[root@PGHOST html]# systemctl disable firewalld
[root@PGHOST log]# cp test.html /var/www/html/
檢視
http://192.168.112.88/test.html
頁面顯示正常.
8.部署pgbadger 定期執行指令碼
cat pgbadger_run.sh
#!/bin/bash
source ~/.bash_profile
/u01/pgbadger-11.3/pgbadger /pgsoft/data/log/*.csv -o /var/www/html/test.html
crontab -l
0 */1 * * * root /u01/pgbadger_run.sh
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7569309/viewspace-2725181/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PostgreSQL DBA(3) - 日誌分析工具pgbadger簡介SQL
- Mysql 慢日誌分析工具MysqldumpslowMySql
- mysql慢查詢日誌分析工具使用MySql
- Mysql慢查詢日誌分析工具mysqlslaMySql
- mysql分析慢查詢日誌工具mysqlsla安裝MySql
- 分析mysql慢查詢日誌的好工具--mysqlslaMySql
- 慢查詢日誌開啟分析
- mysqlsla 分析mysql慢查詢日誌MySql
- 【MySql】 慢日誌查詢工具之mysqlslaMySql
- 【pt系列】MySQL慢日誌分析工具pt-query-digest使用、報告分析MySql
- redis慢日誌Redis
- 關於MySQL 通用查詢日誌和慢查詢日誌分析MySql
- mongodb 日誌分析工具mtoolsMongoDB
- MongoDB 日誌分析工具 mtoolsMongoDB
- 日誌分析工具 Log Parser
- nginx日誌分析工具goaccessNginxGo
- mysql慢查詢和錯誤日誌分析MySql
- MySQL優化 - 開啟MySQL慢查詢日誌及分析工具mysqldumpslowMySql優化
- PHP慢指令碼日誌和Mysql的慢查詢日誌PHP指令碼MySql
- 【MySql】mysql 慢日誌查詢工具之mysqldumpslowMySql
- 2.4慢操作日誌
- 對 MySQL 慢查詢日誌的簡單分析MySql
- 日誌分析-apache日誌分析Apache
- 【工具】利用python 傳送MySQL 慢日誌郵件PythonMySql
- MySQL慢日誌全解析MySql
- mysql開啟慢日誌MySql
- MySQL:慢查詢日誌MySql
- MySQL慢日誌優化MySql優化
- mysql 鎖的慢日誌MySql
- 使用慢查詢日誌
- mysql慢查詢日誌MySql
- MySQL慢日誌功能分析及優化增強MySql優化
- LogMiner日誌分析工具說明
- mysql5.7 慢日誌配置MySql
- 慢查詢日誌的管理
- 最好用的開源日誌分析工具
- MySQL 慢查詢日誌——讓“慢”無所遁形MySql
- [日誌分析篇]-利用ELK分析jumpserver日誌-日誌拆分篇Server