This document was created based on the following original document (CentOS): http://blog.csdn.net/xu470438000/article/details/42971091 modified some path errors, complete some command execution results information, Make sure the cluster is successfully created under Mac (to make the cluster work at least 3 master nodes, here we will create 6 Redis nodes, of which three are the primary node, three are the slave nodes, the corresponding IP and port correspondence of the Redis node are as follows)
- 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
1: official website Download 3.0.1 Stable (http://redis.io/): http://download.redis.io/releases/redis-3.0.1.tar.gz 2: Upload Server, unzip, compile
tar -zxvf redis-3.0. 1. Tar . gz# generates Redis-3.0/usr/local/redis-3.0. 1 Make Make Install the results of #执行一下make Test view make are all ok# the final result is shown below \o/alltests passed without errors!
3: Create the directory required by the cluster
mkdir -p/usr/local//usr/local/clustermkdir7000mkdir 7001mkdir7002mkdir7003mkdir7004mkdir 7005
4: Modify configuration file redis.conf
CP/usr/local/redis-3.0.1/redis.conf/usr/local/ClusterVIredis.conf# #修改配置文件中的下面选项port7000daemonize Yescluster-enabled Yescluster-config-fileNodes.confcluster-node-timeout theappendonly yes# #修改完redis These configuration entries in the. conf configuration file, copy the configuration file to the 7000/7001/7002/7003/7004/7005 Directory belowCP/usr/local/cluster/redis.conf/usr/local/cluster/7000CP/usr/local/cluster/redis.conf/usr/local/cluster/7001CP/usr/local/cluster/redis.conf/usr/local/cluster/7002CP/usr/local/cluster/redis.conf/usr/local/cluster/7003CP/usr/local/cluster/redis.conf/usr/local/cluster/7004CP/usr/local/cluster/redis.conf/usr/local/cluster/7005# #注意: To modify 7001 after the copy is complete/7002/7003/7004/7005 directory under the port parameter in the redis.conf file, change the name of the corresponding folder respectively
5: Start each of the 6 Redis instances separately (practice proves that you must execute the redis-server command in the CD to the 700X folder)
cd/usr/local/cluster/7000Redis-Server REDIS.CONFCD/usr/local/cluster/7001Redis-Server REDIS.CONFCD/usr/local/cluster/7002Redis-Server REDIS.CONFCD/usr/local/cluster/7003Redis-Server REDIS.CONFCD/usr/local/cluster/7004Redis-Server REDIS.CONFCD/usr/local/cluster/7005Redis-Server redis.conf # #启动之后使用命令查看redis的启动情况ps-ef|grepThe Redis display below shows the boot success X0544:7005wei.li$PS-ef |grepRedis909302175 5547 1 0 One: 31 a.m.??0:01.07Redis-server *:7000[cluster]909302175 5736 1 0 One: 44 a.m.??0:00.29Redis-server *:7001[cluster]909302175 5761 1 0 One: 48 a.m.??0:00.05Redis-server *:7002[cluster]909302175 5773 1 0 One: 49 a.m.??0:00.03Redis-server *:7003[cluster]909302175 5780 1 0 One: 49 a.m.??0:00.02Redis-server *:7004[cluster]909302175 5787 1 0 One: 49 a.m.??0:00.01Redis-server *:7005[cluster]909302175 5790 952 0 One: 49 a.m. ttys0000:00.00 grepRedis
6: Execute redis Create cluster command to create cluster
Cd/usr/local/redis-3. 0.1/src. /REDIS-TRIB.RB 1127.0. 0.1:7000127.0. 0.1:7001127.0. 0.1:7002127.0. 0.1:7003127.0. 0.1:7004127.0. 0.1:7005
Please note: RVM and RubyGems are installed on the machine, just perform
Install redis-v
Ready to install REDIS-RB
Normal execution results are as follows
X0544:SRC wei.li$./REDIS-TRIB.RB Create--replicas1 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 clusterconnecting to Node127.0.0.1:7000: okconnecting to Node127.0.0.1:7001: okconnecting to Node127.0.0.1:7002: okconnecting to Node127.0.0.1:7003: okconnecting to Node127.0.0.1:7004: okconnecting to Node127.0.0.1:7005: OK>>> performing hash slots allocation on6nodes ... Using3Masters:127.0.0.1:7000127.0.0.1:7001127.0.0.1:7002Adding Replica127.0.0.1:7003To127.0.0.1:7000Adding Replica127.0.0.1:7004To127.0.0.1:7001Adding Replica127.0.0.1:7005To127.0.0.1:7002M:2CD16D3E6EB9F29BA578FBCF0627F3B3BB4653CF127.0.0.1:7000Slots:0-5460(5461slots) masterm:432d74a91b5f1b6358cf245a153160fcf4e93447127.0.0.1:7001Slots:5461-10922(5462slots) masterm:ecfbdc1268990a42968f1bd887341f02e679f01f127.0.0.1:7002Slots:10923-16383(5461slots) masters:cfacbc4067cbfffab2caa83858f0eebcb572c31d127.0.0.1:7003replicates 2cd16d3e6eb9f29ba578fbcf0627f3b3bb4653cfs:69d3240c55fb8209e5f248f76c7557d023c4420f127.0.0.1:7004replicates 432d74a91b5f1b6358cf245a153160fcf4e93447s:ff8c288967f944d463cf0a4d8712eb460e715c0f127.0.0.1:7005replicates Ecfbdc1268990a42968f1bd887341f02e679f01fcan I set the above configuration? (Type'Yes'to accept):
Enter Yes, and the configuration is complete.
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 toJoinThe clusterwaiting forThe cluster toJoin..>>> performing Cluster Check (using node127.0.0.1:7000) M:2CD16D3E6EB9F29BA578FBCF0627F3B3BB4653CF127.0.0.1:7000Slots:0-5460(5461slots) masterm:432d74a91b5f1b6358cf245a153160fcf4e93447127.0.0.1:7001Slots:5461-10922(5462slots) masterm:ecfbdc1268990a42968f1bd887341f02e679f01f127.0.0.1:7002Slots:10923-16383(5461slots) masterm:cfacbc4067cbfffab2caa83858f0eebcb572c31d127.0.0.1:7003Slots: (0slots) Master replicates 2cd16d3e6eb9f29ba578fbcf0627f3b3bb4653cfm:69d3240c55fb8209e5f248f76c7557d023c4420f 127.0.0.1:7004Slots: (0slots) Master replicates 432d74a91b5f1b6358cf245a153160fcf4e93447m:ff8c288967f944d463cf0a4d8712eb460e715c0f 127.0.0.1:7005Slots: (0slots) Master replicates Ecfbdc1268990a42968f1bd887341f02e679f01f[ok] All nodes agree about slots configuration.>>> Check forOpen Slots ...>>>Check Slots Coverage ... [OK] All16384slots covered. X0544:SRC wei.li$
This is where the Redis cluster is built successfully!
7: Use the REDIS-CLI command to enter the cluster environment
7000 127.0. 0.1:7000
Redis3.0.1 stable version of cluster deployment (MAC)