一 Server IP: Real Server 1:192.168.16.62 Real Server 2:192.168.16.63 Virtual Server :192.168.16.69 Keepalived Server 1:192.168.16.64 Keepalived Server 2:192.168.16.66 二 Real Server 配置
Real Server 1:192.168.16.62 ifconfig lo:0 192.168.16.69 netmask 255.255.255.255 broadcast 192.168.16.69 route add -host 192.168.16.69 dev lo:0 echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce 安装 httpd Real Server 2 同上 三 Keepalived Server 1 配置 安装 keepalived keepalived.conf按如下配置 global_defs { notification_email { suzb@clo.com.cn } notification_email_from keepalived@clo.com smtp_server 192.268.101.12 smtp_connect_timeout 30 router_id node04 vrrp_mcast_group4 224.0.16.18 }
vrrp_instance VI_1 {
state MASTER|BACKUP
interface ens32
virtual_router_id 60
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123
}
virtual_ipaddress {
192.168.16.69/24 dev ens32
}
notify_master “/etc/keepalived/keepalived-notify.sh master”
notify_backup “/etc/keepalived/keepalived-notify.sh backup”
notify_fault “/etc/keepalived/keepalived-notify.sh fault”
}
virtual_server 192.168.16.69 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.16.62 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.16.63 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
}
Keepalived Server 2 配置 同上
四,测试
#ip addr l 在 Virtual Server 查看 VIP 在那台Virtual Server 上
#ipvsadm -Ln 查看 ipvs 策略是否生成
#curl 192.168.16.69 发布的web站点
本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/90021