1.安装依赖
1 | su - root |
2.安装keepalived
2.1.上传
1 | 1、cd /usr/local |
3、选择keepalived安装文件
2.2.解压
1 |
|
2.3.重命名
1 | mv keepalived-1.2.2 keepalived |
2.4.安装keepalived
1 |
|
2、执行命令
1 |
|
3、编译
1 |
|
4、安装
1 |
|
2.5.配置服务和加入开机启动
1 |
|
2.6.修改配置文件
1 |
|
2、详解:
1 |
|
3.按照上面步骤安装备机器
注意:备的配置文件不相同。
4.两台机器启动keepalived:
service keepalived start
5.验证
ip a
6.监控
因为keepalive只能监控机器的死活,所以当软件死掉后,keepalived仍然不会切换;
所以需要写一个脚本,监控软件的死活。
运行wangsf.sh,监控软件
主配置文件keepalived.conf
1 |
|
从配置文件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
! 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_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 51
priority 100
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.70
}
}
virtual_server 192.168.56.70 8080 {
delay_loop 6
lb_algo rr
lb_kind DR
#nat_mask 255.255.255.0
persistence_timeout 1
protocol TCP
real_server 192.168.56.201 8080 {
weight 20
SSL_GET {
url {
path /
digest ff20ad2481f97b1754ef3e12ecd3a9cc
}
url {
path /mrtg/
digest 9b3a0c85a887a256d6939da88aabd8cd
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}