主節點配置
! Configuration File for keepalived
global_defs {
notification_email {
<a href="mailto:[email protected]">[email protected]</a>
}
smtp_server smtp.163.com
smtp_connect_timeout 30
router_id LVS_master
}
vrrp_instance VIlvs {
state MASTER
interface eth2
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1122
}
virtual_ipaddress {
172.16.11.200
192.168.7.1 dev eth1
virtual_server 172.16.11.200 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
nat_mask 255.255.255.0
#persistence_timeout 50
protocol TCP
real_server 192.168.7.156 80 {
weight 100
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
}
real_server 192.168.7.158 80 {
備節點配置
router_id LVS_slave
state SLAVE
interface eth5
priority 90
192.168.7.1 dev eth4
核心參數設定
echo 1 > /proc/sys/net/ipv4/ip_forward
-A POSTROUTING -s 192.168.7.0/24 -o eth2 -j SNAT --to-source 172.16.11.162
WEB伺服器節點
隻需開啟WEB服務,預設網關指向LVS伺服器即可
本文轉自 jxwpx 51CTO部落格,原文連結:http://blog.51cto.com/jxwpx/1371345,如需轉載請自行聯系原作者