zoukankan      html  css  js  c++  java
  • Lvs网络负载均衡 隧道(ip tunl)

    win7网络配置

      200.168.10.4 255.255.255.0

    lvs server

      #ifconfig eth0 200.168.10.1

      #ifconfig eth1 down

    webserver1

      #route del default

      #ifconfig eth0 200.168.10.2

    webserver2

      #ifconfig eth0 200.168.10.3

      #route del default

    server、web1、web2都使用vmnet1网卡,关闭防火墙,启动apache

    vip  配置虚拟ip(在lvs server中)

      #ifconfig tunl(小写字母l)0 200.168.10.10netmask 255.255.255.255 up

      #route add -host 200.168.10.10 dev tunl0

    使用route -n,ifconfig tunl0分别查看配置情况

    地址转换脚本

      #vi ipvs.sh

    # /bin/bash
    # ipvs.sh
    ipvsadm -C
    ipvsadm -At 200.168.10.10:80 -s rr
    ipvsadm -at 200.168.10.10:80 -r 200.168.10.2:80 -i
    ipvsadm -at 200.168.10.10:80 -r 200.168.10.3:80 -i
    ipvsadm -L -n

      #chmod a+x ipvs.sh

      #./ipvs.sh

    webserver1、webserver2配置

      #vi arp.sh

    # /bin/bash
    # arp.sh
    ifconfig tunl0 200.168.10.10    netmask 255.255.255.255 up
    route add -host 200.168.10.10 dev tunl0
    
    echo 1 >/proc/sys/net/ipv4/conf/tunl0/arp_ignore
    echo 2 >/proc/sys/net/ipv4/conf/tunl0/arp_announce
    echo 3 >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo 4 >/proc/sys/net/ipv4/conf/all/arp_announce

      #chmod a+x arp.sh

      #./arp.sh

    浏览器 200.168.10.10,刷新页面查看轮询访问效果

    lsv server 

      #ipvsadm -L -n 查看访问的情况

  • 相关阅读:
    FIFO深度计算
    php学习笔记--函数
    php学习笔记--类型转换
    php学习笔记--变量与常量
    css之伪对象-webkit-scrollbar
    8大排序算法
    正则表达式
    SDC Tcl package of Timequest
    面试经历之今日头条
    《Linux高性能服务器编程》学习总结(十三)——多进程编程
  • 原文地址:https://www.cnblogs.com/hwt987/p/3676076.html
Copyright © 2011-2022 走看看