消失的postmaster进程

3/7/2017来源:SQL技巧人气:603

, 之前看<<PostgreSQL数据库内核分析>>这本书,提到了postmaster进程, 于是在我安装的PG 9.6.0中,ps -ef了一把,结果没找到,如下:
[postgres@rhel73 global]$ pwd
/usr/local/pgsql/data/global
[postgres@rhel73 global]$ ps -ef | grep -i  post
root      2220     1  0 03:43 ?        00:00:00 /usr/libexec/postfix/master -w
postfix   2222  2220  0 03:43 ?        00:00:00 qmgr -l -t unix -u
root      2549  2501  0 03:48 pts/0    00:00:00 su - postgres
postgres  2550  2549  0 03:48 pts/0    00:00:00 -bash
postgres  2632     1  0 03:51 pts/0    00:00:00 /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data--->>>只有这个.
postgres  2634  2632  0 03:51 ?        00:00:00 postgres: checkpointer PRocess   
postgres  2635  2632  0 03:51 ?        00:00:00 postgres: writer process   
postgres  2636  2632  0 03:51 ?        00:00:00 postgres: wal writer process   
postgres  2637  2632  0 03:51 ?        00:00:00 postgres: autovacuum launcher process   
postgres  2638  2632  0 03:51 ?        00:00:00 postgres: stats collector process   
postgres  7255  2550  0 12:03 pts/0    00:00:00 ps -ef
postgres  7256  2550  0 12:03 pts/0    00:00:00 grep --color=auto -i post
[postgres@rhel73 global]$ ps -ef | grep mast
root      2220     1  0 03:43 ?        00:00:00 /usr/libexec/postfix/master -w
postgres  7638  2550  0 12:46 pts/0    00:00:00 grep --color=auto mast
[postgres@rhel73 global]$ ps -ef | grep master
root      2220     1  0 03:43 ?        00:00:00 /usr/libexec/postfix/master -w
postgres  7640  2550  0 12:46 pts/0    00:00:00 grep --color=auto master
[postgres@rhel73 global]$ 
[postgres@rhel73 global]$ 
[postgres@rhel73 global]$ 
[postgres@rhel73 global]$ which postmaster
/usr/local/pgsql/bin/postmaster
[postgres@rhel73 global]$ 
[postgres@rhel73 global]$ 
[postgres@rhel73 global]$ cd ..
[postgres@rhel73 data]$ ls -lrt
total 56
-rw-------. 1 postgres postgres     4 Feb 28 07:57 PG_VERSION
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_twophase
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_tblspc
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_stat
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_snapshots
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_serial
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_replslot
drwx------. 4 postgres postgres    36 Feb 28 07:57 pg_multixact
drwx------. 4 postgres postgres    39 Feb 28 07:57 pg_logical
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_dynshmem
drwx------. 2 postgres postgres     6 Feb 28 07:57 pg_commit_ts
-rw-------. 1 postgres postgres 22282 Feb 28 07:57 postgresql.conf
-rw-------. 1 postgres postgres    88 Feb 28 07:57 postgresql.auto.conf
-rw-------. 1 postgres postgres  1636 Feb 28 07:57 pg_ident.conf
-rw-------. 1 postgres postgres  4468 Feb 28 07:57 pg_hba.conf
drwx------. 3 postgres postgres    60 Feb 28 07:57 pg_xlog
drwx------. 2 postgres postgres    18 Feb 28 07:57 pg_subtrans
drwx------. 2 postgres postgres    18 Feb 28 07:57 pg_clog
drwx------. 6 postgres postgres    54 Feb 28 08:02 base
-rw-------. 1 postgres postgres    78 Mar  2 03:51 postmaster.pid
drwx------. 2 postgres postgres    18 Mar  2 03:51 pg_notify
-rw-------. 1 postgres postgres    59 Mar  2 03:51 postmaster.opts
drwx------. 2 postgres postgres  4096 Mar  2 03:51 global
drwx------. 2 postgres postgres    25 Mar  2 12:56 pg_stat_tmp
[postgres@rhel73 data]$ pwd
/usr/local/pgsql/data
[postgres@rhel73 data]$ cat postmaster.pid
2632
/usr/local/pgsql/data
1488444664
5432
/tmp
localhost
  5432001         0
[postgres@rhel73 data]$ ps -ef | grep 5432
postgres  7746  2550  0 12:57 pts/0    00:00:00 grep --color=auto 5432
[postgres@rhel73 data]$ 
[postgres@rhel73 data]$ 
[postgres@rhel73 data]$ 
[postgres@rhel73 data]$ cat postmaster.opts
/usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data"
[postgres@rhel73 data]$ pwd
/usr/local/pgsql/data
[postgres@rhel73 data]$ 


问了问公司的技术总监,结果是这样的:
postmaster is a deprecated alias of postgres.如上来自:
https://www.postgresql.org/docs/9.5/static/app-postmaster.html


结论是这样的:
PG9.5之前的postmaster进程实际上就是PG9.5及其以后版本中第一个启动的postgres进程,该进程的ospid(操作系统进程的进程号)在$PGDATA/下的postmaster.pid中有记录.