由于一堆奇怪的跟踪文件不断写入系统日志,我试图禁用 Postgres 侦听 IPv6。
我不想在操作系统本身中禁用 IPv6,因此在看到提及跟踪消息并找到博客文章Disable IPv6 Postgres 和 PGBouncer 后,我已按照第 2 步进行更新postgresql.conf(将“*”更改为“0.0.0.0 ”):
# grep listen postgresql.conf
listen_addresses = '0.0.0.0'
Run Code Online (Sandbox Code Playgroud)
我也在里面找到了这个条目pg_hba.conf并注释掉了它:
# IPv6 local connections:
#host all all ::1/128 trust
Run Code Online (Sandbox Code Playgroud)
我重新启动了 Postgres。netstat似乎表明它不再监听 IPv6:
# netstat -ntl | grep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
Run Code Online (Sandbox Code Playgroud)
似乎lsof有不同的想法:
# lsof -i6 | grep postgres
postmaste 37921 postgres 8u IPv6 39125550 0t0 UDP
localhost:38892->localhost:38892
postmaste 37944 postgres 8u IPv6 39125550 0t0 UDP …Run Code Online (Sandbox Code Playgroud)