Debian下PostgreSQL日志分析方法如下:
/var/log/postgresql/
目录,文件名如postgresql-{版本号}-main.log
。tail -f
实时查看、grep
搜索关键字)。less
)直接打开。ERROR
、FATAL
等级别日志,定位问题。log_min_duration_statement
参数记录慢查询,结合EXPLAIN
分析执行计划。pgbadger /path/to/logs -o report.html
即可。logrotate
)避免文件过大。参考资料: