359025439 发表于 2019-1-5 06:01:47

lvs dr模式安装

  lvs dr模式安装
  环境:centos5.5 (注:测试环境均为centos5.5,在虚拟机上虚拟三个centos系统)
  vip 192.168.3.169
  lb真是ip192.168.3.168
  server1 ip:192.168.10.2
  server1 ip:192.168.10.3
  rpm包安装ipvsadmin
  I lb上边配置
  1 复制网卡ifcfg-eth0:1
  DEVICE=eth0:1
  BOOTPROTO=none
  IPADDR=192.168.3.169
  NETMASK=255.255.0.0

  ONBOOT=yes
  2 开启路由转发功能 vim /etc/sysctl.conf

  net.ipv4.ip_forward = 1
  3添加脚本

  #!/bin/sh
  ipvsadm -C
  ipvsadm -A -t 192.168.3.169:80 -s wlc
  ipvsadm -a -t 192.168.3.169:80 -r 192.168.10.2 -g
  ipvsadm -a -t 192.168.3.169:80 -r 192.168.10.3 -g
  

  II server上边配置
  1 cp换回接口 ifcfg-lo:1
  DEVICE=lo:1
  IPADDR=192.168.3.169
  NETMASK=255.255.255.255
  NETWORK=192.168.3.169
  ONBOOT=yes
  ARP=no
  

  2开启路由转发 vim /etc/sysctl.conf
  net.ipv4.ip_forward = 1
  添加
  

  net.ipv4.conf.lo.arp_ignore = 1
  net.ipv4.conf.all.arp_announce = 2
  net.ipv4.conf.all.arp_ignore = 1
  net.ipv4.conf.all.arp_announce = 2
  

  使用sysctl -p 保存
  两台服务器同样的配置
  III 在lb上启动ipvsadm
  

  service ipvsadm start
  Clearing the current IPVS table:            [确定]
  Applying IPVS configuration: /etc/init.d/ipvsadm: line 62: /etc/sysconfig/ipvsadm: 没有那个文件或目录
  [失败]
  

  出现这样的错误service ipvsadm save 然后再重启
  运行刚才的脚本
  查看状态
  ipvsadm -L -n
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port      Forward Weight ActiveConn InActConn
  TCP 192.168.3.169:80 wlc
  -> 192.168.10.3:80       Route1   0   28
  -> 192.168.10.2:80       Route1   0   27
  




页: [1]
查看完整版本: lvs dr模式安装