本篇內(nèi)容主要講解“PostgreSQL 12在日志記錄上的改進是什么”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“PostgreSQL 12在日志記錄上的改進是什么”吧!
創(chuàng)新互聯(lián)于2013年成立,先為班瑪?shù)确?wù)建站,班瑪?shù)鹊仄髽I(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為班瑪企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
對于每一個客戶端連接,PG都會請求Postmaster,然后fork一個后臺進程來處理請求,Postmaster期望每一個客戶端請求發(fā)送startup message給PG Server,startup packet中的信息用于配置fork的后臺進程。對于端口掃描、HA解決方案中的心跳檢測等等都會發(fā)請求給PG Server port,PG會啟動進程來處理這些連接,但安全檢測、HA腳本等不同于常規(guī)的客戶端,對于這些請求,PG會產(chǎn)生一條日志條目,因此會造成日志文件的膨脹而導(dǎo)致不必要的IO開銷。
PG 11
使用工具nc來訪問數(shù)據(jù)庫端口,日志中會產(chǎn)生無用的日志條目。
[xdb@localhost ~]$ psql -c 'select version();' Timing is on. Expanded display is used automatically. version --------------------------------------------------------------------------------------------------------- PostgreSQL 11.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit (1 row) Time: 56.253 ms [xdb@localhost ~]$ [xdb@localhost ~]$ for i in {1..100}; do nc -zv localhost 5110 ; done Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5110. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5110. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5110. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5110. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. ...
數(shù)據(jù)庫日志輸出
2019-12-09 14:35:55.468 CST,,,16065,"::1:57554",5dedeb4b.3ec1,1,"",2019-12-09 14:35:55 CST,,0,LOG,08P01,"incomplete startup packet",,,,,,,,,"" 2019-12-09 14:35:55.479 CST,,,16067,"::1:57556",5dedeb4b.3ec3,1,"",2019-12-09 14:35:55 CST,,0,LOG,08P01,"incomplete startup packet",,,,,,,,,"" 2019-12-09 14:35:55.490 CST,,,16069,"::1:57558",5dedeb4b.3ec5,1,"",2019-12-09 14:35:55 CST,,0,LOG,08P01,"incomplete startup packet",,,,,,,,,"" 2019-12-09 14:35:55.503 CST,,,16071,"::1:57560",5dedeb4b.3ec7,1,"",2019-12-09 14:35:55 CST,,0,LOG,08P01,"incomplete startup packet",,,,,,,,,"" 2019-12-09 14:35:55.513 CST,,,16073,"::1:57562",5dedeb4b.3ec9,1,"",2019-12-09 14:35:55 CST,,0,LOG,08P01,"incomplete startup packet",,,,,,,,,"" ...
這些日志其實是無用的日志信息,可以不作記錄。
PG 12
[xdb@localhost ~]$ psql -h localhost -p 5120 -U pg12 -c 'select version();' Timing is on. Expanded display is used automatically. version --------------------------------------------------------------------------------------------------------- PostgreSQL 12.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit (1 row) Time: 60.207 ms [xdb@localhost ~]$ [xdb@localhost ~]$ for i in {1..100}; do nc -zv localhost 5120 ; done Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5120. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5120. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5120. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5120. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to ::1:5120. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds. [xdb@localhost ~]$ ...
數(shù)據(jù)庫日志信息,相對于PG 11,沒有出現(xiàn)無用的日志信息
[pg12@localhost ~]$ tail -f $PGDATA/pg_log/postgresql-2019-12-09.log 2019-12-09 14:18:59.317 CST [1813] LOG: ending log output to stderr 2019-12-09 14:18:59.317 CST [1813] HINT: Future log output will go to log destination "csvlog".
到此,相信大家對“PostgreSQL 12在日志記錄上的改進是什么”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!