on the same server
based on redis 5.0.0
https://my.oschina.net/ruoli/blog/2252393
create dir /root/software/redis
download the source code and compile
1
2
3
4wget http://download.redis.io/releases/redis-5.0.0.tar.gz
tar xzf redis-5.0.0.tar.gz
cd redis-5.0.0
makecreate 6 redis.conf for the cluster
1
2
3
4
5
6/root/software/redis/redis-cluster-conf/7001/redis.conf
/root/software/redis/redis-cluster-conf/7002/redis.conf
/root/software/redis/redis-cluster-conf/7003/redis.conf
/root/software/redis/redis-cluster-conf/7004/redis.conf
/root/software/redis/redis-cluster-conf/7005/redis.conf
/root/software/redis/redis-cluster-conf/7006/redis.conf
the conf of the 1st node as below:1
2
3
4
5
6
7
8port 7001 #端口
cluster-enabled yes #启用集群模式
cluster-config-file nodes.conf
cluster-node-timeout 5000 #超时时间
appendonly yes
daemonize yes #后台运行
protected-mode no #非保护模式
pidfile /var/run/redis_7001.pid
NOTE: the port and pidfile SHOULD BE 7001/7002/…, redis_7001.pid/redis_7002.pid/…
startup 6 nodes
1
2
3
4
5
6/root/software/redis/redis-5.0.0/src/redis-server /root/software/redis/redis-cluster-conf/7001/redis.conf
/root/software/redis/redis-5.0.0/src/redis-server /root/software/redis/redis-cluster-conf/7002/redis.conf
/root/software/redis/redis-5.0.0/src/redis-server /root/software/redis/redis-cluster-conf/7003/redis.conf
/root/software/redis/redis-5.0.0/src/redis-server /root/software/redis/redis-cluster-conf/7004/redis.conf
/root/software/redis/redis-5.0.0/src/redis-server /root/software/redis/redis-cluster-conf/7005/redis.conf
/root/software/redis/redis-5.0.0/src/redis-server /root/software/redis/redis-cluster-conf/7006/redis.confstartup the cluster
1
2# DO REMEMBER update the ip to your ip
/root/software/redis/redis-5.0.0/src/redis-cli --cluster create 192.168.2.40:7001 192.168.2.40:7002 192.168.2.40:7003 192.168.2.40:7004 192.168.2.40:7005 192.168.2.40:7006 --cluster-replicas 1
on 6 servers
https://blog.51cto.com/13860853/2415197
查看节点
./redis-5.0.0/src/redis-cli -h 127.0.0.1 -p 7001 -c cluster nodes
./redis-5.0.0/src/redis-cli -h 192.1.114.84 -p 7001 -c cluster nodes