systemd不会为保持状态刷新主PID

时间:2020-07-09 18:40:46

标签: linux systemd keepalived

当systemd不刷新主PID时,我遇到了一个问题:

keepalived以及keepalived.service和keepalived.service.conf的状态如下:

[root@rhel7_36 ~]# systemctl status keepalived -l
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/keepalived.service.d
           └─keepalived.service.conf
   Active: active (running) since Thu 2020-07-09 18:21:18 GMT; 42s ago
  Process: 1173 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1176 (keepalived)
   CGroup: /system.slice/keepalived.service
           ├─1176 /usr/sbin/keepalived -D
           ├─1177 /usr/sbin/keepalived -D
           ├─1178 /usr/sbin/keepalived -D
           ├─1695 /usr/sbin/keepalived -D
           ├─1696 /usr/sbin/keepalived -D
           ├─1697 sh -c /bin/ping -q -c 5 -W 1 192.168.X.X >/dev/null
           ├─1698 sh -c /bin/ping -q -c 5 -W 1 192.168.X.X >/dev/null
           ├─1699 /bin/ping -q -c 5 -W 1 192.168.X.X
           └─1700 /bin/ping -q -c 5 -W 1 192.168.X.X

Jul 09 18:21:20 rhel7_36 Keepalived_vrrp[1178]: VRRP_Group(VG_PREAUTH) Syncing instances to FAULT state
Jul 09 18:21:20 rhel7_36 Keepalived_vrrp[1178]: Opening script file /usr/libexec/keepalived/stateNotify.py
Jul 09 18:21:22 rhel7_36 Keepalived_vrrp[1178]: VRRP_Script(icmp_to_eth1_router) succeeded
Jul 09 18:21:22 rhel7_36 Keepalived_vrrp[1178]: VRRP_Script(icmp_to_eth0_router) succeeded
Jul 09 18:21:23 rhel7_36 Keepalived_vrrp[1178]: Kernel is reporting: Group(VG_PREAUTH) UP
Jul 09 18:21:23 rhel7_36 Keepalived_vrrp[1178]: VRRP_Group(VG_PREAUTH) Leaving FAULT state
Jul 09 18:21:23 rhel7_36 Keepalived_vrrp[1178]: VRRP_Instance(VI_eth1) Entering BACKUP STATE
Jul 09 18:21:23 rhel7_36 Keepalived_vrrp[1178]: VRRP_Group(VG_PREAUTH) Syncing instances to BACKUP state
Jul 09 18:21:23 rhel7_36 Keepalived_vrrp[1178]: VRRP_Instance(VI_eth0) Entering BACKUP STATE
Jul 09 18:21:23 rhel7_36 Keepalived_vrrp[1178]: Opening script file /usr/libexec/keepalived/stateNotify.py

[root@rhel7_36 ~]# systemctl cat keepalived
# /usr/lib/systemd/system/keepalived.service
[Unit]
Description=LVS and VRRP High Availability Monitor
After=syslog.target network-online.target

[Service]
Type=forking
PIDFile=/var/run/keepalived.pid
KillMode=process
EnvironmentFile=-/etc/sysconfig/keepalived
ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

# /etc/systemd/system/keepalived.service.d/keepalived.service.conf
[Service]
Environment="INSTALL_DIR=/opt/edge"
Nice=-10
Restart=on-failure
RestartSec=20

现在我正在执行pkill -9 keepalived,以便keepalived在20秒内自行启动。它第一次执行此操作,并且keepalived的状态如下所示

[root@rhel7_36 ~]# systemctl status keepalived -l
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/keepalived.service.d
           └─keepalived.service.conf
   Active: active (running) since Thu 2020-07-09 18:27:36 GMT; 4min 19s ago
  Process: 1910 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
  Process: 2377 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1176 (code=killed, signal=KILL)
   CGroup: /system.slice/keepalived.service
           ├─2378 /usr/sbin/keepalived -D
           ├─2379 /usr/sbin/keepalived -D
           └─2380 /usr/sbin/keepalived -D

Jul 09 18:27:38 rhel7_36 Keepalived_vrrp[2380]: VRRP_Group(VG_PREAUTH) Syncing instances to FAULT state
Jul 09 18:27:38 rhel7_36 Keepalived_vrrp[2380]: Opening script file /usr/libexec/keepalived/stateNotify.py
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: VRRP_Script(icmp_to_eth0_router) succeeded
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: VRRP_Script(icmp_to_eth1_router) succeeded
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: Kernel is reporting: Group(VG_PREAUTH) UP
Jul 09 18:27:41 ehel7_36 Keepalived_vrrp[2380]: VRRP_Group(VG_PREAUTH) Leaving FAULT state
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: VRRP_Instance(VI_eth1) Entering BACKUP STATE
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: VRRP_Group(VG_PREAUTH) Syncing instances to BACKUP state
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: VRRP_Instance(VI_eth0) Entering BACKUP STATE
Jul 09 18:27:41 rhel7_36 Keepalived_vrrp[2380]: Opening script file /usr/libexec/keepalived/stateNotify.py

如您所见,主PID未刷新。

我在/usr/lib/systemd/system/keepalived.service中包含PIDFile,并且还存在/var/run/keepalived.pid文件。

现在它也将无法重新加载keepalived。我很困惑为什么它没有刷新PID。

[root@rhel7_36 ~]# systemctl reload keepalived
Job for keepalived.service failed because the control process exited with error code. See "systemctl status keepalived.service" and "journalctl -xe" for details.

[root@rhel7_36 ~]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/keepalived.service.d
           └─keepalived.service.conf
   Active: active (running) (Result: exit-code) since Thu 2020-07-09 18:27:36 GMT; 7min ago
  Process: 3329 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=1/FAILURE)
  Process: 2377 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1176 (code=killed, signal=KILL)
   CGroup: /system.slice/keepalived.service
           ├─2378 /usr/sbin/keepalived -D
           ├─2379 /usr/sbin/keepalived -D
           ├─2380 /usr/sbin/keepalived -D
           ├─3344 /usr/sbin/keepalived -D
           ├─3345 /usr/sbin/keepalived -D
           ├─3346 sh -c /bin/ping -q -c 5 -W 1 192.168.X.X >/dev/null
           ├─3347 sh -c /bin/ping -q -c 5 -W 1 192.168.X.X >/dev/null
           ├─3348 /bin/ping -q -c 5 -W 1 192.168.X.X
           └─3349 /bin/ping -q -c 5 -W 1 192.168.X.X

Jul 09 18:35:08 rhel7_36 kill[3329]: -s, --signal <sig>     send sp...l
Jul 09 18:35:08 rhel7_36 kill[3329]: -q, --queue <sig>      use sig...)
Jul 09 18:35:08 rhel7_36 kill[3329]: -p, --pid              print p...m
Jul 09 18:35:08 rhel7_36 kill[3329]: -l, --list [=<signal>] list si...e
Jul 09 18:35:08 rhel7_36 kill[3329]: -L, --table            list si...s
Jul 09 18:35:09 rhel7_36 kill[3329]: -h, --help     display this he...t
Jul 09 18:35:09 rhel7_36 kill[3329]: -V, --version  output version ...t
Jul 09 18:35:09 rhel7_36 kill[3329]: For more details see kill(1).
Jul 09 18:35:08 rhel7_36 systemd[1]: keepalived.service: control pr...1
Jul 09 18:35:08 rhel7_36 systemd[1]: Reload failed for LVS and VRRP....
Hint: Some lines were ellipsized, use -l to show in full.

[root@rhel7_36 ~]# journalctl -xe
Jul 09 18:35:08 rhel7_36 systemd[1]: keepalived.service: control proces
Jul 09 18:35:08 rhel7_36 systemd[1]: Reload failed for LVS and VRRP Hig
-- Subject: Unit keepalived.service has finished reloading its configuration
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit keepalived.service has finished reloading its configuration
-- 
-- The result is failed.
Jul 09 18:35:55 rhel7_36 systemd[1]: Starting Cleanup of Temporary Dire
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit systemd-tmpfiles-clean.service has begun starting up.
Jul 09 18:35:55 rhel7_36 systemd[1]: Started Cleanup of Temporary Direc
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit systemd-tmpfiles-clean.service has finished starting up.
-- 
-- The start-up result is done

keepalived版本 Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2

任何输入都有助于理解和纠正此问题。

谢谢!!!

0 个答案:

没有答案