标签:服务器
Keepalived 是一个基于VRRP协议来实现的LVS服务高可用方案,可以利用其来避免单点故障。一个mysql或lvs或nginx服务会有2台服务器运行Keepalived,一台为主服务器(MASTER),一台为备份服务器(BACKUP),但是对外表现为一个虚拟IP,主服务器会发送特定的消息给备份服务器,当备份服务器收不到这个消息的时候,即主服务器宕机的时候,备份服务器就会接管虚拟IP,继续提供服务,从而保证了高可用性。
以下简图为例,当服务调用mysql的时候,直接调用vip,这样即使master上宕机,依旧可访问从数据库。
Keepalive的安装:
1、 安装环境包
[root@jacken ~]# yum -y install kernel-devel openssl-devel popt-devel
2、 安装keepalive
[root@jacken ~]# wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz [root@jacken ~]# tarkeepalived-1.1.15.tar.gz [root@jacken ~]# cd keepalived-1.1.15 [root@jacken keepalived-1.1.15]#./configure--with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64/ [root@jacken ~]# make && makeinstall
3、 设置keepalive
[root@jacken ~]# DIR=/usr/local/ ; cp$DIR/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ [root@jacken ~]# cp $DIR/etc/sysconfig/keepalived/etc/sysconfig/ && mkdir -p /etc/keepalived [root@jacken ~]# cp $DIR/sbin/keepalived/usr/sbin/ [root@jacken ~]# cp/usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ [root@jacken ~]# /etc/init.d/keepalivedrestart Stopping keepalived: [FAILED] Starting keepalived: [ OK ] [root@jacken ~]#
Other
脚本配置文件:
[root@jacken ~]# chmod +xinstall_keepalive.sh [root@jacken ~]# cat install_keepalive.sh #!/bin/bash yum -y install kernel-devel openssl-devel popt-devel && wgethttp://www.keepalived.org/software/keepalived-1.1.15.tar.gz && tar keepalived-1.1.15.tar.gz && cd keepalived-1.1.15 && ./configure--with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64/ && make && make install && DIR=/usr/local/ cp $DIR/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ && cp $DIR/etc/sysconfig/keepalived/etc/sysconfig/ && mkdir -p /etc/keepalived && cp $DIR/sbin/keepalived /usr/sbin/&& cp/usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ && /etc/init.d/keepalived restart if [ $? -eq 0 ];then echo -e ‘\e[32mInstall Keepalive Successfully!\e[0m‘ else echo -e ‘\e[31mInstall Keepalive Failure!\e[0m‘ fi [root@jacken ~]#
其实这个不算是什么脚本,方便安装而已,内容在附件当中!
本文出自 “一步步踏入Linux世界” 博客,请务必保留此出处http://linuxnote.blog.51cto.com/9876511/1652612
标签:服务器
原文地址:http://linuxnote.blog.51cto.com/9876511/1652612