redis-5.0.5参考资料:https://blog.csdn.net/u010520146/article/details/84932104
redis-3.0.0参考资料:https://blog.csdn.net/qq_42815754/article/details/82912130
复制文件全部
cp -r redis-5.0.5/* 8004
sh redis-cluster-start.sh
protected-mode no (yes,不变)
port 8000 (修改)
cluster-enabled yes (放开注释)
cluster-config-file nodes-8000.conf (修改)
cluster-node-timeout 5000 (放开注释,修改)
daemonize yes (不变)
pidfile /var/run/redis_8000.pid (修改)
logfile "8000.log" (修改)
dir /redis/data (不修改,不新建文件夹,保留./)
创建集群
[root@ylm-100 soft]# redis-cli -a 123456 --cluster create 192.168.92.100:8000 192.168.92.100:8001 192.168.92.100:8002 192.168.92.100:8003 192.168.92.100:8004 192.168.92.100:8005 --cluster-replicas 1
yes
进入节点
cluster info
cluster nodes
[root@localhost src]# redis-cli -p 8001 -a 123456
127.0.0.1:8001> get a
(error) MOVED 15495 127.0.0.1:8002
127.0.0.1:8001>
这边提示MOVED命令,则用如下:
[root@localhost src]# redis-cli -c -p 8001 -a 123456
127.0.0.1:8001> get a
-> Redirected to slot [15495] located at 127.0.0.1:8002
"aaaa"
127.0.0.1:8002> keys *
集群登录 -c
[root@ylm-100 soft]# redis-cli -c -h 192.168.92.100 -p 8000 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.92.100:8000> set ww ww
-> Redirected to slot [8126] located at 192.168.92.100:8001
OK
192.168.92.100:8001> get ww
"ww"
启动脚本
vim ../redis-cluster-start.sh
/usr/local/soft/8000/src/redis-server /usr/local/soft/8000/redis.conf
/usr/local/soft/8001/src/redis-server /usr/local/soft/8001/redis.conf
/usr/local/soft/8002/src/redis-server /usr/local/soft/8002/redis.conf
/usr/local/soft/8003/src/redis-server /usr/local/soft/8003/redis.conf
/usr/local/soft/8004/src/redis-server /usr/local/soft/8004/redis.conf
/usr/local/soft/8005/src/redis-server /usr/local/soft/8005/redis.conf