Redis集群搭建

安装、启动Redis有问题的请点击

前提

Redis集群至少需要六个实例
集群目录
1
2
3
4
5
6
redis-6378
redis-6379
redis-6380
redis-6381
redis-6382
redis-6383

配置文件[redis.conf]修改

[xx]代表具体的端口
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#端口
port 63xx

#开启守护进程
daemonize yes

#开启集群
cluster-enabled yes

#集群配置文件
cluster-config-file nodes-63xx.conf

#保护模式关闭
protected-mode no

批启动脚本

[./start-all.sh]
1
2
3
4
5
6
7
8
9
10
11
./redis-6378/src/redis-server ./redis-6378/redis.conf &

./redis-6379/src/redis-server ./redis-6379/redis.conf &

./redis-6380/src/redis-server ./redis-6380/redis.conf &

./redis-6381/src/redis-server ./redis-6381/redis.conf &

./redis-6382/src/redis-server ./redis-6382/redis.conf &

./redis-6383/src/redis-server ./redis-6383/redis.conf &

启动所有的Redis

1
nohup sh ./start-all.sh &

开始集群

[your_password]redis的密码
1
./redis-6379/src/redis-cli --cluster create 192.168.100.1:6378 192.168.100.1:6379 192.168.100.1:6380 192.168.100.1:6381 192.168.100.1:6382 192.168.100.1:6383 --cluster-replicas 1 -a your_password

评论