RHEL 6.5----LVS(DR)
| 主机名 | 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)的更多相关文章
- LVS(二):四种工作模型
面试的时候必问这个四种工作模式,因为这几乎是企业里面必用的内容,所以一定要将其理解通透. 一.lvs-nat模式 二.LVS-DR模式(默认) 三.LVS-tun模式 四.LVS-fullnat模式 ...
- 校园客户端(DR)启动后提示我们缺失packet.dll,无法正常启动(7)
有的时候校园客户端(DR)启动后提示我们缺失packet.dll,无法正常启动,然而我们重装了客户端后任然不感冒,那么问题来了,问题解决不了往往源于我们对问题的本质不够了解,如果了解问题的本质,那么问 ...
- 从一个开发的角度看负载均衡和LVS(转)
原文:http://blog.hesey.net/2013/02/introduce-to-load-balance-and-lvs-briefly.html 在大规模互联网应用中,负载均衡设备是必不 ...
- Linux负载均衡--LVS(IPVS)
一.LVS简介 LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目,现在已经是 Linux标准内核的一部分.LVS是一种叫基于T ...
- RHEL 7特性说明(七):编译程序及工具
转载自:RedHat https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/7.0_Release ...
- RHEL 7特性说明(六):集群
来自:Linux中国 2014-07-16 00:00:00 ed Hat Enterprise Linux 7.0 是 Red Hat 的下一代操作系统完整套件,旨在用于关键任务企业级计算以及顶 ...
- LVS(五)LVS的持久连接
什么是持久链接 把某个客户端的请求始终定向到同一应用服务器上.对于LVS来说持久连接和算法没有关系.也就是使用任何算法LVS都可以实现同一客户端的请求转发到之前选定的应用服务器,以保持会话.而且还能实 ...
- CentOS6.4 配置LVS(DR模式)
DR模式中LVS主机与实际服务器都有一块网卡连在同一物理网段上. IP分配 VIP:10.10.3.170 RIP1:10.10.3.140 RIP2:10.10.3.141 1.安装所需的依赖包 y ...
- 自动化脚本-配置LVS(DR模式)
一,获取所需配置的主机IP cat get_ip.sh #!/bin/bash #将获得到的IP地址写进IP.txt >ip.txt #将原有的hosts信息清除 >/root/.ssh/ ...
随机推荐
- SpringMVC中返回JSON时乱码的解决方案
springMVC中返回JSON会出现乱码,解决如下: produces = "text/html;charset=UTF-8" @ResponseBody @RequestMap ...
- js modify local file
https://stackoverflow.com/questions/4561157/is-it-possible-to-modify-a-html-file-from-which-the-scri ...
- jQuery.ajaxSetup()
jQuery.ajaxSetup()函数用于设置AJAX的全局默认设置. 该函数用于更改jQuery中AJAX请求的默认设置选项.之后执行的所有AJAX请求,如果对应的选项参数没有设置,将使用更改后的 ...
- 如何去除Office Excel的密码保护?
企图更改Excel文件内容,然而却弹出如下提示: 根据提示,我尝试解除保护表,却要求输入密码: 这就尴尬了=_=密码不是我设定的 问了度娘,找到了解决方案 将Excel文件扩展名更改为rar, 使用压 ...
- Replace Type Code With Class和Replace Type Code With Subclass和Replace Type Code With State/Strategy
周末闲来写写看书总结,今天写<重构>中的3个重要手法,分别是Replace Type Code With Class.Replace Type Code With Subclass和Rep ...
- 移动web开发适配rem
移动的meta标签 <meta name="viewport" content="width=device-width, initial-scale=1,user ...
- uptime命令
uptime命令能够打印系统总共运行了多长时间和系统的平均负载.uptime命令可以显示的信息显示依次为:现在时间.系统已经运行了多长时间.目前有多少登陆用户.系统在过去的1分钟.5分钟和15分钟内的 ...
- flywaydb and sql server
https://flywaydb.org/documentation/database/sqlserver How Flyway works https://flywaydb.org/getstart ...
- Silverlight中使用MVVM(4)
Silverlight中使用MVVM(1)--基础 Silverlight中使用MVVM(2)—提高 Silverlight中使用MVVM(3)—进阶 Silverlight中使用MVVM(4)—演练 ...
- Android 不同阶段 Logo 显示
/********************************************************************* * Android 不同阶段 Logo 显示 * 说明: ...