# 28.1.标准Unix工具
在大多数Unix平台上,PostgreSQL修改其命令标题,如附言
,这样就可以很容易地识别各个服务器进程。下面是一个示例展示
$ ps auxww | grep ^postgres
postgres 15551 0.0 0.1 57536 7132 pts/0 S 18:02 0:00 postgres -i
postgres 15554 0.0 0.0 57536 1184 ? Ss 18:02 0:00 postgres: background writer
postgres 15555 0.0 0.0 57536 916 ? Ss 18:02 0:00 postgres: checkpointer
postgres 15556 0.0 0.0 57536 916 ? Ss 18:02 0:00 postgres: walwriter
postgres 15557 0.0 0.0 58504 2244 ? Ss 18:02 0:00 postgres: autovacuum launcher
postgres 15558 0.0 0.0 17512 1068 ? Ss 18:02 0:00 postgres: stats collector
postgres 15582 0.0 0.0 58772 3080 ? Ss 18:04 0:00 postgres: joe runbug 127.0.0.1 idle
postgres 15606 0.0 0.0 58772 3052 ? Ss 18:07 0:00 postgres: tgl regression [local] SELECT waiting
postgres 15610 0.0 0.0 58772 3056 ? Ss 18:07 0:00 postgres: tgl regression [local] idle in transaction
(适当引用附言
在不同的平台上有所不同,显示的细节也是如此。这个例子来自最近的一个Linux系统。)这里列出的第一个进程是主服务器进程。为其显示的命令参数与启动时使用的参数相同。接下来的五个进程是由主进程自动启动的后台工作进程。(如果您已将系统设置为不启动统计数据采集器,“统计数据采集器”进程将不存在;同样,“自动真空发射器”进程也可以被禁用。)其余的每个进程都是一个服务器进程,处理一个客户端连接。每个这样的进程都在表单中设置其命令行显示
postgres: user database host activity
用户、数据库和(客户端)主机项在客户端连接的生命周期内保持不变,但活动指示符会发生变化。活动可以是闲置的
(即等待客户端命令),闲置交易
(在房间里等待客户)开始
块)或命令类型名称,例如选择
而且等待
如果服务器进程当前正在等待另一个会话持有的锁,则会追加。在上面的示例中,我们可以推断流程15606正在等待流程15610完成其事务,从而释放一些锁。(进程15610必须是阻止程序,因为没有其他活动会话。在更复杂的情况下,有必要调查pg_锁
系统视图,以确定谁在阻止谁。)
如果簇_名称已配置群集名称也将显示在中附言
输出:
$ psql -c 'SHOW cluster_name'
cluster_name
### Tip
Solaris requires special handling. You must use `/usr/ucb/ps`, rather than `/bin/ps`. You also must use two `w` flags, not just one. In addition, your original invocation of the `postgres` command must have a shorter `ps` status display than that provided by each server process. If you fail to do all three things, the `ps` output for each server process will be the original `postgres` command line.