1、安装目录包
1
|
yum
install
-y net-tools psmisc
|
2、安装keepalived
1
|
yum
install
-y ipvsadm keepalived
|
3、master配置文件
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
|
! Configuration File
for
keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
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_nginx {
script
"killall -0 nginx"
interval 1
weight -15
}
vrrp_instance VI_1 {
state MASTER
interface eno16777736
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.1.10
}
track_script {
chk_nginx
}
}
|
4、backup配置文件
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
|
! Configuration File
for
keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
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_nginx {
script
"killall -0 nginx"
interval 1
weight -15
}
vrrp_instance VI_1 {
state BACKUP
interface eno16777736
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.1.10
}
track_script {
chk_nginx
}
}
|
5、设置开启启动和启动keepalived
1
2
|
systemctl
enable
keepalived
systemctl start keepalived
|
参考博文:http://soulful.blog.51cto.com/468033/1676442
本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/1741941,如需转载请自行联系原作者