标签:llinux企业常用服务---ha+keepalived双机热备 ha keepalived
部署前准备:
iptables和selinux没配置,关掉
挂载系统镜像作为本地yum源,修改yum文件
源码包准备keepalived-1.2.13.tar.gz
环境介绍:
2台centos6.5虚拟机,主服务器ip:192.168.100.150;从服务器ip:192.168.100.151;集群vip:192.168.100.95
1.安装keepalived(主从上都需要安装)
yum -y install kernel-devel openssl-devel popt-devel ipvsadm
tar zxvf keepalived-1.2.2.tar.gz -C /usr/src/
cd /usr/src/keepalived-1.2.2/
./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64/
make &&make install
chkconfig --add keepalived
chkconfig keepalived on
2.配置HA
主配置:(192.168.100.150上操作)
cd /etc/keepalived/
mv keepalived.conf keepalived.conf.bak
vi /etc/keepalived/keepalived.conf
global_defs {
router_id HA_TEST_R1 ##本服务器的名称
}
vrrp_instance VI_1 { ##定义VRRP热备实例
state MASTER ##MASTER表示主服务器
interface eth0 ##承载VIP地址的物理接口
virtual_router_id 1 ##虚拟路由器的ID号
priority 100 ##优先级,数值越大优先级越高
advert_int 1 ##通告间隔秒数(心跳频率)
authentication { ##认证信息
auth_type PASS ##认证类型
auth_pass 123456 ##密码字串
}
virtual_ipaddress {
192.168.100.95 ##指定漂移地址(VIP)
}
}
:wq
从配置:(192.168.100.151上操作)
cd /etc/keepalived/
mv keepalived.conf keepalived.conf.bak
vi /etc/keepalived/keepalived.conf
global_defs {
router_id HA_TEST_R2 ##本服务器的名称
}
vrrp_instance VI_1 {
state BACKUP ##SLAVE表示从服务器
interface eth0
virtual_router_id 1
priority 99 ##优先级,低于主服务器
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.100.95
}
}
:wq
3.启动服务及应用服务:
1)启动keepalived:
/etc/init.d/keepalived start
ip addr show dev eth0 ##验证vip是否在主服务器上
2)主、备机均启用FTP、Web服务,内容相同
yum -y install httpd vsftpd
/etc/init.d/vsftpd restart
/etc/init.d/httpd restart
chkconfig vsftpd on
chkconfig httpd on
4.测试双机热备的效果
先后禁用、启用主服务器的网卡,执行以下测试
cat /var/log/messages
测试1:使用ping检测192.168.100.95的连通性
测试2:访问ftp://192.168.100.95,确认可用性及内容变化
测试3:访问http://192.168.100.95/,确认可用性及内容变化
测试4:查看日志文件/var/log/messages中的变化
本文出自 “LP-linux” 博客,请务必保留此出处http://linuxlp.blog.51cto.com/11463376/1773635
llinux企业常用服务---HA+keepalived双机热备
标签:llinux企业常用服务---ha+keepalived双机热备 ha keepalived
原文地址:http://linuxlp.blog.51cto.com/11463376/1773635