加粗样式KeepAlived+Redis+Haproxy实现主从热备、负载均衡、秒级切换实战
- Redis+Keepalived+Haproxy 的集群架构,分别用六个端口,实现多路复用,最终实现主从热备、负载均衡、秒级切换。
修改主机名,域名解析(三台)
hostnamectl --static set-hostname redis1
hostnamectl --static set-hostname redis2
hostnamectl --static set-hostname redis3
[root@redis3 ~]# cat >>/etc/hosts <<eof
10.11.59.125 redis1
10.11.59.126 redis2
10.11.59.254 redis3
eof
修改系统参数(三台)
[root@redis1 ~]# cat >> /etc/security/limits.conf << EOF
- soft nofile 102400
- hard nofile 102400
EOF
[root@redis1 ~]# echo “net.core.somaxconn = 32767” >> /etc/sysctl.conf
[root@redis1 ~]# sysctl -p
vm.max_map_count = 262144
net.core.somaxconn = 32767
[root@redis1 ~]# echo “vm.overcommit_memory=1” >> /etc/sysctl.conf
[root@redis1 ~]# sysctl -p
vm.max_map_count = 262144
net.core.somaxconn = 32767
vm.overcommit_memory = 1
[root@redis1 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@redis1 ~]# echo “echo never > /sys/kernel/mm/transparent_hugepage/enabled” >> /etc/rc.local
[root@redis1 ~]# chmod +x /etc/rc.local
编译安装redis(三台)
[root@redis01 ~]# yum -y install gcc glibc glibc-kernheaders glibc-common glibc-devel make
[root@redis01 ~]# yum -y install centos-release-scl
[root@redis01 ~]# yum -y install devtool