Rhel6-keepalived+lvs配置文档
系统环境: rhel6 x86_64 iptables and selinux disabled
主机: 192.168.122.119 server19.example.com
192.168.122.25 server25.example.com
192.168.122.163 server63.example.com
192.168.122.193 server93.example.com
所需的包:keepalived-1.2.7.tar.gz
Realserver1
192.168.122.163:apache
Realserver2
192.168.122.193:apache
Load
Balance 192.168.122.119:keepalived
Load
Balance 192.168.122.25:keepalived
Virtual
IP 192.168.122.178
以下步骤在server19和server25上实施:
[root@server19
~]# yum install kernel-devel make gcc -y
[root@server19
~]# yum install openssl-devel popt-devel -y
[root@server19
~]# yum install libnl-devel -y
以下步骤在server19或server25上实施:
[root@server19
kernel]# tar zxf keepalived-1.2.7.tar.gz
[root@server19
kernel]# cd keepalived-1.2.7
[root@server19
keepalived-1.2.7]# ./configure –prefix=/usr/local/keepalived
[root@server19
keepalived-1.2.7]# make && make install
[root@server19
keepalived-1.2.7]# scp -r /usr/local/keepalived/
root@192.168.122.25:/usr/local/
以下步骤在server19和server25上实施:
[root@server19
keepalived-1.2.7]# ln -s /usr/local/keepalived/etc/keepalived/ /etc/
[root@server19
keepalived-1.2.7]# ln -s
/usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@server19
keepalived-1.2.7]# ln -s
/usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[root@server19
keepalived-1.2.7]# ln -s /usr/local/keepalived/sbin/keepalived
/sbin/
注:系统镜像的负载均衡套件中也集成了keepalived,也可以直接使用yum
install keepalived -y进行安装。但需先配置yum源:
[LoadBalancer]
name=Instructor
Server Repository
baseurl=ftp://192.168.122.1/pub/yum/LoadBalancer
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
以下步骤在server19实施:
[root@server19
~]# vim /etc/keepalived/keepalived.conf
global_defs
{
notification_email {
root@localhost 错误发送至此邮箱
}
notification_email_from keepalived@server19.example.com
发信人
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance
VI_1 {
state MASTER 角色:(1)MASTER
(2)BACKUP
interface eth0
virtual_router_id 51 (主备的配置需要一致)
priority 100 优先级(数字越大,优先级越高)
advert_int 1
authentication {
auth_type PASS 认证类型
auth_pass 1111 认证密码
}
virtual_ipaddress {
192.168.122.178 虚拟IP,可设置多个
}
}
virtual_server
192.168.122.178 80 {
delay_loop 6
lb_algo rr
lb_kind DR
#
nat_mask 255.255.255.0
#
persistence_timeout 50
protocol TCP
real_server 192.168.122.163 80 {
weight 1
TCP_CHECK {
(注:TCP_CHECK和大括号之间要有空格)
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.193 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
以下步骤在server25实施:
[root@server25
~]# vim /etc/keepalived/keepalived.conf
global_defs
{
notification_email {
root@localhost 错误发送至此邮箱
}
notification_email_from keepalived@server25.example.com
发信人
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance
VI_1 {
state BACKUP 角色:(1)MASTER
(2)BACKUP
interface eth0
virtual_router_id 51 (主备的配置需要一致)
priority 50 优先级(数字越大,优先级越高)
advert_int 1
authentication {
auth_type PASS 认证类型
auth_pass 1111 认证密码
}
virtual_ipaddress {
192.168.122.178 虚拟IP,可设置多个
}
}
virtual_server
192.168.122.178 80 {
delay_loop 6
lb_algo rr
lb_kind DR
#
nat_mask 255.255.255.0
#
persistence_timeout 50
protocol TCP
real_server 192.168.122.163 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.193 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
以下步骤在server63上实施:
[root@server63
~]# yum install arptables_jf httpd -y
[root@server63
~]# arptables -A IN -d 192.168.122.178 -j DROP
[root@server63
~]# arptables -A OUT -s 192.168.122.178 -j mangle --mangle-ip-s
192.168.122.163
[root@server63
~]# /etc/init.d/arptables_jf save
[root@server63
~]# ifconfig eth0:0 192.168.122.178 netmask 255.255.255.255 up
或
[root@server63
~]# ip addr add 192.168.122.178 dev eth0
注:可用ip
addr show查看
[root@server63
~]# echo `hostname` > /var/www/html/index.html
[root@server63
~]# /etc/init.d/httpd start
以下步骤在server93上实施:
[root@server93
~]# yum install arptables_jf httpd -y
[root@server93
~]# arptables -A IN -d 192.168.122.178 -j DROP
[root@server93
~]# arptables -A OUT -s 192.168.122.178 -j mangle --mangle-ip-s
192.168.122.193
[root@server93
~]# /etc/init.d/arptables_jf save
[root@server93
~]# ifconfig eth0:0 192.168.122.178 netmask 255.255.255.255 up
或
[root@server93
~]# ip addr add 192.168.122.178 dev eth0
注:可用ip
addr show查看
[root@server93
~]# echo `hostname` > /var/www/html/index.html
[root@server93
~]# /etc/init.d/httpd start
以下步骤在server19和server25上实施:
[root@server19
~]# /etc/init.d/keepalived start
测试:
执行ip
addr show可查看虚拟IP,执行ipvsadm
-l查看规则是否加载,访问192.168.122.178反复刷新网页,每次出现的页面都不同说明配置成功.
当主备挂掉后可由另一台接管,当两台都正常时由Master充当调度器.
#配置多个服务(apache+ftp)
以下步骤在server19实施:
[root@server19
~]# vim /etc/keepalived/keepalived.conf
global_defs
{
notification_email {
root@localhost
}
notification_email_from keepalived@server19.example.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance
VI_1 {
state MASTER
interface eth0
virtual_router_id 51 (主备的配置需要一致)
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.122.178 虚拟IP,可设置多个
}
}
virtual_server
192.168.122.178 80 {
delay_loop 6
lb_algo rr
lb_kind DR
#
nat_mask 255.255.255.0
#
persistence_timeout 50
protocol TCP
real_server 192.168.122.163 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.193 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
virtual_server
192.168.122.178 21 {
delay_loop 6
lb_algo rr
lb_kind DR
#
nat_mask 255.255.255.0
persistence_timeout 50 持续连接时间为50s
protocol TCP
real_server 192.168.122.163 21 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.193 21 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
以下步骤在server25实施:
[root@server25
~]# vim /etc/keepalived/keepalived.conf
global_defs
{
notification_email {
root@localhost
}
notification_email_from keepalived@server25.example.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance
VI_1 {
state BACKUP
interface eth0
virtual_router_id 51 (主备的配置需要一致)
priority
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.122.178 虚拟IP,可设置多个
}
}
virtual_server
192.168.122.178 80 {
delay_loop 6
lb_algo rr
lb_kind DR
#
nat_mask 255.255.255.0
#
persistence_timeout 50
protocol TCP
real_server 192.168.122.163 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.193 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
virtual_server
192.168.122.178 21
{
delay_loop 6
lb_algo rr
lb_kind DR
#
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.122.163 21 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.122.193 21 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
以下步骤在server63上实施:
[root@server63
~]# yum install arptables_jf httpd vsftpd -y
[root@server63
~]# arptables -A IN -d 192.168.122.178 -j DROP
[root@server63
~]# arptables -A OUT -s 192.168.122.178 -j mangle --mangle-ip-s
192.168.122.163
[root@server63
~]# /etc/init.d/arptables_jf save
[root@server63
~]# ifconfig eth0:0 192.168.122.178 netmask 255.255.255.255 up
或
[root@server63
~]# ip addr add 192.168.122.178 dev eth0
注:可用ip
addr show查看
[root@server63
~]# echo `hostname` > /var/www/html/index.html
[root@server63
~]# /etc/init.d/httpd start
[root@server63
~]# touch /var/ftp/server63
[root@server63
~]# /etc/init.d/vsftpd start
以下步骤在server93上实施:
[root@server93
~]# yum install arptables_jf httpd vsftpd -y
[root@server93
~]# arptables -A IN -d 192.168.122.178 -j DROP
[root@server93
~]# arptables -A OUT -s 192.168.122.178 -j mangle --mangle-ip-s
192.168.122.193
[root@server93
~]# /etc/init.d/arptables_jf save
[root@server93
~]# ifconfig eth0:0 192.168.122.178 netmask 255.255.255.255 up
或
[root@server93
~]# ip addr add 192.168.122.178 dev eth0
注:可用ip
addr show查看
[root@server93
~]# echo `hostname` > /var/www/html/index.html
[root@server93
~]# /etc/init.d/httpd start
[root@server93
~]# touch /var/ftp/server93
[root@server93
~]# /etc/init.d/vsftpd start
以下步骤在server19和server25上实施:
[root@server19
~]# /etc/init.d/keepalived start
Rhel6-keepalived+lvs配置文档的更多相关文章
- Rhel6-heartbeat+lvs配置文档
系统环境: rhel6 x86_64 iptables and selinux disabled 主机: 192.168.122.119 server19.example.com 192.168.12 ...
- 最详细的keepalived+lvs-dr配置文档
四台台机器: 分发器主:192.168.0.154 分发器备:192.168.0.171 rs_1:192.168.0.131 rs_2:192.168.0.132 keepalived安装: yum ...
- MYSQL服务器my.cnf配置文档详解
MYSQL服务器my.cnf配置文档详解 硬件:内存16G [client] port = 3306 socket = /data/3306/mysql.sock [mysql] no-auto-re ...
- 转!!Java代码规范、格式化和checkstyle检查配置文档
为便于规范各位开发人员代码.提高代码质量,研发中心需要启动代码评审机制.为了加快代码评审的速度,减少不必要的时间,可以加入一些代码评审的静态检查工具,另外需要为研发中心配置统一的编码模板和代码格式化模 ...
- Hibernate配置文档详解
Hibernate配置文档有框架总部署文档hibernate.cfg.xml 和映射类的配置文档 ***.hbm.xml hibernate.cfg.xml(文件位置直接放在src源文件夹即可) (在 ...
- Java代码规范、格式化和checkstyle检查配置文档
http://www.blogjava.net/amigoxie/archive/2014/05/31/414287.html 文件下载: http://files.cnblogs.com/files ...
- Spring Hibernate4 整合配置文档
1 applicationContext.xml配置文档 <?xml version="1.0" encoding="UTF-8"?><bea ...
- Kerberos主从配置文档
Kerberos主从配置文档 1. Kerberos主从同步机制 在Master上通过以下命令同步数据: kdb5_util dump /var/kerberos/krb5kdc/slave_db ...
- python常用模块-配置文档模块(configparser)
python常用模块-配置文档模块(configparser) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. ConfigParser模块用于生成和修改常见配置文档,当前模块的名称 ...
随机推荐
- Android5.0新控件CardView的介绍和使用
CardView也是5.0的新控件,这控件其实就是一个卡片啦,当然我们自己也完全可以定义这样一个卡片,从现在的微博等社App中可以看到各式各样的自定义卡片,所以这个控件意义不是很大.suppor ...
- Android开发面试经——1.常见人事面试问题
Android开发(29) 版权声明:本文为寻梦-finddreams原创文章,请关注:http://blog.csdn.net/finddreams 做为程序员,我们都是有梦想的人,有时候当我 ...
- Win7/8下提示OpenSCManager failed 拒绝访问
在我们日常使用命令行安装一些工具的时候经常提示如下错误提示,这是上市Win7或者Win8操作系统权限的原因 工具/原料 Win7,Win8操作系统 方法/步骤 1 以Win8为例,按WIN+Q ...
- JS 判断当前使用浏览器名及版本
由于我的后台系统的上传图片不支持IE浏览器的,所以我需要判断公司人员在使用后台系统的时候,是否使用的浏览器是IE的. // 获取当前浏览器名 及 版本号 function appInfo(){ var ...
- EI中国
这里可以看到EI收录的所有的中国期刊:http://lib.sytu.edu.cn/files/zwwxx/2009-EI-china.htm
- 删除github账号的方法
如果你不想使用自己的github账号了,github官网允许你删除账号,具体操作步骤为: 1.登录github网站,网站右上角的头像,在下拉菜单中选择"Settings"(设置): ...
- icp算法的一些参考资料
1.综述:迭代最近点算法综述,介绍了svd分解和四元数法,其中 svd法:http://blog.csdn.net/kfqcome/article/details/9358853 四元数法:http: ...
- Oracle session inactive状态临时表数据未清空问题
问题描述:Oracle数据库,java代码使用某数据库实例,获取connection并在使用结束关闭,而session未销毁,而是状态变为inactive从而导致临时表数据未清空. Oracle临时表 ...
- linux笔记:权限管理命令chmod,chown,chgrp,umask
权限对文件和目录的含义是不同的:对文件来说:读:可以查看文件内容写:可以修改文件内容执行:可以执行文件对目录来说:读:可以列出目录中的内容写:可以在目录中创建.删除文件执行:可以进入目录 能够更改文件 ...
- python 练习 4
#!/usr/bin/python # -*- coding: utf-8 -*- from math import sqrt import random def daoxu(n): d=n s=0 ...