1.2.9集群的安装及配置

说明:
一、目 的:本文实现的Linux集群是基于Keepalived-1.2.9软件实现,
二、难 点:实现虚拟IP(VIP)自动切换的同时,还要同时实现虚拟MAC地址(VMAC)的切换,即无论集群中的Host如何切换,对外访问的IP和MAC始终不变
三、适用环境:当对外路由或交换机绑定主机MAC时适用
四、说 明:若无须对外绑定MAC地址,则大可简化如下配置

1. 环境及软件:
1) 系统:Debian6 amd64
2) 内核:linux 3.2.0-0.bpo.4-amd64
3) 软件:keepalived-1.2.9

2. 配置:
MASTER设备IP: eth0: 10.10.1.200/24 eth1:192.168.61.253/21
BACKUP设备IP: eth0: 10.10.1.100/24 eth1:192.168.61.252/21
VIP: 192.168.61.248/21

3. 安装步骤:
1)升级当前Debian系统内核linux 2.6.32
a) 修改Debian源文件/etc/apt/sources.list,添加一个向后兼容的源(源地址如下)
deb squeeze-backports main

b) 更新Debian源文件关联并升级系统内核至3.2.0
# aptitude update
# aptitude -t squeeze-backports install linux 3.2.0-0.bpo.4-amd64
如果编译NVDIA的官方驱动的话,还要装:

# aptitude -t squeeze-backports install linux-headers-3.2.0.bpo.4-amd64

2) 安装keepalived-1.2.9
a) 首先要安装keepalived所依赖的组件
# aptitude install make gcc libpopt-dev libnl-dev libcurl4-openssl-dev

b) 将keepalived-1.2.9.tar.gz文件拷贝到/usr/local/soft下,解压,编译并安装到/usr/local/keepalived

# mkdir /usr/local/soft
通过ftp将文件拷贝至/usr/local/soft
# cd /usr/local/soft
# tar zxvf keepalived-1.2.9.tar.gz
# cd keepalived-1.2.9
# ./configure --prefix=/usr/local/keepalived
# make && make install

c) 重置keepalived相关文件,以便开机自动启动

# cp /usr/local/keepalived/sbin/keepalived /usr/sbin
# mkdir /etc/sysconfig
# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig
# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
d) 修改keepalived启动脚本
# nano /etc/init.d/keepalived
修改/etc/init.d/keepalived文件,部分片段如下(蓝色标记为注释内容,红色标记为修改内容):
……
#. /etc/rc.d/init.d/functions
. /lib/lsb/init-functions
# Source configuration file (we set KEEPALIVED_OPTIONS there)
. /etc/sysconfig/keepalived
RETVAL=0
prog="keepalived"
start() {
echo -n $"Starting $prog: "
# keepalived ${KEEPALIVED_OPTIONS}
keepalived -D
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/$prog
}
stop() {
echo -n $"Stopping $prog: "
killproc keepalived
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/$prog
}
……
condrestart)
if [ -f /var/lock/$prog ]; then
stop
start
fi
;;
……

更多详情见请继续阅读下一页的精彩内容

Keepalived 的详细介绍请点这里
Keepalived 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/81c75472f8e83b3684f977e615cff4f5.html