首页 > 其他 > 详细

配置 redis 3.0.5 集群

时间:2015-12-19 15:11:59      阅读:284      评论:0      收藏:0      [点我收藏+]

系统环境:CentOS release 6.7_x86_64

软件环境:redis-3.0.5


1、yum install ruby rubygems  #安装ruby环境依赖

2、gem install redis #安装redis集群管理器

Successfully installed redis-3.2.2
1 gem installed
Installing ri documentation for redis-3.2.2...
Installing RDoc documentation for redis-3.2.2...

3、cp redis源码包/src/redis-trib.rb /usr/local/bin/redis-trib

4、在配置文件中添加

cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000

5、启动服务

6、ps -aux | grep redis #查看服务是否是以集群方式启动

Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ
root      8986  0.0  0.3  40608  7356 ?        Ssl  19:16   0:00 /usr/local/redis/bin/redis-server *:6379 [cluster]    
root      8996  0.0  0.3 137440  7368 ?        Ssl  19:17   0:00 redis-server *:6380 [cluster]    
root      9027  0.0  0.3 137440  7584 ?        Ssl  19:23   0:00 redis-server *:6381 [cluster]    
root      9065  0.0  0.3 137440  7520 ?        Ssl  19:29   0:00 redis-server *:6382 [cluster]
root      9069  0.0  0.3 137440  7520 ?        Ssl  19:29   0:00 redis-server *:6383 [cluster]
root      9073  0.0  0.3 137440  7520 ?        Ssl  19:29   0:00 redis-server *:6384 [cluster]
root      9079  0.0  0.0 103320   860 pts/0    S+   19:29   0:00 grep redis

注:redis集群必须要有3个主节点

1、创建集群

[root@localhost /]# redis-trib create --replicas 1 192.168.2.105:6379 192.168.2.105:6380 192.168.2.105:6381 192.168.2.105:6382 192.168.2.105:6383 192.168.2.105:6384

  2、redis-cli -c -h 192.168.2.105 -p 6382 #进入节点

  3、192.168.2.105:6383> cluster info #查看集群的状态

cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_sent:353048
cluster_stats_messages_received:353048

  4、192.168.2.105:6383> cluster nodes #查看各节点的状态

a53adc9730f8d655266b0daeeb9f5d2c594d2630 192.168.2.105:6382 myself,slave b510459e932c2fad907277e6c44362da2514befb 0 0 4 connected
1862087294efabd66d2ea5c972746c9dacc2119c 192.168.2.105:6383 slave 999596b3e6b7508a6f33c808a5f27d494726bf07 0 1449655176281 5 connected
573bc078efa51518ebf97b80e28d9f68f137eb94 192.168.2.105:6384 slave 0b2d2b8137064bc2d0a78b5ce1c899e9c8c33bbe 0 1449655175280 6 connected
b510459e932c2fad907277e6c44362da2514befb 192.168.2.105:6379 master - 0 1449655176280 1 connected 0-5460
999596b3e6b7508a6f33c808a5f27d494726bf07 192.168.2.105:6380 master - 0 1449655176780 2 connected 5461-10922
0b2d2b8137064bc2d0a78b5ce1c899e9c8c33bbe 192.168.2.105:6381 master - 0 1449655177281 3 connected 10923-16383

本文出自 “运维危机” 博客,请务必保留此出处http://qiudays.blog.51cto.com/8910608/1726261

配置 redis 3.0.5 集群

原文:http://qiudays.blog.51cto.com/8910608/1726261

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!