Redis-6.0.6版本高可用集群搭建

2020年发布的Redis6.0 是Redis自发布以来最大的升级,提供了多线程支持, ACLs细粒度的权限管理,SSL加密,客户端缓存,集群代理等多项重大更新

公司采购了XXX系统,我决定用目前最高版本的Redis-6.0.6搭建高可用集群,废话不说,直接上步骤

cat /etc/redhat-release

CentOS Linux release 7.6.1810 (Core)

gcc -v

gcc version 4.8.5 20150623

操作系统自带的GCC版本太低,报错make[1]: *** [server.o] Error 1,先升级GCC:

yum -y install centos-release-scl

yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

scl enable devtoolset-9 bash

以上为临时启用,如果要长期使用gcc 9.1的话:

echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile

cd redis-6.0.6/

make PREFIX=/usr/local/redis install

三台机器

redis1  10.1.10.154   8001

redis2  10.1.10.155   8002

redis3  10.1.10.156   8003

redis4  10.1.10.154   8004

redis5  10.1.10.155   8005

redis6  10.1.10.156   8006

 

redis.conf配置(其中之一)

protected-mode no

port 8001

daemonize yes

pidfile /var/run/redis_8001.pid

logfile /u01/redis-cluster/redis01/redis_8001.log

dbfilename /u01/redis-cluster/redis01/dump-8001.rdb

dir /u01/redis-cluster/redis04/

cluster-enabled yes

cluster-config-file nodes-8001.conf

appendonly yes

appendfilename “appendonly-8001.aof”

 

./redis-cli –cluster create 10.1.10.154:8001 10.1.10.155:8002 10.1.10.156:8003 10.1.10.155:8005 10.1.10.156:8006 10.1.10.154:8004 –cluster-replicas 1

>>> Performing hash slots allocation on 6 nodes…

Master[0] -> Slots 0 – 5460

Master[1] -> Slots 5461 – 10922

Master[2] -> Slots 10923 – 16383

Adding replica 10.1.10.155:8005 to 10.1.10.154:8001

Adding replica 10.1.10.156:8006 to 10.1.10.155:8002

Adding replica 10.1.10.154:8004 to 10.1.10.156:8003

M: 552e4cc8d33e7b8485cbe44d00d856fa4a42f68d 10.1.10.154:8001

   slots:[0-5460] (5461 slots) master

M: 1bc6d5ccb27116c12c15bf2f4a0da5307810670a 10.1.10.155:8002

   slots:[5461-10922] (5462 slots) master

M: 85e007c030b0a550f6ffb5dca1860cb0042c5969 10.1.10.156:8003

   slots:[10923-16383] (5461 slots) master

S: 4268dd2e59efbfa97dc93983d34376d52a583acc 10.1.10.155:8005

   replicates 552e4cc8d33e7b8485cbe44d00d856fa4a42f68d

S: 482acf6feec3ac0afa7c0cbd1b253a3b7270c829 10.1.10.156:8006

   replicates 1bc6d5ccb27116c12c15bf2f4a0da5307810670a

S: 3ad998290bd7dcd97d85866502beab4ff0852837 10.1.10.154:8004

   replicates 85e007c030b0a550f6ffb5dca1860cb0042c5969

Can I set the above configuration? (type ‘yes’ to accept): yes

>>> Nodes configuration updated

>>> Assign a different config epoch to each node

>>> Sending CLUSTER MEET messages to join the cluster

Waiting for the cluster to join

.

>>> Performing Cluster Check (using node 10.1.10.154:8001)

M: 552e4cc8d33e7b8485cbe44d00d856fa4a42f68d 10.1.10.154:8001

   slots:[0-5460] (5461 slots) master

   1 additional replica(s)

S: 3ad998290bd7dcd97d85866502beab4ff0852837 10.1.10.154:8004

   slots: (0 slots) slave

   replicates 85e007c030b0a550f6ffb5dca1860cb0042c5969

M: 85e007c030b0a550f6ffb5dca1860cb0042c5969 10.1.10.156:8003

   slots:[10923-16383] (5461 slots) master

   1 additional replica(s)

M: 1bc6d5ccb27116c12c15bf2f4a0da5307810670a 10.1.10.155:8002

   slots:[5461-10922] (5462 slots) master

   1 additional replica(s)

S: 482acf6feec3ac0afa7c0cbd1b253a3b7270c829 10.1.10.156:8006

   slots: (0 slots) slave

   replicates 1bc6d5ccb27116c12c15bf2f4a0da5307810670a

S: 4268dd2e59efbfa97dc93983d34376d52a583acc 10.1.10.155:8005

   slots: (0 slots) slave

   replicates 552e4cc8d33e7b8485cbe44d00d856fa4a42f68d

[OK] All nodes agree about slots configuration.

>>> Check for open slots…

>>> Check slots coverage…

[OK] All 16384 slots covered.

 

 

发表评论