数据库
首页 > 数据库> > Redis三主三从集群搭建

Redis三主三从集群搭建

作者:互联网

 1、下载Redis:http://redis.io/download

wget https://download.redis.io/releases/redis-6.2.4.tar.gz

2、解压Redis:

tar -zxvf redis-6.2.4.tar.gz

3、切换到解压目录:

cd redis-6.2.4

4、安装依赖环境:

yum install gcc

5、编译安装:

make

6、创建配置文件存放目录

mkdir -p /usr/local/redis-cluster/8001
mkdir -p /usr/local/redis-cluster/8002
mkdir -p /usr/local/redis-cluster/8003
mkdir -p /usr/local/redis-cluster/8004
mkdir -p /usr/local/redis-cluster/8005
mkdir -p /usr/local/redis-cluster/8006

7、复制redis.con到配置文件目录下,修改配置(端口号对应修改)

daemonize yes
port 8001
#指定数据文件存放位置
dir /usr/local/redis-cluster/8001/
cluster-enabled yes(启动集群模式)
#集群节点信息文件
cluster-config-file nodes-8001.conf
cluster-node-timeout 5000
bind 0.0.0.0
#关闭保护模式
protected-mode no
appendonly yes

8、启动各个节点

src/redis-server /usr/local/redis-cluster/8001/redis.conf
src/redis-server /usr/local/redis-cluster/8002/redis.conf
src/redis-server /usr/local/redis-cluster/8003/redis.conf
src/redis-server /usr/local/redis-cluster/8004/redis.conf
src/redis-server /usr/local/redis-cluster/8005/redis.conf
src/redis-server /usr/local/redis-cluster/8006/redis.conf

9、创建集群

src/redis-cli --cluster create --cluster-replicas 1 192.168.229.128:8001 192.168.229.128:8002 192.168.229.128:8003 192.168.229.128:8004 192.168.229.128:8005 192.168.229.128:8006

        输入yes确认创建

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

10、进入某个节点(-c 以集群模式访问)

src/redis-cli -c -h 127.0.0.1 -p 8001

11、查看节点信息

127.0.0.1:8001> CLUSTER NODES

标签:src,Redis,三主三,redis,cluster,集群,usr,local,8001
来源: https://blog.csdn.net/qq_34585332/article/details/118439195