今天看啥
    热点:

      天发国际娱乐官网:▲(张祥)【责任编辑:董志成】

      负载均衡群集LVS-DR 与 LVS-NAT


      负载均衡群集之LVS-DR

      调度服务器:
      一块网卡:
      Vmnet1:192.168.80.100
      -------------------------加载LVS内核模块----------------------
      LVS现在已成为Linux内核的一部分,默认编译为ip_vs模块,必要时能够自动调用。以下操作可以手动加载ip_vs模块,并查看当前系统中ip_vs模块的版本信息
      [[email protected] ~]# cat /proc/net/ip_vs
      cat: /proc/net/ip_vs: 没有那个文件或目录
      [[email protected] ~]# modprobe ip_vs //加载ip_vs模块,
      [[email protected] ~]# cat /proc/net/ip_vs //查看ip_vs版本信息
      [[email protected] ~]# rpm -ivh /mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm //安装管理软件,不需要启动

      ---------------------DR模式调度器配置------(调度器与各服务器在同个网段内)-------------
      ------------------注意:80.188是调度器和各真实服务器要共同虚拟出的一个地址---------------
      [[email protected] ~]# vi dr.sh
      #!/bin/bash
      #
      ifconfig ens33:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 up
      route add -host 192.168.80.188 dev ens33:0
      ipvsadm -C
      ipvsadm -A -t 192.168.80.188:80 -s rr
      ipvsadm -a -t 192.168.80.188:80 -r 192.168.80.101:80 -g
      ipvsadm -a -t 192.168.80.188:80 -r 192.168.80.102:80 -g
      ipvsadm –Ln
      [[email protected] ~]# sh dr.sh
      [[email protected] ~]# ifconfig

      192.168.80.101服务器:
      Vmnet1内网:192.168.80.101
      [[email protected] ~]# yum install -y httpd
      [[email protected] ~]# vi /etc/httpd/conf/httpd.conf
      ServerName www.aa.com
      [[email protected] ~]# vi /var/www/html/index.html
      <h1>Server aa </h1>
      [[email protected] ~]# service httpd restart
      ------DR模式,各真实服务器配置---虚拟地址是相同的---
      [[email protected] ~]# vi web.sh
      #!/bin/bash
      #haha
      ifconfig lo:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 up
      route add -host 192.168.80.188 dev lo:0
      echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
      echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
      echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
      echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
      sysctl -p &>/dev/null
      [[email protected] ~]# sh web.sh
      [[email protected] ~]# ifconfig

      192.168.80.102服务器:
      Vmnet1内网:192.168.80.102
      [[email protected] ~]# yum install -y httpd
      [[email protected] ~]# vi /etc/httpd/conf/httpd.conf
      ServerName www.bb.com
      [[email protected] ~]# vi /var/www/html/index.html
      <h1>Server bb </h1>
      [[email protected] ~]# service httpd restart
      ------DR模式,各真实服务器配置---虚拟地址是相同的---
      [[email protected] ~]# vi web.sh
      #!/bin/bash
      #haha
      ifconfig lo:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 up
      route add -host 192.168.80.188 dev lo:0
      echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
      echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
      echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
      echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
      sysctl -p &>/dev/null
      [[email protected] ~]# sh web.sh

      真机浏览器测试:
      Vmnet1:192.168.80.88
      浏览器输入:http://www.1click-soft.com/tfgjylgw/会轮流出现192.168.80.101和192.168.80.102的页面

       

      负载均衡群集之LVS-NAT

      调度服务器:
      两块网卡:
      Vmnet1内网:192.168.80.100
      Vmnet2外网:192.168.90.100(调度器的地址是外网口地址)
      -------------------------加载LVS内核模块----------------------
      LVS现在已成为Linux内核的一部分,默认编译为ip_vs模块,必要时能够自动调用。以下操作可以手动加载ip_vs模块,并查看当前系统中ip_vs模块的版本信息
      [[email protected] ~]# cat /proc/net/ip_vs
      cat: /proc/net/ip_vs: 没有那个文件或目录
      [[email protected] ~]# modprobe ip_vs //加载ip_vs模块,
      [[email protected] ~]# cat /proc/net/ip_vs //查看ip_vs版本信息
      [[email protected] ~]# rpm -ivh /mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm //安装管理软件,不需要启动

      [[email protected] ~]# vi nat.sh
      #!/bin/bash
      echo "1" > /proc/sys/net/ipv4/ip_forward
      ipvsadm -C
      ipvsadm -A -t 192.168.90.100:80 -s rr
      ipvsadm -a -t 192.168.90.100:80 -r 192.168.80.102:80 -m
      ipvsadm -a -t 192.168.90.100:80 -r 192.168.80.101:80 -m
      ipvsadm -Ln
      [[email protected] ~]# sh nat.sh

      192.168.80.101服务器:
      Vmnet1内网:192.168.80.101
      网关:192.168.80.100
      [[email protected] ~]# yum install -y httpd
      [[email protected] ~]# vi /etc/httpd/conf/httpd.conf
      ServerName www.aa.com
      [[email protected] ~]# vi /var/www/html/index.html
      <h1>Server aa </h1>
      [[email protected] ~]# service httpd restart
      [[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
      GATEWAY=192.168.80.100
      [[email protected] ~]# service network restart

      192.168.80.102服务器:
      Vmnet1内网:192.168.80.102
      网关:192.168.80.100

      [[email protected] ~]# yum install -y httpd
      [[email protected] ~]# vi /etc/httpd/conf/httpd.conf
      ServerName www.bb.com
      [[email protected] ~]# vi /var/www/html/index.html
      <h1>Server bb </h1>
      [[email protected] ~]# service httpd restart
      [[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
      GATEWAY=192.168.80.100
      [[email protected] ~]# service network restart

      真机浏览器测试:
      Vmnet1:192.168.80.88
      Vmnet2:192.168.90.88

      本文永久更新链接地址:https://www.1click-soft.com/Linux/2018-03/151514.htm

      www.1click-soft.comtruehttp://www.1click-soft.com/Linux/1315879.htmlTechArticle负载均衡群集LVS-DR 与 LVS-NAT 负载均衡群集之LVS-DR 调度服务器: 一块网卡: Vmnet1:192.168.80.100 -------------------------加载LVS内核模块----------...

      相关文章

      相关搜索: 负载均衡 LVS-DR LVS-NAT

      帮客评论

      视觉看点
      百度 360 搜狗