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

相关推荐

  • 网络基础2

    网络基础2

    Linux笔记 2018-05-01
  • linux入门命令

    bc:计算器 mainframe 缓存查看:lscpu磁盘和内存性能测试命令: dd Xmanager (xshell) 安装:用户名: byg公司: microsoft注册码: 使用工具生成 命令库调用: # ldd /bin/ls系统库跟踪,调用库详细信息 # strace lslibrary 库跟踪 # ltrace ls 二进制文件查看: # hex…

    Linux笔记 2018-07-21
  • 文本处理工具sed的高级用法

    在上一章,我们学习了sed的一些基本用法,利用这些基本用法我们已经可以解决文本处理中遇到的绝大部分问题,但要想更加利用好sed这个工具,我们还需要学习下它的一些高级用法。

    2018-04-20
  • 计算机扫盲闲谈—番外篇(基础知识补充)

    Ken Thompson:一切为了游戏。没错就是为了玩这款为Multics系统开发的游戏“star travel”他编写了一套简化的系统——Unix

    2018-03-27
  • 简述iproute家族命令

    iptoute2家族 ip命令:ip – show / manipulate routing, devices, policy routing and tunnelsip [ OPTIONS ] OBJECT { COMMAND | help }OBJECT := { link | address | addrlabel | route | ru…

    Linux笔记 2018-06-15
  • 磁盘管理

    笔记

    2018-04-29