Keepalived Install

keepalived install

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
yum install -y popt-devel gcc
yum install -y kernel kernel-devel

wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
tar -zxf keepalived-1.2.7.tar.gz
cd keepalived-1.2.7

./configure --sysconf=/etc --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.32-358.2.1.el6.x86_64/

# 参数解释:
#
# --sysconf 指定了配置文件的地址.即:/etc/keepalived/keepalived.conf
# --prefix 指定了安装目录
# --with-kernel-dir 指定使用内核源码中的头文件,即 include 目录.只有使用 LVS 时才需要这个参数,其它的时候不需要。
# onfigue .成功后提示:

Keepalived configuration
------------------------
Keepalived version : 1.2.7
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
IPVS use libnl : No
Use VRRP Framework : Yes
Use VRRP VMAC : Yes
SNMP support : No
Use Debug flags : No


make
make install

cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
# 加入服务
vi /etc/keepalived/keepalived.conf

#nginx 方案 (master)
#backup 修改state 为BACKUP priority 为99
! Configuration File for keepalived

global_defs {
notification_email {
#sysadmin@firewall.loc
}
#notification_email_from Alexandre.Cassen@firewall.loc
#smtp_server 192.168.200.1
#smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_script chk_http_port {
script "</dev/tcp/127.0.0.1/80"
interval 1
weight -2
}

vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.190
}
track_script {
chk_http_port
}
}