keepalived01:雙網卡服務器雙機熱備
01
keepalived雙網卡服務器雙機熱備
02
03
環境:
04
master: eth0(192.168.0.100/24) eth1(10.0.0.100/24)
05
backup: eth0(192.168.0.200/24) eth1(10.0.0.200/24)
06
07
軟件安裝:
08
安裝依賴:
09
yum install ipvsadm kernel-devel openssl-devel popt-devel \
10
libnl-devel gcc make -y
11
解壓編譯:
12
tar zxf keepalived-1.2.7.tar.gz
13
cd keepalived-1.2.7
14
./configure --prefix=/usr/local/keepalived
15
make && make install
16
做鏈接:
17
ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
18
ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
19
ln -s /usr/local/keepalived/etc/keepalived/ /etc/
20
ln -s /usr/local/keepalived/sbin/keepalived /usr/sbin/
21
備份配置文件:
22
cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
23
添加用戶:
24
useradd keepalived
25
26
修改配置:
27
vi /etc/keepalived/keepalived.conf
28
###############################################################
29
! Configuration File for keepalived
30
31
global_defs {
32
notification_email {
33
[email protected]
34
}
35
notification_email_from keepalived@localhost
36
smtp_server 127.0.0.1
37
smtp_connect_timeout 30
38
router_id LVS_DEVEL
39
}
40
vrrp_sync_group VGM {
41
group {
42
VI_1
43
}
44
}
45
vrrp_instance VI_1 {
46
state MASTER #BACKUP
47
interface eth0
48
virtual_router_id 51
49
priority 100 #50
50
advert_int 1
51
authentication {
52
auth_type PASS
53
auth_pass westos
54
}
55
track_interface {
56
eth0
57
eth1
58
}
59
virtual_ipaddress {
60
192.168.0.150/24 dev eth0
61
10.0.0.150/24 dev eth1
62
}
63
}
64
65
###############################################################
66
67
啟動服務測試:
68
tail -f /var/log/message
69
/etc/init.d/keepalived start(master,backup)
70
master的測試頁面“MASTER”,backup的測試頁面“BACKUP”
71
72
master,backup的keepalived都啟動時在backup端測試:
73
[root@backup ~]# curl http://192.168.0.150
74
MASKTER
75
[root@backup ~]# curl http://10.0.0.150
76
MASKTER
77
將master的eht1 down掉後在backup端測試:
78
[root@backup ~]# curl http://192.168.0.150
79
BACKUP
80
[root@backup ~]# curl http://10.0.0.150
81
BACKUP