Redis是一个高性能的kv数据库,我们用Redis构建了一套消息系统。
Redis架构为Master Slave结构,通过keepalived进行状态检查,故障迁移,达到高可用的目的。
下载keepalived #wget编译安装keepalived,编译时需要指定内核目录,否则Use IPVS Framework为NO。
#./configure --prefix=/usr/local/keepalived \ --with-kernel-dir=/usr/src/kernels/3.9.10-100.fc17.x86_64 \ --enable-snmp \ --enable-sha1配置keepalived信息如下图:
编译与安装:
#make && make install结果报错了,重新指定配置参数,去掉 --with-kernel-dir
配置信息如下图:
在次编译安装,OK,顺利通过安装成功!
现在可以将/usr/local/keepalived下相应文件拷贝到系统对应目录
配置keepalived在配置keepalived.conf配置文件之前先备份一份keepalived.conf文件后在进行配置
#cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak在Master机器配置keepalived
[root@node3 etc]# more /etc/keepalived/keepalived.conf global_defs { notification_email { admin@qixing318.com } notification_email_from keepalived@node3 router_id node3 } vrrp_instance mes_Redis { state MASTER interface eth0 garp_master_delay 10 smtp_alert virtual_router_id 3 priority 100 nopreempt advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.172.100 } }在Slave机器配置keepalived
[root@node4 etc]# more /etc/keepalived/keepalived.conf global_defs { notification_email { admin@qixing318.com } notification_email_from keepalived@node4 router_id node4 } vrrp_instance mes_Redis { state BACKUP interface eth0 garp_master_delay 10 smtp_alert virtual_router_id 3 priority 90 nopreempt advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.172.100 } } 配置防火墙 打开Master和Slave机器上的防火墙 [root@node3 ~]# more /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 9022 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT -A INPUT -p 112 -j ACCEPT -A INPUT -p 255 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT [root@node3 ~]# iptables-restore /etc/sysconfig/iptables