explain postmaster.pid

今天我们部门内部的数据库讲座, 提到了postmaster.pid这个文件, 我以前并没有仔细的去查看它每一行的含义.
刚好今天有机会查了一下源码, 再加上三个臭皮匠赛过一个诸葛亮. 终于把每一行的意思给搞明白了.
先来看一个postmaster.pid文件的内容 : 
cat postmaster.pid

2551
/pgdata/digoal/1921/data02/pg_root
1331803654
1921
/pgdata/digoal/1921/data02/pg_root
0.0.0.0
  1921001   6127619

我一行一行来解释 : 
2551 postgres主进程的PID

ps -ewf|grep 2551
postgres  2551     1  0 17:27 ?        00:00:00 /opt/pgsql/bin/postgres
postgres  2552  2551  0 17:27 ?        00:00:00 postgres: logger process   
postgres  2554  2551  0 17:27 ?        00:00:00 postgres: writer process   
postgres  2555  2551  0 17:27 ?        00:00:00 postgres: wal writer process   
postgres  2556  2551  0 17:27 ?        00:00:00 postgres: autovacuum launcher process   
postgres  2557  2551  0 17:27 ?        00:00:00 postgres: archiver process   
postgres  2558  2551  0 17:27 ?        00:00:00 postgres: stats collector process   


/pgdata/digoal/1921/data02/pg_root
数据目录.

1331803654
这行是这个文件创建的时间转换成epoch. 我一开始一直以为是pg_postmaster_start_time获得的时间.如果你发现不对的话就去看看postmaster.pid的文件创建时间吧.

digoal=# select pg_postmaster_start_time();
   pg_postmaster_start_time    
-------------------------------
 2012-03-15 17:27:34.416047+08
(1 row)
digoal=# select extract(epoch from '2012-03-15 17:27:34'::timestamp);  
date_part  
------------  
1331803654 
(1 row)

虽然上面的postmaster时间和这个文件的创建时间一致, 但它其实是这个文件的创建时间.

stat postmaster.pid  

File: `postmaster.pid'  

Size: 119 Blocks: 8 IO Block: 4096  

regular file Device: fd03h/64771d Inode: 1572868 Links: 1 

Access: (0600/-rw-------)  

Uid: ( 500/postgres)  

Gid: ( 500/postgres) 

Access: 2012-03-15 17:41:10.416810701 +0800 

Modify: 2012-03-15 17:27:34.364810701 +0800 

Change: 2012-03-15 17:27:34.364810701 +0800


1921 数据库监听端口. 在postgresql.conf中对应 port = 1921
 
/pgdata/digoal/1921/data02/pg_root 是unix socket的监听目录. 在postgresql.conf中对应 unix_socket_directory = '/pgdata/digoal/1921/data02/pg_root'

0.0.0.0 数据库监听地址, 对应 postgresql.conf 的 listen_addresses = '0.0.0.0'

最后一行对应的是共享内存的地址(shared memory segments中的key和shmid).
  1921001   6127619

ipcs  
------ Shared Memory Segments -------- 
key shmid owner perms bytes nattch status  
0x001d4fe9 6127619 postgres 600 617250816 4

postmaster.pid显示的是key转成10进制后的数字.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值