CentOS6.4 配置HAProxy+Keepalived
安装HAProxy请参考
http://www.cnblogs.com/kgdxpr/p/3272861.html
安装Keepalived
1、下载安装依赖包
yum install -y wget make gcc openssl-devel popt-devel
2、下载、安装Keepalived
wget http://www.keepalived.org/software/keepalived-1.2.8.tar.gz
tar zxvf keepalived-1.2..tar.gz
cd keepalived-1.2.
./configure --prefix=/usr/local/keepalived
make
make install
3、安装成功后做成服务模式。
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
4、配置文件
mkdir -p /etc/keepalived/
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
chmod +x /etc/init.d/keepalived
vi /etc/keepalived/keepalived.conf
global_defs {
router_id LVS_DEVEL
}
#监测haproxy进程状态,每2秒执行一次
vrrp_script chk_haproxy {
script "/etc/keepalived/chk_haproxy.sh"
interval
weight
}
vrrp_instance VI_1 {
state MASTER #从服务器为BACKUP
interface eth0
virtual_router_id
priority #从服务器要低于100
advert_int
mcast_src_ip 10.10.3.171 #MASTER服务器IP,从服务器写从服务器的IP
authentication {
auth_type PASS
auth_pass 111111
}
track_script {
chk_haproxy #监测haproxy进程状态
}
virtual_ipaddress {
10.10.3.170 #虚拟IP
}
}
chk_haproxy.sh内容
vi /etc/keepalived/chk_haproxy.sh
status=$(ps aux|grep haproxy | grep -v grep | grep -v bash | wc -l)
if [ "${status}" = "" ]; then
/etc/init.d/haproxy start status2=$(ps aux|grep haproxy | grep -v grep | grep -v bash |wc -l) if [ "${status2}" = "" ]; then
/etc/init.d/keepalived stop
fi
fi
启动和关闭服务
service keepalived start
service keepalived stop
高可用测试
、将Master上的keepalived停止 查看Master上的日志 tail -f /var/log/messages Sep :: Keepalived[]: Stopping Keepalived v1.2.8 (/,)
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) sending priority
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) removing protocol VIPs. 发现Master释放了VIP 再查看Backup上的日志 Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Transition to MASTER STATE
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Entering MASTER STATE
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) setting protocol VIPs.
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.10.3.180
Sep :: Keepalived_healthcheckers[]: Netlink reflector reports IP 10.10.3.180 added 发现Backup绑定了VIP 、将Master上的keepalived启动 查看Master上的日志 tail -f /var/log/messages Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Entering MASTER STATE
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) setting protocol VIPs.
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.10.3.180
Sep :: Keepalived_healthcheckers[]: Netlink reflector reports IP 10.10.3.180 added 发现Master绑定了VIP 再查看Backup上的日志 Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Received higher prio advert
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) Entering BACKUP STATE
Sep :: Keepalived_vrrp[]: VRRP_Instance(VI_1) removing protocol VIPs.
Sep :: Keepalived_healthcheckers[]: Netlink reflector reports IP 10.10.3.180 removed 发现Backup释放了VIP
CentOS6.4 配置HAProxy+Keepalived的更多相关文章
- RabbitMQ集群安装配置+HAproxy+Keepalived高可用
RabbitMQ集群安装配置+HAproxy+Keepalived高可用 转自:https://www.linuxidc.com/Linux/2016-10/136492.htm rabbitmq 集 ...
- CentOS6.4 配置Haproxy
Haproxy下载地址:http://pan.baidu.com/share/link?shareid=1787182295&uk=1829018343 也可用wget http://hapr ...
- HaProxy+Keepalived+Mycat高可用群集配置
概述 本章节主要介绍配置HaProxy+Keepalived高可用群集,Mycat的配置就不在这里做介绍,可以参考我前面写的几篇关于Mycat的文章. 部署图: 配置 HaProxy安装 181和1 ...
- 广州项目实施步骤II_练习配置HaProxy的重定向负载均衡
CentOS6.4 配置Haproxy Haproxy下载地址:http://pan.baidu.com/share/link?shareid=1787182295&uk=18290183 ...
- Haproxy+keepalived高可用集群实战
1.1 Haproxy+keepalived高可用集群实战 随着互联网火热的发展,开源负载均衡器的大量的应用,企业主流软件负载均衡如LVS.Haproxy.Nginx等,各方面性能不亚于硬件负载均衡 ...
- Haproxy+Keepalived高可用负载均衡详细配置
本文所使用的环境: 10.6.2.128 centos6.5 10.6.2.129 centos6.5 VIP 为10.6.2.150 要实现的目标: 实现10.6.2.128和10.6 ...
- RabbitMQ高可用配置(Haproxy + Keepalived)
网络结构如下图: 共有104.105.106三台RabbitMQ Server,互为集群 其中104和105安装了Haproxy,每个Haproxy承担三台RabbitMQ server的负载均衡 两 ...
- saltstack自动化运维系列⑥SaltStack实践安装配置HAproxy的Keepalived
saltstack自动化运维系列⑥SaltStack实践安装配置HAproxy的Keepalived 安装配置Keepalived 1.编写功能模块 #创建keepalived目录# mkdir -p ...
- haproxy+keepalived主备与双主模式配置
Haproxy+Keepalived主备模式 主备节点设置 主备节点上各安装配置haproxy,配置内容且要相同 global log 127.0.0.1 local2 chroot /var/lib ...
随机推荐
- Struts2中通配符的使用
1.准备工作 新建一个JavaWeb项目HelloWord,导入Struts2的.jar包,在Web.xml下配置Struts2的监听,在src下添加Struts2的配置文件struts.xml:将该 ...
- BZOJ 3540 realtime-update 解题
分析一下题意,大约是给定一串牛,然后找到一个跨越距离最长的牛子串使得在这个范围内白牛和花牛一样多. 白牛可以任意涂成花牛. 既然"白牛可以任意涂成花牛",那么我们需要找到一个最长的 ...
- SphinxSE的安装
SphinxSE 的使用 SphinxSE 的使用 :wiki SphinxSE是一个可以编译进MySQL 5.x版本的MySQL存储引擎,尽管被称作“存储引擎”,SphinxSE自身其实并不存储任何 ...
- 《C#高级编程》学习笔记------C#中的委托和事件(续)
本文转载自张子阳 目录 为什么要使用事件而不是委托变量? 为什么委托定义的返回值通常都为void? 如何让事件只允许一个客户订阅?(事件访问器) 获得多个返回值与异常处理 委托中订阅者方法超时的处理 ...
- 14.约瑟夫环问题[JosephusProblem]
[题目] n个数字(0,1,…,n-1)形成一个圆圈,从数字0开始,每次从这个圆圈中删除第m个数字(第一个为当前数字本身,第二个为当前数字的下一个数字).当一个数字删除后,从被删除数字的下一个继续删除 ...
- iOS 关于objectForKey返回类型是不是mutable
以前看NSUserDefault时,记住了那里的objectForKey返回的一定是immutable的对象.现在有点弄混了,其实,NSObject的objectForKey方法没有这个限制,是可以返 ...
- iOS 和Android中的基本日期处理
提到日期处理,主要有2个参数,一个是所在的时区,一个是所用的日历方法. 主要涉及2大类问题,一类是日期类型和字符串之间的转化,另一类是日期的计算问题.ios和android都提供了相应的类来处理问题. ...
- codeforces 474D.Flowers 解题报告
题目链接:http://codeforces.com/problemset/problem/474/D 题目意思:Marmot 吃两种类型的花(实在难以置信呀--):red 或者 white,如果要吃 ...
- ubuntu tar 命令详细讲解
Ubuntu--tar命令 tar zxvf ut6410-android2.1.tgz tar zcvf ut6410-android2.1.tgz ut6410-android2.1/ tar - ...
- 【mysql】用navicat连接虚拟机mysql出现错误代码(10038)
来源: http://www.cnblogs.com/ohmydenzi/p/5521121.html http://blog.csdn.net/chana1101/article/details/3 ...