释放双眼,带上耳机,听听看~!
🤖 由 ChatGPT 生成的文章摘要
完整日志如下
[root@abcdocker keepalived]# journalctl -fu keepalived
-- Logs begin at Tue 2023-08-08 16:58:16 CST. --
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48476]: Assigned address 1.1.1.1 for interface eth0
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48476]: Registering gratuitous ARP shared channel
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48476]: (VI_1) removing VIPs.
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48476]: (VI_1) Entering BACKUP STATE (init)
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48476]: VRRP sockpool: [ifindex( 2), family(IPv4), proto(112), fd(13,14), unicast, address(10.51.214.10)]
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48477]: Error exec-ing command '/etc/keepalived/check_port.sh', error 8: Exec format error
Sep 19 16:45:25 abcdocker Keepalived_vrrp[48476]: VRRP_Script(chk_nginx) succeeded
Sep 19 16:45:25 abcdocker systemd[1]: Started LVS and VRRP High Availability Monitor.
Sep 19 16:45:27 abcdocker Keepalived_vrrp[48478]: Error exec-ing command '/etc/keepalived/check_port.sh', error 8: Exec format error
Sep 19 16:45:29 abcdocker Keepalived_vrrp[48480]: Error exec-ing command '/etc/keepalived/check_port.sh', error 8: Exec format error
Sep 19 16:45:35 abcdocker Keepalived_vrrp[48484]: Error exec-ing command '/etc/keepalived/check_port.sh', error 8: Exec format error
/etc/keepalived/check_port.sh'
脚本内容如下
- 我的系统版本为Centos8
cat >check_port.sh<<'EOF'
CHK_PORT=$1
if [ -n "$CHK_PORT" ];then
PORT_PROCESS=`lsof -i:$CHK_PORT|wc -l`
if [ $PORT_PROCESS -eq 0 ];then
echo "Port $CHK_PORT Is Not Used,End."
systemctl stop keepalived
exit 1
fi
else
echo "Check Port Cant Be Empty!"
fi
EOF
原因是没有添加#bin/bash解析
,但是我在Centos7确实没遇到这种问题