大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

LVS-DR群集模式+keepalived怎么实现高可用-创新互联

这期内容当中小编将会给大家带来有关LVS-DR群集模式+keepalived怎么实现高可用,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

创新互联建站主要从事做网站、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务郊区,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

条件:五台虚拟机:

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

(主)负载调度器:

创建映射端口(VIP)

LVS-DR群集模式+keepalived怎么实现高可用

优化环境:(/etc/sysctl.conf)

LVS-DR群集模式+keepalived怎么实现高可用

net.ipv4.conf.all.send_redirects = 0

net.ipv4.conf.default.send_redirects = 0

net.ipv4.conf.eth0.send_redirects = 0

sysctl -p

加载ip_vs模块

modprobe ip_vs

查看ipvs

cat /proc/net/ip_vs

安装IPVS

yum install -y ipvsadm

查看版本:

ipvsadm -v

设置负载调度器设置模式

ipvsadm -A -t 192.168.115.100:80 -s rr

ipvsadm -a -t 192.168.115.100:80 -r 192.168.115.173:80 -g(173和176分别指向两个RS)

ipvsadm -a -t 192.168.115.100:80 -r 192.168.115.176:80 -g

查看:

ipvsadm -Ln

安装keepalived

yum install -y gcc*  kernel-devel openssl-devel popt-devel ipvsadm

tar -xvf keepalived-1.2.7.tar.gz

./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-131.0.15.el6.i686

make && make install

chkconfig --add keepalived

chkconfig keepalived on

LVS-DR群集模式+keepalived怎么实现高可用

配置keepalived文件:

LVS-DR群集模式+keepalived怎么实现高可用

启动服务:

service keepalived start

chkconfig keepalived on

共享资源服务器:

搭建NFS给RS挂在使用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

RS1:

安装Apache服务

配置本地回环端口映射:

LVS-DR群集模式+keepalived怎么实现高可用

设置一条路由:

route add -host 192.168.115.100 dev lo:0

优化环境:

LVS-DR群集模式+keepalived怎么实现高可用

net.ipv4.conf.all.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.default.arp_ignore = 1

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.lo.arp_ignore = 1

net.ipv4.conf.lo.arp_announce = 2

RS2:

安装Apache服务,将内容从NFS服务器上面挂在过来:

mount -t nfs 192.168.115.177:/share /var/www/html

设置映射网卡:

LVS-DR群集模式+keepalived怎么实现高可用

优化环境:

LVS-DR群集模式+keepalived怎么实现高可用

net.ipv4.conf.all.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.default.arp_ignore = 1

net.ipv4.conf.lo.arp_ignore = 1

net.ipv4.conf.lo.arp_announce = 2

设置路由:

设置一条路由:

route add -host 192.168.115.100 dev lo:0

测试机访问:

每刷新一次,内容一次轮询:

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

下面搭建基于keepalived的LVS-DR

增加一个虚拟机作为从负载调度器:

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

加载ip_vs模块

modprobe ip_vs

查看ipvs

cat /proc/net/ip_vs

安装IPVS

yum install -y ipvsadm

查看版本:

ipvsadm -v

设置负载调度器设置模式

ipvsadm -A -t 192.168.115.100:80 -s rr

ipvsadm -a -t 192.168.115.100:80 -r 192.168.115.173:80 -g(173和176分别指向两个RS)

ipvsadm -a -t 192.168.115.100:80 -r 192.168.115.176:80 -g

查看:

ipvsadm -Ln

LVS-DR群集模式+keepalived怎么实现高可用

优化环境:

LVS-DR群集模式+keepalived怎么实现高可用

net.ipv4.conf.all.send_redirects = 0

net.ipv4.conf.default.send_redirects = 0

net.ipv4.conf.eth0.send_redirects = 0

安装keepalived

yum install -y gcc*  kernel-devel openssl-devel popt-devel ipvsadm

tar -xvf keepalived-1.2.7.tar.gz

./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-131.0.15.el6.i686

make && make install

chkconfig --add keepalived

chkconfig keepalived on

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

service keepalived start

chkconfig keepalived on

测试机测试:

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

LVS-DR群集模式+keepalived怎么实现高可用

从服务器成功接替工作:实验成功:

配置文件模板:

! Configuration File for keepalived

global_defs {

 router_id LVS_R1

}

vrrp_instance VI_1 {

  state MASTER

  interface eth0

  virtual_router_id 51

  priority 100

  advert_int 1

  authentication {

    auth_type PASS

    auth_pass 1111

  }

  virtual_ipaddress {

    192.168.115.100

  }

}

virtual_server 192.168.115.100 80 {

  delay_loop 6

  lb_algo rr

  lb_kind DR

  protocol TCP

  real_server 192.168.115.173 80 {

    weight 1

        TCP_CHECK {

            connect_port 80

            connect_timeout 3

            nb_get_retry 3

            delay_before_retry 3

    }

    }

 real_server 192.168.115.176 80 {

    weight 1

        TCP_CHECK {

            connect_port 80

            connect_timeout 3

            nb_get_retry 3

            delay_before_retry 3

    }

    }

  }

在做从负载调度器的时候,因为有两个网卡公用一个地址,这样启动网卡的时候会报错

解决办法:

vim /etc/sysconfig/network-scripts/ifup-eth

LVS-DR群集模式+keepalived怎么实现高可用

将图示内容注释即可

然后再重启网卡

上述就是小编为大家分享的LVS-DR群集模式+keepalived怎么实现高可用了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章名称:LVS-DR群集模式+keepalived怎么实现高可用-创新互联
地址分享:http://dzwzjz.com/article/codihj.html
在线咨询
服务热线
服务热线:028-86922220
TOP