您好,登錄后才能下訂單哦!
本篇內容主要講解“PostgreSQL 12在日志記錄上的改進是什么”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“PostgreSQL 12在日志記錄上的改進是什么”吧!
對于每一個客戶端連接,PG都會請求Postmaster,然后fork一個后臺進程來處理請求,Postmaster期望每一個客戶端請求發送startup message給PG Server,startup packet中的信息用于配置fork的后臺進程。對于端口掃描、HA解決方案中的心跳檢測等等都會發請求給PG Server port,PG會啟動進程來處理這些連接,但安全檢測、HA腳本等不同于常規的客戶端,對于這些請求,PG會產生一條日志條目,因此會造成日志文件的膨脹而導致不必要的IO開銷。
PG 11
使用工具nc來訪問數據庫端口,日志中會產生無用的日志條目。
[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. ...
數據庫日志輸出
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 ~]$ ...
數據庫日志信息,相對于PG 11,沒有出現無用的日志信息
[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在日志記錄上的改進是什么”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。