PostgreSQL进程结构

进程结构
查看进程
[root@node201 13325]# ps -ef | grep postgres
postgres 35292 1 0 20:48 ? 00:00:00 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
postgres 35294 35292 0 20:48 ? 00:00:00 postgres: logger process
postgres 35296 35292 0 20:48 ? 00:00:00 postgres: checkpointer process
postgres 35297 35292 0 20:48 ? 00:00:00 postgres: writer process
postgres 35298 35292 0 20:48 ? 00:00:00 postgres: wal writer process
postgres 35299 35292 0 20:48 ? 00:00:00 postgres: autovacuum launcher process
postgres 35300 35292 0 20:48 ? 00:00:14 postgres: stats collector process
postgres 35722 35292 0 20:56 ? 00:00:22 postgres: postgres postgres 192.168.8.2(60426) idle
postgres 35906 35292 0 21:00 ? 00:00:55 postgres: postgres xunlei 192.168.8.2(60544) idle
postgres 36221 35292 0 21:05 ? 00:00:01 postgres: postgres test 192.168.8.2(60978) idle
postgres 36243 35292 0 21:06 ? 00:00:00 postgres: postgres test 192.168.8.2(60998) idle
postgres 36974 35292 0 21:19 ? 00:00:00 postgres: postgres xunlei 192.168.8.2(62060) idle
postgres 37116 35292 0 21:22 ? 00:00:00 postgres: postgres postgres 192.168.8.2(62296) idle
Postgres就是Master进程。
有:号的都是后台进程,例如:postgres:

client连接启动进程
[root@node201 13325]# ps -ef | grep postgres
postgres 35292 1 0 Apr03 ? 00:00:00 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
postgres 35294 35292 0 Apr03 ? 00:00:00 postgres: logger process
postgres 35296 35292 0 Apr03 ? 00:00:00 postgres: checkpointer process
postgres 35297 35292 0 Apr03 ? 00:00:00 postgres: writer process
postgres 35298 35292 0 Apr03 ? 00:00:00 postgres: wal writer process
postgres 35299 35292 0 Apr03 ? 00:00:00 postgres: autovacuum launcher process
postgres 35300 35292 0 Apr03 ? 00:00:14 postgres: stats collector process
postgres 35722 35292 0 Apr03 ? 00:00:22 postgres: postgres postgres 192.168.8.2(60426) idle
postgres 35906 35292 0 Apr03 ? 00:00:57 postgres: postgres xunlei 192.168.8.2(60544) idle
postgres 36221 35292 0 Apr03 ? 00:00:01 postgres: postgres test 192.168.8.2(60978) idle
postgres 36243 35292 0 Apr03 ? 00:00:00 postgres: postgres test 192.168.8.2(60998) idle
postgres 36974 35292 0 Apr03 ? 00:00:00 postgres: postgres xunlei 192.168.8.2(62060) idle
postgres 37116 35292 0 Apr03 ? 00:00:00 postgres: postgres postgres 192.168.8.2(62296) idle
root 45348 1773 0 00:00 pts/1 00:00:00 su - postgres
postgres 45349 45348 1 00:00 pts/1 00:00:00 -bash
postgres 45397 45349 1 00:00 pts/1 00:00:00 psql -h 192.168.8.201 -p5432 -dtest
postgres 45398 35292 0 00:00 ? 00:00:00 postgres: postgres test 192.168.8.201(52880) idle
看到psql是客户端进程
上面黄色的是session进程。

查看多进程:
再开启一个连接
[root@node202 ~]# su - postgres
-bash-4.2$ psql -h 192.168.8.201 -p5432 -dtest
psql (9.6.21)
Type “help” for help.

test=#

查看
[root@node201 13325]# ps -ef | grep postgres
postgres 35292 1 0 Apr03 ? 00:00:00 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
postgres 35294 35292 0 Apr03 ? 00:00:00 postgres: logger process
postgres 35296 35292 0 Apr03 ? 00:00:00 postgres: checkpointer process
postgres 35297 35292 0 Apr03 ? 00:00:00 postgres: writer process
postgres 35298 35292 0 Apr03 ? 00:00:00 postgres: wal writer process
postgres 35299 35292 0 Apr03 ? 00:00:00 postgres: autovacuum launcher process
postgres 35300 35292 0 Apr03 ? 00:00:15 postgres: stats collector process
postgres 35722 35292 0 Apr03 ? 00:00:22 postgres: postgres postgres 192.168.8.2(60426) idle
postgres 35906 35292 0 Apr03 ? 00:01:03 postgres: postgres xunlei 192.168.8.2(60544) idle
postgres 36221 35292 0 Apr03 ? 00:00:01 postgres: postgres test 192.168.8.2(60978) idle
postgres 36243 35292 0 Apr03 ? 00:00:00 postgres: postgres test 192.168.8.2(60998) idle
postgres 36974 35292 0 Apr03 ? 00:00:00 postgres: postgres xunlei 192.168.8.2(62060) idle
postgres 37116 35292 0 Apr03 ? 00:00:00 postgres: postgres postgres 192.168.8.2(62296) idle
root 45348 1773 0 00:00 pts/1 00:00:00 su - postgres
postgres 45349 45348 0 00:00 pts/1 00:00:00 -bash
postgres 45397 45349 0 00:00 pts/1 00:00:00 psql -h 192.168.8.201 -p5432 -dtest
postgres 45398 35292 0 00:00 ? 00:00:00 postgres: postgres test 192.168.8.201(52880) idle
postgres 46699 35292 0 00:25 ? 00:00:00 postgres: postgres test 192.168.8.202(40116) idle
新创建的进程,是新的session进程。进程号+1

kill进程
[root@node201 13325]# kill 46699

Kill了进程,看到少了1个session进程,但是似乎都正常。
[root@node202 ~]# su - postgres
-bash-4.2$ psql -h 192.168.8.201 -p5432 -dtest
psql (9.6.21)
Type “help” for help.

test=#
test=# select 1
test-# select 1;
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
看到执行sql时,客户端出错了,说服务器端关闭了连接。另外1个客户端正常。杀死postgres进程,看进程状态

杀死Master进程,看进程状态
[root@node201 13325]# kill 35292
[root@node201 13325]# ps -ef | grep postgres
postgres 35292 1 0 Apr03 ? 00:00:00 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
postgres 35294 35292 0 Apr03 ? 00:00:00 postgres: logger process
postgres 35296 35292 0 Apr03 ? 00:00:00 postgres: checkpointer process
postgres 35297 35292 0 Apr03 ? 00:00:00 postgres: writer process
postgres 35298 35292 0 Apr03 ? 00:00:00 postgres: wal writer process
postgres 35299 35292 0 Apr03 ? 00:00:00 postgres: autovacuum launcher process
postgres 35300 35292 0 Apr03 ? 00:00:15 postgres: stats collector process
postgres 35722 35292 0 Apr03 ? 00:00:22 postgres: postgres postgres 192.168.8.2(60426) idle
postgres 35906 35292 0 Apr03 ? 00:01:06 postgres: postgres xunlei 192.168.8.2(60544) idle
postgres 36221 35292 0 Apr03 ? 00:00:01 postgres: postgres test 192.168.8.2(60978) idle
postgres 36243 35292 0 Apr03 ? 00:00:00 postgres: postgres test 192.168.8.2(60998) idle
postgres 36974 35292 0 Apr03 ? 00:00:00 postgres: postgres xunlei 192.168.8.2(62060) idle
postgres 37116 35292 0 Apr03 ? 00:00:00 postgres: postgres postgres 192.168.8.2(62296) idle
root 45348 1773 0 00:00 pts/1 00:00:00 su - postgres
postgres 45349 45348 0 00:00 pts/1 00:00:00 -bash
postgres 45397 45349 0 00:00 pts/1 00:00:00 psql -h 192.168.8.201 -p5432 -dtest
postgres 45398 35292 0 00:00 ? 00:00:00 postgres: postgres test 192.168.8.201(52880) idle
postgres 46890 35292 0 00:28 ? 00:00:00 postgres: postgres test 192.168.8.202(40118) idle
root 47078 26784 0 00:32 pts/2 00:00:00 grep --color=auto postgres

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值