KeepAlive高可用双主lvs-dr模型集群

1.环境:

RS1  :  192.168.0.117

RS2 :192.168.0.118

VS1 :192.168.0.106

VS2 :  192.168.0.114

VIP1:192.168.0.90     VIP2:192.168.0.99

2.在RS上安装httpd服务:yum install httpd

编辑网页:

vi /var/www/html/index.html

192.168.0.117

vi /var/www/html/index.html

192.168.0.118

3.在RS上配置VIP,两台RS上都要配置

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
ifconfig  lo:0  192.168.0.90 netmask  255.255.255.255  broadcast  192.168.0.90  up
ifconfig  lo:1  192.168.0.99 netmask  255.255.255.255  broadcast  192.168.0.99  up
route add  -host  192.168.0.90  dev  ens33
route add  -host  192.168.0.99  dev  ens33
4.启动httpd服务
systemctl start httpd
5.在VS中配置vs的高可用以及VS集群服务
VS1:

global_defs {

notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos7-1
vrrp_mcast_group4 224.0.101.23
}

vrrp_instance myr1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90/24 dev ens33
}

}

vrrp_instance myr2 {
state MASTER
interface ens33
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.99/24 dev ens33
}
}

virtual_server 192.168.0.90 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

virtual_server 192.168.0.99 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

VS2:

global_defs {

notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos7-2
vrrp_mcast_group4 224.0.101.23
}

vrrp_instance myr1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90/24 dev ens33
}
}

vrrp_instance myr2 {
state BACKUP
interface ens33
virtual_router_id 52
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.99/24 dev ens33
}
}

virtual_server 192.168.0.90 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

virtual_server 192.168.0.99 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

6.在vs上配置sorry_server
yum install httpd
vs2上
vi /var/www/html/index.html
Driector2:sorry_server
vs1上
vi /var/www/html/index.html
Driector1:sorry_server

7.启动keepalived

systemctl  start keepalived

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/103771

(0)
DPingDPing
上一篇 2018-07-23
下一篇 2018-07-23

相关推荐