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/ ...
随机推荐
- chmod|chown|chgrp和用法和区别
1.chgrp(改变文件所属用户组) chgrp 用户组 文件名 ###就是这个格了.如果整个目录下的都改,则加-R参数用于递归. 如:chgrp -R user smb.conf 2.c ...
- 使用iconv的包装类CharsetConverter进行编码转换的示例
GitHub地址https://github.com/BuYishi/charset_converter_test charset_converter_test.cpp #include <io ...
- (28)java web的hibernate使用
Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQL语句,自 ...
- 恢复MySQL数据库删除的数据
在日常运维工作中,对于数据库的备份是至关重要的!数据库对于网站的重要性使得我们对 MySQL 数据库的管理不容有失!然而是人总难免会犯错误,说不定哪天大脑短路了,误操作把数据库给删除了,怎么办? 下面 ...
- mysql字符串的常用函数(截取和拼接)
#截取字符串(先正序取2个,再倒序取1个)SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('aaa-gg-cc-dd','-',2),'-',-1) #获取子表某个字段的 ...
- Vijos P1389婚礼上的小杉
背景 小杉的幻想来到了经典日剧<求婚大作战>的场景里……他正在婚礼上看幻灯片,一边看着可爱的新娘长泽雅美,一边想,如果能再来一次就好了(-.-干嘛幻想这么郁闷的场景……). 小杉身为新一代 ...
- dedecms5.7二级域名文章图片不显示修改方法.相对路径改为绝对路径的方法
dedecms5.7(织梦CMS5.7)二级域名文章图片不显示修改方法.相对路径改为绝对路径的方法 dedecms升级到5.7SP1后,开启二级域名,你会发现,在二级域名下的文章,上传的图片地址都是: ...
- codeforces 696B B. Puzzles(树形dp+概率)
题目链接: B. Puzzles time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- fastText入门
简介fastText是Facebook AI Research在2016年提出的文本分类和词训练的工具.它最大的特点:模型非常简单,训练速度快,并且能够达到与深度学习旗鼓相当的精度. 最近在做一个给微 ...
- bzoj 1657 Mooo 奶牛的歌声 —— 单调栈
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1657 单调栈水题. 代码如下: #include<iostream> #incl ...