????1.4.2.   ??????2keepalived????
! Configuration File for keepalived
global_defs {
notification_email {
master@extmail.org
}
notification_email_from yunlei_ma@extmail.org
smtp_server mail.extmail.org
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script chk_mongodb {
script "/etc/keepalived/mongodb_check.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 100
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_mongodb
}
virtual_ipaddress {
192.168.1.18
}
}
????1.4.3.   Mongodb????????
/etc/keepalived/mongodb_check.sh
#!/bin/bash
daemonid=`ps -ef |grep /usr/local/mongodb/bin/mongod |grep dbpath|awk '{print $2}'`
if [ "$daemonid" != "" ];then
echo $daemonid
exit 0
else
echo $daemonid
/etc/init.d/keepalived stop
exit 1
fi
????1.5.    ???????????????
????iptables –I INPUT –p tcp –dport 27017 –j ACCEPT
????iptables –I INPUT –p udp –dport 27017 –j ACCEP
????/etc/init.d/iptables save
????/etc/init.d/iptables restart
????1.6.    ????л?????
????1.6.1.   ???????
?????????????keepalived???????????IP?????????????????崻????????????????????????????????????
????1.6.2.   Keepalived??
????Keepalived????????IP????????????????????