主机名 IP  所需软件 
master

eth0==>192.168.30.140(Nat)

eth0:1==>192.168.17.130(Nat)

ipvsadm
node-1 eth0==>192.168.17.131 httpd
node-2 eth0==>192.168.17.132

在master上安装及开启ipvsadm

[root@master ~]# yum install -y ipvsadm
[root@master ~]# cd /etc/sysconfig/network-scripts/
[root@master network-scripts]# cp ifcfg-eth0 ifcfg-eth:
[root@master network-scripts]# vim ifcfg-eth0:1 #只需修改绿色部分三处,其他不要动
DEVICE=eth0:
TYPE=Ethernet
UUID=a186cc9d-8d79--a180-a1b17d884a7b
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=:0C::4D::
IPADDR=192.168.30.130
PREFIX=
GATEWAY=192.168.30.2
DNS1=119.29.29.29
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0:1"
重启网络服务
[root@master ~]# service network restart
Shutting down interface eth0: Device state: (disconnected)
[ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/
[ OK ]
[root@master ~]# ifconfig
eth0 Link encap:Ethernet HWaddr :0C::4D::
inet addr:192.168.30.140 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4d:/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (8.4 KiB) TX bytes: (8.0 KiB) eth0: Link encap:Ethernet HWaddr :0C::4D:: #MAC地址一定要与eth0的一样
inet addr:192.168.30.130 Bcast:192.168.30.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU: Metric:

添加规则

确保这里是0
[root@master ~]# sysctl -p
net.ipv4.ip_forward =
..........
添加规则
[root@master ~]# ipvsadm -A -t 192.168.30.130: -s rr
[root@master ~]# ipvsadm -a -t 192.168.30.130: -r 192.168.30.131 -g
[root@master ~]# ipvsadm -a -t 192.168.30.130: -r 192.168.30.132 -g
[root@master ~]# ipvsadm -L -n
IP Virtual Server version 1.2. (size=)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.30.130: rr
-> 192.168.30.131: Route
-> 192.168.30.132: Route
保存规则
[root@master ~]# /etc/init.d/ipvsadm save
ipvsadm: Saving IPVS table to /etc/sysconfig/ipvsadm: [ OK ]

在realserver(node-1和node-2)上

生成ifcfg-lo:1文件
[root@node- ~]# cd /etc/sysconfig/network-scripts/
[root@node- network-scripts]# cp ifcfg-lo ifcfg-lo:
[root@node- network-scripts]# vim ifcfg-lo:
DEVICE=lo:
IPADDR=192.168.30.130
NETMASK=255.255.255.255
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
ONBOOT=yes
NAME=loopback

关闭ARP转发

[root@node- ~]# vim /etc/sysctl.conf  #末未添加
net.ipv4.conf.eth0.arp_ignore =
net.ipv4.conf.eth0.arp_announce =
[root@node- ~]# sysctl -p #使立即生效
net.ipv4.ip_forward =
.....
net.ipv4.conf.eth0.arp_ignore =
net.ipv4.conf.eth0.arp_announce =

修改网关

[root@node- ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
GATEWAY=192.168.30.2
#网关修改为指向外网出口的路由器IP

创建测试页面

[root@node- ~]# echo "<h1>This is the node-1 Web-Server:192.168.17.131</h1>" > /var/www/html/index.html 

在node-2上

[root@node- ~]# cd /etc/sysconfig/network-scripts/
[root@node- network-scripts]# cp ifcfg-lo ifcfg-lo:
[root@node- network-scripts]# vim ifcfg-lo:
DEVICE=lo:
IPADDR=192.168.30.130
NETMASK=255.255.255.255
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
ONBOOT=yes
NAME=loopback
[root@node- ~]# service network restart
Shutting down interface eth0: Device state: (disconnected)
[ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/
[ OK ]
[root@node- ~]# ifconfig
eth0 Link encap:Ethernet HWaddr :::2F::4D
inet addr:192.168.30.132 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80:::56ff:fe2f:844d/ Scope:Link
...................
lo: Link encap:Local Loopback
inet addr:192.168.30.130 Mask:255.255.255.255
UP LOOPBACK RUNNING MTU: Metric:

关闭ARP转发通node-1操作一样;

创建测试页面

[root@node- ~]# echo "<h1>This is the node-2 Web-Server:192.168.17.132</h1>" > /var/www/html/index.html
[root@node- ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

物理机使用浏览器访问测试

RHEL 6.5----LVS(DR)的更多相关文章

  1. LVS(二):四种工作模型

    面试的时候必问这个四种工作模式,因为这几乎是企业里面必用的内容,所以一定要将其理解通透. 一.lvs-nat模式 二.LVS-DR模式(默认) 三.LVS-tun模式 四.LVS-fullnat模式 ...

  2. 校园客户端(DR)启动后提示我们缺失packet.dll,无法正常启动(7)

    有的时候校园客户端(DR)启动后提示我们缺失packet.dll,无法正常启动,然而我们重装了客户端后任然不感冒,那么问题来了,问题解决不了往往源于我们对问题的本质不够了解,如果了解问题的本质,那么问 ...

  3. 从一个开发的角度看负载均衡和LVS(转)

    原文:http://blog.hesey.net/2013/02/introduce-to-load-balance-and-lvs-briefly.html 在大规模互联网应用中,负载均衡设备是必不 ...

  4. Linux负载均衡--LVS(IPVS)

    一.LVS简介 LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目,现在已经是 Linux标准内核的一部分.LVS是一种叫基于T ...

  5. RHEL 7特性说明(七):编译程序及工具

    转载自:RedHat https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/7.0_Release ...

  6. RHEL 7特性说明(六):集群

    来自:Linux中国  2014-07-16 00:00:00  ed Hat Enterprise Linux 7.0 是 Red Hat 的下一代操作系统完整套件,旨在用于关键任务企业级计算以及顶 ...

  7. LVS(五)LVS的持久连接

    什么是持久链接 把某个客户端的请求始终定向到同一应用服务器上.对于LVS来说持久连接和算法没有关系.也就是使用任何算法LVS都可以实现同一客户端的请求转发到之前选定的应用服务器,以保持会话.而且还能实 ...

  8. CentOS6.4 配置LVS(DR模式)

    DR模式中LVS主机与实际服务器都有一块网卡连在同一物理网段上. IP分配 VIP:10.10.3.170 RIP1:10.10.3.140 RIP2:10.10.3.141 1.安装所需的依赖包 y ...

  9. 自动化脚本-配置LVS(DR模式)

    一,获取所需配置的主机IP cat get_ip.sh #!/bin/bash #将获得到的IP地址写进IP.txt >ip.txt #将原有的hosts信息清除 >/root/.ssh/ ...

随机推荐

  1. UIProgress控件的属性和方法

    进度条控件是IOS开发中一个简单的系统控件,使用总结如下: 初始化一个进度条: - (instancetype)initWithProgressViewStyle:(UIProgressViewSty ...

  2. 传统maven项目创建

    转自:https://blog.csdn.net/wangfengtong/article/details/77098238 需求表均同springmvc案例 此处只是使用maven 注意,以下所有需 ...

  3. NOIP2016总结

    Day1: T1:模拟: #include<iostream> #include<cstdio> #include<cstdlib> #include<cst ...

  4. YTU 2203: 最小节点(线性表)

    2203: 最小节点(线性表) 时间限制: 1 Sec  内存限制: 128 MB 提交: 243  解决: 204 题目描述 (线性表)设有一个由正整数组成的无序(向后)单链表,编写完成下列功能的算 ...

  5. html5--6-60 阶段练习7-下拉菜单

    html5--6-60 阶段练习7-下拉菜单 学习要点 综合运用所学过的知识完成一个下拉菜单的小练习,加深对学过知识点的综合应用能力. <!DOCTYPE html> <html l ...

  6. html5--6-2 CSS语法

    html5--6-2 CSS语法 实例 学习要点 掌握引入外部样式表方法 插入样式的三种方法 内联样式表(行内) 内部样式表(style中) 外部样式表 创建一个外部样式表 在head中使用link元 ...

  7. 多线程-threading模块3

    超级播放器 #coding:utf-8 import threading from time import sleep,ctime #超级播放器 def super_player(file,time) ...

  8. 【重要】Selenium2+python自动化44-元素定位参数化(find_element)

    转:https://www.cnblogs.com/yoyoketang/p/6551274.html 前言 元素定位有八种方法,这个能看到这一篇的小伙伴都知道了,那么有没有一种方法,可以把八种定位合 ...

  9. backface-visibility

    浏览器支持 只有 Internet Explorer 10+ 和 Firefox 支持 backface-visibility 属性. Opera 15+.Safari 和 Chrome 支持替代的 ...

  10. SpringBoot整合Ribbon注入RestTemplate实例找不到原因

    通过把@LoadBalanced注解放在创建RestTemplate对象的方法上,可以正常运行:如果放在属性上,会导致找不到RestTemplate Bean