{"id":96922,"date":"2024-10-20T13:29:15","date_gmt":"2024-10-20T05:29:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/96922\/"},"modified":"2024-10-20T13:29:15","modified_gmt":"2024-10-20T05:29:15","slug":"postgresql%e6%97%a5%e8%aa%8c%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7-pgbadger","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/96922\/","title":{"rendered":"PostgreSQL\u65e5\u8a8c\u5206\u6790\u5de5\u5177\u2014\u2014pgBadger"},"content":{"rendered":"<h1 id=\"postgresql%e6%97%a5%e8%aa%8c%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7-pgbadger-mKKQDFacce\">PostgreSQL\u65e5\u8a8c\u5206\u6790\u5de5\u5177\u2014\u2014pgBadger<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u5c0d\u65bc\u4f01\u696d\u7684\u904b\u71df\u81f3\u95dc\u91cd\u8981\u3002PostgreSQL\u4f5c\u70ba\u4e00\u500b\u5f37\u5927\u7684\u958b\u6e90\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u5834\u666f\u3002\u7136\u800c\uff0c\u96a8\u8457\u6578\u64da\u91cf\u7684\u589e\u9577\u548c\u7528\u6236\u8acb\u6c42\u7684\u589e\u52a0\uff0c\u5982\u4f55\u6709\u6548\u5730\u76e3\u63a7\u548c\u5206\u6790\u6578\u64da\u5eab\u7684\u65e5\u8a8c\u6210\u70ba\u4e86\u4e00\u500b\u91cd\u8981\u7684\u8ab2\u984c\u3002\u9019\u6642\uff0cpgBadger\u4f5c\u70ba\u4e00\u6b3e\u9ad8\u6548\u7684PostgreSQL\u65e5\u8a8c\u5206\u6790\u5de5\u5177\uff0c\u4fbf\u61c9\u904b\u800c\u751f\u3002<\/p>\n<h2 id=\"pgbadger%e7%b0%a1%e4%bb%8b-mKKQDFacce\">pgBadger\u7c21\u4ecb<\/h2>\n<p>pgBadger\u662f\u4e00\u6b3e\u7528\u65bc\u5206\u6790PostgreSQL\u65e5\u8a8c\u7684\u5de5\u5177\uff0c\u80fd\u5920\u751f\u6210\u8a73\u7d30\u7684\u5831\u544a\uff0c\u5e6b\u52a9\u7528\u6236\u4e86\u89e3\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u4f7f\u7528\u60c5\u6cc1\u3002\u5b83\u4ee5\u5176\u9ad8\u6548\u7684\u6027\u80fd\u548c\u6613\u7528\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u7684\u9752\u775e\u3002pgBadger\u652f\u6301\u591a\u7a2e\u65e5\u8a8c\u683c\u5f0f\uff0c\u5305\u62ec\u6a19\u6e96\u7684PostgreSQL\u65e5\u8a8c\u683c\u5f0f\u548cCSV\u683c\u5f0f\uff0c\u4e26\u80fd\u5920\u5feb\u901f\u89e3\u6790\u5927\u91cf\u7684\u65e5\u8a8c\u6578\u64da\u3002<\/p>\n<h2 id=\"pgbadger%e7%9a%84%e4%b8%bb%e8%a6%81%e7%89%b9%e6%80%a7-mKKQDFacce\">pgBadger\u7684\u4e3b\u8981\u7279\u6027<\/h2>\n<ul>\n<li><strong>\u9ad8\u6548\u6027\uff1a<\/strong>pgBadger\u80fd\u5920\u5feb\u901f\u8655\u7406\u5927\u91cf\u7684\u65e5\u8a8c\u6587\u4ef6\uff0c\u4e26\u751f\u6210\u5831\u544a\uff0c\u9019\u5c0d\u65bc\u5927\u578b\u6578\u64da\u5eab\u5c24\u70ba\u91cd\u8981\u3002<\/li>\n<li><strong>\u8a73\u7d30\u5831\u544a\uff1a<\/strong>\u751f\u6210\u7684\u5831\u544a\u5305\u62ec\u67e5\u8a62\u6027\u80fd\u3001\u932f\u8aa4\u7d71\u8a08\u3001\u9023\u63a5\u6578\u91cf\u7b49\u591a\u65b9\u9762\u7684\u4fe1\u606f\uff0c\u5e6b\u52a9\u7528\u6236\u5168\u9762\u4e86\u89e3\u6578\u64da\u5eab\u7684\u904b\u884c\u72c0\u6cc1\u3002<\/li>\n<li><strong>\u53ef\u8996\u5316\u5716\u8868\uff1a<\/strong>\u5831\u544a\u4e2d\u5305\u542b\u591a\u7a2e\u53ef\u8996\u5316\u5716\u8868\uff0c\u4fbf\u65bc\u7528\u6236\u76f4\u89c0\u5730\u7406\u89e3\u6578\u64da\u3002<\/li>\n<li><strong>\u652f\u6301\u591a\u7a2e\u65e5\u8a8c\u683c\u5f0f\uff1a<\/strong>pgBadger\u652f\u6301\u591a\u7a2ePostgreSQL\u65e5\u8a8c\u683c\u5f0f\uff0c\u9748\u6d3b\u6027\u5f37\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%9dpgbadger-mKKQDFacce\">\u5982\u4f55\u5b89\u88ddpgBadger<\/h2>\n<p>\u5b89\u88ddpgBadger\u975e\u5e38\u7c21\u55ae\uff0c\u4ee5\u4e0b\u662f\u57fa\u672c\u7684\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo apt-get install pgbadger<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u751f\u6210\u5831\u544a\uff1a<\/p>\n<pre><code>pgbadger \/path\/to\/postgresql.log -o report.html<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u6703\u5206\u6790\u6307\u5b9a\u7684\u65e5\u8a8c\u6587\u4ef6\u4e26\u751f\u6210\u4e00\u500b\u540d\u70bareport.html\u7684\u5831\u544a\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8pgbadger%e9%80%b2%e8%a1%8c%e6%97%a5%e8%aa%8c%e5%88%86%e6%9e%90-mKKQDFacce\">\u4f7f\u7528pgBadger\u9032\u884c\u65e5\u8a8c\u5206\u6790<\/h2>\n<p>\u4f7f\u7528pgBadger\u9032\u884c\u65e5\u8a8c\u5206\u6790\u7684\u904e\u7a0b\u76f8\u5c0d\u7c21\u55ae\u3002\u9996\u5148\uff0c\u78ba\u4fddPostgreSQL\u7684\u65e5\u8a8c\u8a2d\u7f6e\u6b63\u78ba\uff0c\u7136\u5f8c\u5b9a\u671f\u904b\u884cpgBadger\u4f86\u751f\u6210\u5831\u544a\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u5206\u6790\u6307\u6a19\uff1a<\/p>\n<ul>\n<li><strong>\u67e5\u8a62\u6027\u80fd\uff1a<\/strong>pgBadger\u80fd\u5920\u986f\u793a\u6700\u8017\u6642\u7684\u67e5\u8a62\uff0c\u5e6b\u52a9\u7528\u6236\u512a\u5316\u6578\u64da\u5eab\u6027\u80fd\u3002<\/li>\n<li><strong>\u932f\u8aa4\u7d71\u8a08\uff1a<\/strong>\u5831\u544a\u4e2d\u6703\u5217\u51fa\u6240\u6709\u932f\u8aa4\u4fe1\u606f\uff0c\u4fbf\u65bc\u7528\u6236\u53ca\u6642\u8655\u7406\u554f\u984c\u3002<\/li>\n<li><strong>\u9023\u63a5\u6578\u91cf\uff1a<\/strong>\u7528\u6236\u53ef\u4ee5\u67e5\u770b\u7576\u524d\u7684\u9023\u63a5\u6578\u91cf\uff0c\u5e6b\u52a9\u9032\u884c\u8cc7\u6e90\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-mKKQDFacce\">\u7d50\u8ad6<\/h2>\n<p>pgBadger\u4f5c\u70ba\u4e00\u6b3e\u5f37\u5927\u7684PostgreSQL\u65e5\u8a8c\u5206\u6790\u5de5\u5177\uff0c\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u6df1\u5165\u4e86\u89e3\u6578\u64da\u5eab\u7684\u904b\u884c\u72c0\u6cc1\uff0c\u5f9e\u800c\u9032\u884c\u6709\u6548\u7684\u6027\u80fd\u512a\u5316\u548c\u554f\u984c\u6392\u67e5\u3002\u7121\u8ad6\u662f\u5927\u578b\u4f01\u696d\u9084\u662f\u4e2d\u5c0f\u578b\u696d\u52d9\uff0cpgBadger\u90fd\u80fd\u63d0\u4f9b\u6709\u50f9\u503c\u7684\u6578\u64da\u652f\u6301\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u904b\u884c\u60a8\u7684PostgreSQL\u6578\u64da\u5eab\uff0c\u4e26\u5229\u7528pgBadger\u9032\u884c\u65e5\u8a8c\u5206\u6790\uff0c\u9019\u5c07\u6709\u52a9\u65bc\u63d0\u5347\u60a8\u7684\u696d\u52d9\u904b\u71df\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pgBadger is a powerful PostgreSQL log analyzer that generates detailed reports and visualizations, helping optimize database performance and troubleshoot issues.<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-96922","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=96922"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96922\/revisions"}],"predecessor-version":[{"id":96923,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96922\/revisions\/96923"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=96922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=96922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=96922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}