Note the use of
redis3.0
version.
Version 3.0
mainly adds the
redis
cluster function.
1. Preconditions
①yum install gcc-c++
②ruby environment
Installation command:
yum install ruby
yum install rubygems
③Interface program of ruby and redis
Copy redis-3.0.0.gem to /usr/local/redis
Excuting an order:
gem install /usr/local/redis/redis-3.0.0.gem
2. Cluster environment planning
6 servers (three masters and three slaves)
master node:
111.231.87.104:7001 111.231.87.104:7002 111.231.87.104:7003
From node:
111.231.87.104:7004 111.231.87.104:7005 111.231.87.104:7006
3. Establish a pseudo-cluster environment
Excuting an order:
cd /usr/local
mkdir redis-cluster
Copy /usr/local/redis/bin to the redis-cluster directory
Copy 6 redis
Excuting an order:
cd /usr/local/redis
cp -r bin /usr/local/redis-cluster/redis01
Modify the configuration file
port:7001
cluster-enable yes
Copy /mysoft/redis/*.rb to redis-cluster
Write startup/shutdown scripts
Create a cluster
./redis-trib.rb create --replicas 1 192.168.52.128:7001 192.168.52.128:7002 192.168.52.128:7003 192.168.52.128:7004 192.168.52.128:7005 192.168.52.128:7006
Connect to the cluster client
./redis01/redis-cli -h 111.231.87.104 -p 7001 -c
-h IP address
-p port number
-c means cluster
Fourth, problem solving
①
err slot 0 is already busy (redis::commanderror)
Card slot is occupied
check command
./redis-trib.rb check 111.231.87.104:7001
repair command
./redis-trib.rb fix 111.231.87.104:7001
After deleting the generated file (if the data is not needed)
②I
have been waiting for Waiting for the cluster to join for a long time and there is no response
The redis cluster not only needs to open the client port, but also the cluster bus port
Requires current port number + 10000
7001 → 17001
7002 → 17002
7003 → 17003
7004 → 17004
7005 → 17005
7006 → 17006
I have opened 6 redis instances here, requiring a total of 12 port numbers
.