#vi/etc/keepalived/keepalived.conf

! Configuration File for keepalived

 

global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server 127.0.0.1

# smtp_connect_timeout 30

router_id LVS_DEVEL

}

 

 

# VIP1

vrrp_instanceVI_1 {

state MASTER #备份服务器上将MASTER改为BACKUP

interface eth0

virtual_router_id 51

priority 100 # 备份服务上将100改为99

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

10.0.0.1

#(如果有多个VIP,继续换行填写.)

}

}

 

virtual_server 10.0.0.1 80 {

delay_loop 6 #(每隔10秒查询realserver状态)

lb_algo wrr #(lvs 算法)

lb_kind DR #(Direct Route)

persistence_timeout 60 #(同一IP的连接60秒内被分配到同一台realserver)

protocol TCP #(用TCP协议检查realserver状态)

 

real_server 192.168.1.2 80 {

weight 3 #(权重)

TCP_CHECK {

connect_timeout 10 #(10秒无响应超时)

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.1.380 {

weight 3

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}