參考文檔 http://wenku.baidu.com/view/8e38022d2af90242a895e532.html
安裝
解壓文件
tar -xvf keepalived-x.x.x.tar.gz
進(jìn)入文件夾keepalived-x.x.x
./configure
make && make install
在安裝過程中需要注意以下幾點(diǎn):
- gcc環(huán)境
- openssl環(huán)境
- root權(quán)限
配置
# cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
# mkdir /etc/keepalived
# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
# cp /usr/local/sbin/keepalived /usr/sbin/
做成系統(tǒng)啟動(dòng)服務(wù)方便管理.
# vi /etc/rc.local
/etc/init.d/keepalived start
增加上面一行篷牌。
修改配置/etc/keepalived/keepalived.conf
! Configuation File for keepalived
global_defs {
notification_email {
acassen@firewall.loc # 郵件地址睡蟋,當(dāng)異常時(shí)發(fā)郵件通知〖霞眨可以是多個(gè)戳杀,每個(gè)一行
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
}
vrrp_instance VI_1 {
state MASTER # 從機(jī)設(shè)為BACKUP
interface eth0 # 網(wǎng)卡接口
mcast_src_ip 10.0.0.131 # 默認(rèn)沒有這項(xiàng),加上這項(xiàng)后服務(wù)好用了
priority 100 # 優(yōu)先級(jí)夭苗,從機(jī)小與主機(jī)
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.111 # 虛擬ip設(shè)置信卡,可以是多個(gè),主從一致
}
}