forked from aqzt/kjyw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keepalive.sh
53 lines (45 loc) · 1.34 KB
/
keepalive.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
###
# Filename: install_keepalived.sh
# Author: roguo.wei - [email protected]
# Description:
# Last Modified: 2016-11-09 00:57
# Version: 1.0
###
KEEPALIVED_USER="keepalived"
KEEPALIVED_VERSION="1.2.24"
KEEPALIVED_INSTALL_DIR="/usr/local"
yum install -y kernel-devel openssl openssl-devel &> /dev/null
ln -s /usr/src/kernels/`uname -r`/ /usr/src/linux
# check keepalived user
id -u ${KEEPALIVED_USER=} &> /dev/null
[ $? -ne 0 ] && useradd -M -s /bin/bash ${KEEPALIVED_USER}
# check tar file
if [ ! -f keepalived-${KEEPALIVED_VERSION}.tar.gz ];then
echo "keepalived tar file not exists."
echo "download from offical website..."
wget http://www.keepalived.org/software/keepalived-1.2.24.tar.gz
else
tar xf keepalived-${KEEPALIVED_VERSION}.tar.gz
fi
# comline keepalived
pushd keepalived-${KEEPALIVED_VERSION}
./configure --sysconf=/etc &> /dev/null
make &> /dev/null
make install &> /dev/null
popd
/bin/cp /usr/local/sbin/keepalived /usr/bin/
# config log
sed -i 's@^KEEPALIVED_OPTIONS=.*@KEEPALIVED_OPTIONS="-D -d -S 0"@' /etc/sysconfig/keepalived
#cat >> "local0.* /var/log/keepalived/keepalived.log" /etc/rsyslog.conf
cat > /etc/rsyslog.d/keepalived.conf << EOF
local0.* /var/log/keepalived.log
&~
EOF
/etc/init.d/rsyslog restart &> /dev/null
# man config
#
/etc/init.d/keepalived start
chmod +x /etc/init.d/keepalived
chkconfig keepalived on