本来想模拟宕机,但是服务器不在本地,怕起不来,改用杀用户所有进程来模拟。
找到了killall来操作,看下效果:
[dangpg@localhost2 ~]$ ps xuf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
dangpg 1944 0.0 0.0 108344 1820 pts/1 S 17:10 0:00 -bash
dangpg 2500 0.0 0.0 110220 1044 pts/1 R+ 17:13 0:00 \_ ps xuf
dangpg 24685 0.0 0.1 2294596 68032 ? S Jul25 0:16 /home/dangpg/app/pg96/bin/postgres -D /home/dangpg/data/pg96
dangpg 24686 0.0 0.0 118724 1352 ? Ss Jul25 0:00 \_ postgres: logger process
dangpg 24689 0.0 0.1 2296776 99252 ? Ss Jul25 0:41 \_ postgres: checkpointer process
dangpg 24690 0.0 0.0 2294696 23016 ? Ss Jul25 0:11 \_ postgres: writer process
dangpg 24691 0.0 0.0 2294596 17936 ? Ss Jul25 0:23 \_ postgres: wal writer process
dangpg 24692 0.0 0.0 2295024 2348 ? Ss Jul25 0:19 \_ postgres: autovacuum launcher process
dangpg 24693 0.0 0.0 123080 2828 ? Ss Jul25 2:31 \_ postgres: stats collector process
dangpg 2797 0.0 0.0 264256 12032 ? S May24 1:31 /home/dangpg/app/pg10/bin/postgres -D /home/dangpg/data/pg10
dangpg 2798 0.0 0.0 117116 868 ? Ss May24 0:00 \_ postgres: logger process
dangpg 2802 0.0 0.2 264568 132312 ? Ss May24 0:04 \_ postgres: checkpointer process
dangpg 2803 0.0 0.2 264256 133616 ? Ss May24 1:04 \_ postgres: writer process
dangpg 2804 0.0 0.0 264256 5272 ? Ss May24 1:07 \_ postgres: wal writer process
dangpg 2805 0.0 0.0 264696 1820 ? Ss May24 1:47 \_ postgres: autovacuum launcher process
dangpg 2806 0.0 0.0 119344 1036 ? Ss May24 3:42 \_ postgres: stats collector process
dangpg 2807 0.0 0.0 264548 1456 ? Ss May24 0:04 \_ postgres: bgworker: logical replication launcher
[dangpg@localhost2 ~]$ killall -u dangpg
[dangpg@localhost2 ~]$ ps xuf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
dangpg 1944 0.0 0.0 108344 1824 pts/1 S 17:10 0:00 -bash
dangpg 2505 0.0 0.0 110220 1040 pts/1 R+ 17:13 0:00 \_ ps xuf
[dangpg@localhost2 ~]$