标签:
#!/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin [[ -e "/etc/rc.d/init.d/haproxy" ]] || exit 1 [[ -z `ps aux | grep /usr/sbin/haproxy | grep -v grep` ]] && service haproxy start && exit 1 ETH1_ADDR=`/sbin/ifconfig eth0 | awk -F ‘:‘ ‘/inet addr/{print $2}‘ | sed ‘s/[a-zA-Z ]//g‘` [[ -z `curl -I -s "http://${ETH1_ADDR}" | grep "200 OK"` ]] && service haproxy restart
chmox +x /usr/local/haproxy/sbin/check_haproxy.sh
设置定时检查任务
crontab -e
*/5 * * * * /usr/local/haproxy/sbin/check_haproxy.sh >/dev/null 2>&1
备注:若无法运行,请根据haproxy安装路径和绑定的网卡对代码做简单修改
net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 80000 net.core.somaxconn = 32768 net.ipv4.tcp_keepalive_probes = 5 net.ipv4.tcp_keepalive_intvl = 20 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.core.netdev_max_backlog = 32768 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_retries2 = 5 net.ipv4.tcp_mem = 41943040 73400320 94371840 net.ipv4.tcp_max_orphans = 3276800 fs.file-max = 1300000
sysctl -p
标签:
原文地址:http://www.cnblogs.com/Mrhuangrui/p/4601294.html