Lvs 负载均衡
负载均衡服务http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238716mBOV.png
实验环境下防火墙是关闭了。
搭建负载均衡服务需要4台服务器,本机为客户端。
Nlba和nlbb为软件控制端先在nlba上进行配置
Nlba:
配置yum源安装负载均衡套件
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238716d1AF.png
Yum -y install piranha 安装好之后,
启动piranha套件服务
Servicepiranha-guistart
给piranha的web套件设置访问密码
Piranha-passwd 密码为123
通过web页面访问piranha套件,设置群集
http://127.0.0.1:3636 后面为3636端口
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238717jFZH.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_14152387173nbM.png
因为我的20和10都可以做心跳线所以我写了主从2个
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238717nE4B.png
这里写的10.0.0.2 是我NLBb上的ip,如果NLBa不能正常工作的话,那么NLBb就会接替他的工作
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238717T1dk.png
先添加一个真实的服务
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238717uv24.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_14152387179FQS.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_14152387174Hwk.png
配置完之后,启用
配置群集ip
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238749SYF5.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238749sLpw.png
配置完之后启用
我在NLBa上边配置完之后,配置客户端测试一下!
Web1 realserver配置
安装apache启动apache在apache的 网页存放建立一个网页
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_14152387503PNs.png
安装arp地址表控制软件arptables_jf
配置群集ip到arp的地址解析
arptables-AIN 10.0.0.9-jDROP 这里写的是虚拟ip
arptables-AOUT-s10.0.0.9-jmangle- -mangle-ip-s10.0.0.100
保存arp表内容
Service arptables_jfsave
Chkconfig--level 2345 arptables_jfon 添加为开机启动
给realserver绑定虚拟群集ip
ipaddradd10.0.0.9dev eth0
将此群集虚拟ip设置为开机后自动加载
在/etc/rc.d/rc.local 中添加ip addradd 10.0.0.9deveth0
在web2上配置realserver
和web1的配置一样,只是将真实ip改为10.0.0.200
然后在NLBa上开启路由转发功能l
/etc/sysctl.conf
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238750Xq3J.png将forward=0改为1 就是启用forward路由转发
应用一下
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238750UTF2.png
启用piranha套件
Servicepulse start
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238750JW0n.png
启动起来之后
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238750amng.png
使用客户端访问一下:
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238750KaXp.png
刷新一下
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_141523875030ob.png
接下来配置NLBb
如果NLBa 宕机或者心跳线断掉时,NLBb会接管他的服务,
配置和NLBa一样,只是将piranha网页从的心跳线的ip为NLBa的
配置完ip后先测试和web1 web2 客户端是否能ping通
NLBb上开启路由转发
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238753QTY9.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238753ETr1.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238753vteU.png
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238753mCA6.png
Service pulsestart
如果NLBa在正常运行中启动NLBb的话没有任何变化
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238753OdhK.png
每10秒更新一下
此时将NLBa关机观察NLBb点击刷新过一会就切换过来!
http://xingxing88.blog.运维网.com/attachment/201411/6/4484443_1415238754AsbK.png
Chkconfig - -level 35 piranha-guion
Chkconfig --level35pulseon
Chkconfig --level35sshd on
将piranha套件添加为开启自启动
页:
[1]