Redis-集群

准备环境

1 yum install centos-release-scl-rh   
2 yum install rh-ruby23  -y     
3 scl  enable  rh-ruby23 bash  
4 ruby -v
5 gem install redis

复制多个Redis实例(7000-7005)

 1 #修改配置文件
 2 port 7000
 3 pidfile "/var/run/redis_7000.pid"
 4 logfile "/var/log/redis/redis7000.log"
 5 dir "./"
 6 #增加配置
 7 cluster-enabled yes
 8 cluster-config-file nodes.conf
 9 cluster-node-timeout 5000
10 #注,有密码的话要注释
11 #requirepass "root"
12 #启动实例
13 ./redis-server ./redis.conf 

创建集群

1 /usr/local/redis/src/redis-trib.rb create --replicas 1 192.168.10.242:7000 192.168.10.242:7001 192.168.10.242:7002 192.168.10.242:7003 192.168.10.242:7004 192.168.10.242:7005 
2 #显示此处为成功
3 [OK] All nodes agree about slots configuration.
4 >>> Check for open slots...
5 >>> Check slots coverage...
6 [OK] All 16384 slots covered.
7 #登陆集群
8 redis-cli -c -h 192.168.10.242 -p 7000

 

posted @ 2018-07-27 16:11  闫世成  阅读(197)  评论(0编辑  收藏  举报