Redis3.0.1 Stable版本的集群部署(Mac)
- 127.0.0.1:7000
- 127.0.0.1:7001
- 127.0.0.1:7002
- 127.0.0.1:7003
- 127.0.0.1:7004
- 127.0.0.1:7005
#将下载的文件放到 /usr/local/ tar -zxvf redis-3.0.1.tar.gz #生成 redis-3.0.1文件夹 cd /usr/local/redis-3.0.1 make make install #执行一下make test查看 make的结果全部都是OK #最终结果显示如下 \o/ All tests passed without errors!
mkdir -p /usr/local/cluster cd /usr/local/cluster mkdir 7000 mkdir 7001 mkdir 7002 mkdir 7003 mkdir 7004 mkdir 7005
4:修改配置文件redis.conf
cp /usr/local/redis-3.0.1/redis.conf /usr/local/cluster vi redis.conf ##修改配置文件中的下面选项 port 7000 daemonize yes cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes ##修改完redis.conf配置文件中的这些配置项之后把这个配置文件分别拷贝到7000/7001/7002/7003/7004/7005目录下面 cp /usr/local/cluster/redis.conf /usr/local/cluster/7000 cp /usr/local/cluster/redis.conf /usr/local/cluster/7001 cp /usr/local/cluster/redis.conf /usr/local/cluster/7002 cp /usr/local/cluster/redis.conf /usr/local/cluster/7003 cp /usr/local/cluster/redis.conf /usr/local/cluster/7004 cp /usr/local/cluster/redis.conf /usr/local/cluster/7005 ##注意:拷贝完成之后要修改7001/7002/7003/7004/7005目录下面redis.conf文件中的port参数,分别改为对应的文件夹的名称
cd /usr/local/cluster/7000 redis-server redis.conf cd /usr/local/cluster/7001 redis-server redis.conf cd /usr/local/cluster/7002 redis-server redis.conf cd /usr/local/cluster/7003 redis-server redis.conf cd /usr/local/cluster/7004 redis-server redis.conf cd /usr/local/cluster/7005 redis-server redis.conf ##启动之后使用命令查看redis的启动情况ps -ef|grep redis 如下显示则说明启动成功 X0544:7005 wei.li$ ps -ef | grep redis 909302175 5547 1 0 11:31上午 ?? 0:01.07 redis-server *:7000 [cluster] 909302175 5736 1 0 11:44上午 ?? 0:00.29 redis-server *:7001 [cluster] 909302175 5761 1 0 11:48上午 ?? 0:00.05 redis-server *:7002 [cluster] 909302175 5773 1 0 11:49上午 ?? 0:00.03 redis-server *:7003 [cluster] 909302175 5780 1 0 11:49上午 ?? 0:00.02 redis-server *:7004 [cluster] 909302175 5787 1 0 11:49上午 ?? 0:00.01 redis-server *:7005 [cluster] 909302175 5790 952 0 11:49上午 ttys000 0:00.00 grep redis
6:执行redis的创建集群命令创建集群
cd /usr/local/redis-3.0.1/src ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
X0544:cluster wei.li$ gem install redis -V
即可安装完毕redis-rb
正常执行结果如下
X0544:src wei.li$ ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 >>> Creating cluster Connecting to node 127.0.0.1:7000: OK Connecting to node 127.0.0.1:7001: OK Connecting to node 127.0.0.1:7002: OK Connecting to node 127.0.0.1:7003: OK Connecting to node 127.0.0.1:7004: OK Connecting to node 127.0.0.1:7005: OK >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 Adding replica 127.0.0.1:7003 to 127.0.0.1:7000 Adding replica 127.0.0.1:7004 to 127.0.0.1:7001 Adding replica 127.0.0.1:7005 to 127.0.0.1:7002 M: 2cd16d3e6eb9f29ba578fbcf0627f3b3bb4653cf 127.0.0.1:7000 slots:0-5460 (5461 slots) master M: 432d74a91b5f1b6358cf245a153160fcf4e93447 127.0.0.1:7001 slots:5461-10922 (5462 slots) master M: ecfbdc1268990a42968f1bd887341f02e679f01f 127.0.0.1:7002 slots:10923-16383 (5461 slots) master S: cfacbc4067cbfffab2caa83858f0eebcb572c31d 127.0.0.1:7003 replicates 2cd16d3e6eb9f29ba578fbcf0627f3b3bb4653cf S: 69d3240c55fb8209e5f248f76c7557d023c4420f 127.0.0.1:7004 replicates 432d74a91b5f1b6358cf245a153160fcf4e93447 S: ff8c288967f944d463cf0a4d8712eb460e715c0f 127.0.0.1:7005 replicates ecfbdc1268990a42968f1bd887341f02e679f01f Can I set the above configuration? (type ‘yes‘ to accept):
输入yes,然后配置完成。
Can I set the above configuration? (type ‘yes‘ to accept): yes >>> Nodes configuration updated >>> Assign a different config epoch to each node >>> Sending CLUSTER MEET messages to join the cluster Waiting for the cluster to join.. >>> Performing Cluster Check (using node 127.0.0.1:7000) M: 2cd16d3e6eb9f29ba578fbcf0627f3b3bb4653cf 127.0.0.1:7000 slots:0-5460 (5461 slots) master M: 432d74a91b5f1b6358cf245a153160fcf4e93447 127.0.0.1:7001 slots:5461-10922 (5462 slots) master M: ecfbdc1268990a42968f1bd887341f02e679f01f 127.0.0.1:7002 slots:10923-16383 (5461 slots) master M: cfacbc4067cbfffab2caa83858f0eebcb572c31d 127.0.0.1:7003 slots: (0 slots) master replicates 2cd16d3e6eb9f29ba578fbcf0627f3b3bb4653cf M: 69d3240c55fb8209e5f248f76c7557d023c4420f 127.0.0.1:7004 slots: (0 slots) master replicates 432d74a91b5f1b6358cf245a153160fcf4e93447 M: ff8c288967f944d463cf0a4d8712eb460e715c0f 127.0.0.1:7005 slots: (0 slots) master replicates ecfbdc1268990a42968f1bd887341f02e679f01f [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. X0544:src wei.li$
至此redis集群即搭建成功!
7:使用redis-cli命令进入集群环境
X0544:src wei.li$ redis-cli -c -p 7000 127.0.0.1:7000>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。