KeepAlived+Redis+Haproxy实现主从热备、负载均衡、秒级切换

Redis集群部署与HAProxy负载均衡
redis

修改主机名
[root@localhost ~]# hostnamectl --static set-hostname redis01
[root@localhost ~]# hostnamectl --static set-hostname redis02
[root@localhost ~]# hostnamectl --static set-hostname redis03

修改hosts
[root@redis01 ~]# cat >> /etc/hosts <<-EOF
192.168.49.168 redis01
192.168.49.169 redis02
192.168.49.146 redis03
EOF

修改最大可打开文件数
[root@redis01 ~]#cat >> /etc/security/limits.conf << EOF

  • soft nofile 102400
  • hard nofile 102400
    EOF

tcp监听队列大小
[root@redis01 ~]# echo “net.core.somaxconn = 32767” >> /etc/sysctl.conf
[root@redis01 ~]# sysctl -p

OOM相关
[root@redis01 ~]# echo “vm.overcommit_memory=1” >> /etc/sysctl.conf
[root@redis01 ~]# sysctl -p

开启内核的“Transparent Huge Pages (THP)”特性
[root@redis01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@redis01 ~]# echo “echo never > /sys/kernel/mm/transparent_hugepage/enabled” >> /etc/rc.local
####/etc/rc.local 开机后运行
[root@redis01 ~]# chmod +x /etc/rc.local

安装 redis 并配置 redis-cluster
安装gcc套装
[root@redis01 ~]# yum -y install gcc glibc glibc-kernheaders glibc-common glibc-devel make
升级gcc
[root@redis01 ~]# yum -y install centos-release-scl
[root@redis01 ~]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@redis01 ~]# scl enable devtoolset-9 bash
设置永久升级
[root@redis01 ~]# echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile
redis01 安装
[root@redis01 ~]# cd /usr/local/src
[root@redis01 ~]# wget http://download.redis.io/releases/redis-6.0.5.tar.gz
[root@redis01 ~]# tar -zxvf redis-6.0.5.tar.gz
[root@redis01 ~]# cd redis-6.0.5/
[root@redis01 ~]# make
[root@redis01 ~]# ma

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值