惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Secure Thoughts
C
Cyber Attacks, Cyber Crime and Cyber Security
SecWiki News
SecWiki News
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
H
Help Net Security
I
InfoQ
T
Tor Project blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
S
Schneier on Security
The Hacker News
The Hacker News
博客园 - Franky
雷峰网
雷峰网
S
Security @ Cisco Blogs
Google Online Security Blog
Google Online Security Blog
Engineering at Meta
Engineering at Meta
G
GRAHAM CLULEY
Security Latest
Security Latest
The Cloudflare Blog
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
C
Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Latest news
Latest news
Last Week in AI
Last Week in AI
The Register - Security
The Register - Security
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
T
Threatpost
G
Google Developers Blog
有赞技术团队
有赞技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
aimingoo的专栏
aimingoo的专栏
S
Securelist
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
T
The Exploit Database - CXSecurity.com
月光博客
月光博客
Recent Announcements
Recent Announcements

博客园 - wsky

生产环境使用Nuget 为WebClient增加Cookie支持 NHibernate分享 PPT 开源选型关注点 SocketAsyncEventArgs stunnel+haproxy SSL以及问题记录 快速实现一个简单的bigpipe模型 Velocity2010大会回顾 小结一下关于bpm实施方面的交流 乱弹之企业应用 互联网企业流程部门价值方向的一些探讨 Live Writer的代码插件 再谈团队,项目,产品 【渐进】设计一个模拟并行的线程同步组件 【渐进】关于反向代理,负载均衡 【渐进】浅尝DDD,对"试卷"建模 【渐进】延迟加载机制的简易实现(上) - wsky - 博客园 略谈“开发效率” 分工,协作,团队
keepalived安装和使用
wsky · 2011-04-12 · via 博客园 - wsky

keepalived:http://www.keepalived.org/index.html

它是一个基于VRRP协议来实现的WEB服务高可用方案,可以利用其来避免单点故障。一个WEB服务至少会有2台服务器运行Keepalived,一台为主服务器(MASTER),一台为备份服务器(BACKUP),但是对外表现为一个虚拟IP,主服务器会发送特定的消息给备份服务器,当备份服务器收不到这个消息的时候,即主服务器宕机的时候,备份服务器就会接管虚拟IP,继续提供服务,从而保证了高可用性。(摘)

image

可以使用lvs或haproxy+keepalived做高可用的负载均衡方案

记录一下安装过程和问题处理过程

首先需要安装ipvsadm:

或者:

   1:  #在这里查找适合的版本http://www.linuxvirtualserver.org/software/ipvs.html
   2:  wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24-6.src.rpm
   3:  tar –zxvf ipvsadm-1.24.tar.gz
   4:  cd ipvsadm-1.24
   5:  make&&make install

然后安装keepalived

   1:  wget http://www.keepalived.org/software/keepalived-1.2.2.tar.gz
   2:  tar –zxvf keepalived-1.2.2.tar.gz
   3:  cd keepalived-1.2.2
   4:  ./configure
   5:  make && make install

configure时若出现以下结果:

image

只有一项为yes,因为keepalived没有找到内核目录导致的,解决的方法是在编译的时候:

./configure --with-kernel-dir=/usr/src/kernels/2.6.18-194.el5-i686/

若/usr/src/kernel目录下没有内核目录,则需要安装内核开发包:

用命令uname -a查看内核版本,然后可以在这里查找对应的http://zid-luxinst.uibk.ac.at/linux/rpm2html/centos/5/os/i386/CentOS/kernel-devel-2.6.18-194.el5.i686.html

不推荐使用yum install -y kernel-devel安装

安装完成后建立一下链接:

ln -s /usr/src/kernels/2.6.18-194.el5-i686/ /usr/src/linux/

上述过程完毕后,在进行configure:

image

若还是出现no或者make的时候出现:“ error: linux/ip_masq.h: No such file or directory”之类的错误时,在/usr/src/kernels/2.6.18-194.el5-i686/include/linux/version.h中增加声明:

#define UTS_RELEASE "2.6.18"

再进行configure就会都是yes了:

image

接着执行make是若出现“types.h:62: error: conflicting types for ‘dev_t’”错误,需要修改源码目录下的keepalived/libipvs-2.6/ip_vs.h

把#include linux/types.h移到#include sys/types.h 这行的下面

image

上述错误都解决后make&&make install就可以通过了,然后运行:

#查看帮助
keepalived -h
#运行 由于keepalived配置文件不是在启动时一次性加载并读取完成的,所以必须是完整路径,可以根据log判断是否加载了正确的配置文件
keepalived –f /usr/local/etc/keepalived/keepalived.conf 

运行过程可以查看log: