keepalived+lvs+mysql cluster架构实现负载均衡
用途iposmemory调度器172.16.48.204CentOS 5.5 64bit32Gsql节点1172.16.48.206CentOS 5.5 64bit32Gsql节点2172.16.48.207CentOS 5.5 64bit32Gsql节点3172.16.48.208CentOS 5.5 64bit32Gsql节点4172.16.48.211CentOS 5.5 64bit32G
VIP设置为:172.100.100.251 (注:不能和调度器、sql节点在一个网段上)
在调度器172.16.48.204电脑上,用route add default dev eth1
命令添加路由,使得172.16.48.204节点有对100网段的访问权限。
二、架构图
这里调度器只用了一个节点,没有设置Backup
三、软件下载
lvs: ? ?http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
keepalived: ? ? http://www.keepalived.org/download.html
四、软件安装
编辑lvs的时候需要操作系统的内核,不然会报错
configure: error:?
!!! OpenSSL is not properly installed on your system. !!!
!!! Can not include OpenSSL headers files. !!!
解决方法:yum install openssl*
可能?还会报错:libipvs.c:253: 错误:提领指向不完全类型的指针
解决方法:yum -y install kernel-devel ? ?可参考:http://692344.blog.51cto.com/blog/682344/804278
如果还是不行,可能是由于lvs keepalived的版本过高
1.在调度器172.16.48.204上安装lvs
ln -s /usr/src/kernels/2.6.18-164.el5-i686/ /usr/src/linux
tar zxvf ipvsadm-1.24.tar.gz
cd ipvsadm-1.24
make && make install
2.在调度器172.16.48.204上安装keepalived
tar zxvf keepalived-1.1.19.tar.gz
cd keepalived-1.1.19
./configure --prefix=/usr/local/keepalived
make?
make install
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/
mkdir /etc/keepalived
3.配置keepalived.conf
vi /etc/keepalived/keepalived.conf
添加如下内容:
哈哈!成功搞定
?
?