大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇内容主要讲解“PostgreSQL 12在日志记录上的改进是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“PostgreSQL 12在日志记录上的改进是什么”吧!
创新互联于2013年成立,先为班玛等服务建站,班玛等地企业,进行企业商务咨询服务。为班玛企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
对于每一个客户端连接,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在日志记录上的改进是什么”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!