[root@dbserver tmp]# netstat -nap |grep postgres
tcp 0 0 0.0.0.0:7432 0.0.0.0:* LISTEN 64287/postgres
tcp6 0 0 :::7432 :::* LISTEN 64287/postgres
udp6 0 0 ::1:61020 ::1:61020 ESTABLISHED 64287/postgres
unix 2 [ ACC ] STREAM LISTENING 491548 64287/postgres /tmp/.s.PGSQL.7432
unix 3 [ ] STREAM CONNECTED 514748 74729/postgres: pg1 /tmp/.s.PGSQL.7432 --->>注意此处74729号进程。
[root@dbserver tmp]# ps -ef |grep postgres
pg12bt2 64287 1 0 18:33 ? 00:00:00 /home/pg12bt2/pg12bt2bin/bin/postgres
pg12bt2 64292 64287 0 18:33 ? 00:00:00 postgres: checkpointer
pg12bt2 64293 64287 0 18:33 ? 00:00:00 postgres: background writer
pg12bt2 64294 64287 0 18:33 ? 00:00:00 postgres: walwriter
pg12bt2 64295 64287 0 18:33 ? 00:00:00 postgres: autovacuum launcher
pg12bt2 64296 64287 0 18:33 ? 00:00:00 postgres: stats collector
pg12bt2 64297 64287 0 18:33 ? 00:00:00 postgres: logical replication launcher
pg12bt2 74728 74686 0 21:19 pts/0 00:00:00 psql -d postgres
pg12bt2 74729 64287 0 21:19 ? 00:00:00 postgres: pg12bt2 postgres [local] idle --->>注意此处74729号进程。
root 82998 74746 0 23:38 pts/4 00:00:00 grep --color=auto postgres
[root@dbserver tmp]#
参考:
https://access.redhat.com/solutions/442393
The -nap options are a very useful combination to see All connections (local socket and tcp/udp),
the PID/Program name, and Numeric address instead of DNS name.
Looking up network names slows the query considerably, particularly if there are problems with DNS.
The options -t and -u can be used instead of -a to view only TCP and/or UDP connections.
These options are explained from the man page (man netstat) as:
--numeric , -n
Show numerical addresses instead of trying to determine symbolic host, port or user names.
-a, --all
Show both listening and non-listening (for TCP this means established connections) sockets.
With the --interfaces option, show interfaces that are not up
-p, --program
Show the PID and name of the program to which each socket belongs.