redis cluster 安装

服务器:

IP主端口从端口
172.16.8.21570007001
172.16.8.21670007001
172.16.8.21770007001

1.文件下载

wget http://download.redis.io/releases/redis-5.0.6.tar.gz

2.安装

make
make install PREFIX=/usr/local/redis

3.内核参数修改

vm.overcommit_memory=1

net.core.somaxconn = 511

echo never > /sys/kernel/mm/transparent_hugepage/enabled
vim /etc/rc.local

4.创建目录

mkdir -p /opt/app/data/redis_7000
mkdir -p /opt/app/data/redis_7001

5.配置文件

/usr/local/redis/7000.conf

/usr/local/redis/7001.conf

6.参数修改

master:

port 7000
pidfile /var/run/redis_7000.pid
logfile “7000.log”
dir “/opt/app/data/redis_7000”
cluster-config-file nodes-7000.conf
auto-aof-rewrite-min-size 256mb
appendfilename “appendonly.aof”
cluster-enabled yes
appendonly yes
slowlog-log-slower-than 10000
bind 0.0.0.0

slave:

port 7001
pidfile /var/run/redis_7001.pid
logfile “7001.log”
dir “/opt/app/data/redis_7001”
cluster-config-file nodes-7001.conf
auto-aof-rewrite-min-size 256mb
appendfilename “appendonly.aof”
cluster-enabled yes
appendonly yes
slowlog-log-slower-than 10000
bind 0.0.0.0

7.启动redis

/usr/local/bin/redis-server /usr/local/redis/7000.conf
/usr/local/bin/redis-server /usr/local/redis/7001.conf

8.创建集群

redis-cli –cluster create 172.16.8.215:7000 172.16.8.215:7001 172.16.8.216:7000 172.16.8.216:7001 172.16.8.217:7000 172.16.8.217:7001 –cluster-replicas 1