One, the same machine under the cluster construction:
1, create a unified folder for Redis instances--Create Cluster folder under/usr/local Path, command: mkdir cluster
2, create a separate folder for each instance--Create 6 folders under the Cluster folder, respectively, 7001,7002,7003,7004,7005,7006,
Command: mkdir 7001 7002 7003 7004 7005 7006
3, upload the downloaded redis-3.2.8.tar.gz to the virtual machine's/usr/local/redis (premise first built a Redis), and Unzip, command: TAR–ZXVF redis-3.2.8.tar.gz, get redis-3.2.8 Package
4, install GCC, execute yum-y install gcc gcc-c++ libstdc++-devel and make cflags= "-march=x86-64" two times enter Y to continue the installation, After the installation is complete and then enter the redis-3.2.8 package, execute the Make install PREFIX=/USR/LOCAL/REDIS2 command
5, go to cd/usr/local/redis2c, copy the Bin folder to the previous 6 packages created below (/usr/local/cluster/700*),
such as: Cp-r bin/usr/local/cluster/7001
Copy redis-3.2.8 under Redis.conf to/usr/local/cluster below and enter the directory
6, modify the redis.conf file, modify the content as follows
1) block restrict local access, add # before bind 127.0.0.1 (same machine, may not need to change, do not test)
2) Change Protected-mode after yes to No
3) No change to Yes after daemonize
4) Remove cluster-enabled Yes before the # (press ESC to exit I edit mode, input/, and then enter cluster-enabled, enter, you can quickly find)
5) Remove # method with 4)
6) port after the port number is changed 6 times, each change to the previous creation of the 6 package name consistent, such as 7001, each change, the redis.conf file, copied to the corresponding package, such as 7001 (port as long as the conflict can be arbitrarily changed, here for the convenience of management change and package name consistent)
7, launch 6 Redis instances separately and view
8, enter Cd/usr/local/redis/redis-3.2.8/src, execute./REDIS-TRIB.RB Create--replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0 .1:7,003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006, reported a mistake, as follows
Need to install:
1) Ruby Environment, execute command: Yum install Ruby
2) RubyGems component, execute command: Yum install RubyGems
3) Redis and Ruby interface, execute command: Gem install Redis
If you report an error such as node 192.168.133.xx:7001 is not empty, the cluster does not shut down properly or the log file is stored
Perform cluster repair command for error message:./REDIS-TRIB.RB fix 192.168.133.128:7001
9, after the installation is complete, start the command again, and enter Yes and return
10, Start success
11, do the next test, casually into a redis instance, such as Enter cd/usr/local/cluster/7001 under execution./BIN/REDIS-CLI-C-P 7001
Second, the cluster construction under different machines:
Note: The Redis installation procedure is consistent with the same machine, which only explains the changes of individual configurations
1, first create three additional virtual machines (only 3 are created for the convenience of demo)
2, each set fixed IP (not set, can refer to: http://blog.csdn.net/u012042021/article/details/72781888)
Node1 is set to 192.168.133.128;
Node2 is set to 192.168.133.129;
Node3 set to 192.168.133.130
3, each set up two Redis instances (as with the same machine), respectively:
Node1 under 7001, 7002;
Node2 under 7003, 7004;
Node3 under 7005, 7006
4, respectively, modify the corresponding 2 Redis instances of the 3 machine redis.conf file bindings corresponding machine IP, such as Node1 under the two Redis configuration changed to bind 192.168.133.128, save exit
Note: To turn off the firewall for each virtual machine after you have changed it, execute the command: Service iptables stop--takes effect immediately, permanently shuts down the Firewall execution command: chkconfig iptables off--Restart takes effect
5, start each of these 6 instances
Node1:
Node2:
NODE3:
6, enter Node2 (whatever that station) CD/USR/LOCAL/REDIS/REDIS-3.2.8/SRC under (your decompression directory), execute
./redis-trib.rb Create--replicas 1 192.168.133.128:7001 192.168.133.128:7002 192.168.133.129:7001 192.168.133.129: 7002 192.168.133.130:7001 192.168.133.130:7002
7, all components are installed in accordance with the same machine, still reported a fault
8, there are two types of solutions, the official recommended use of the second:
1) Delete the three files under the instance package, and then restart
2) Perform cluster repair command for error message:./REDIS-TRIB.RB fix 192.168.133.128:7001
Start-up consistent with the machine
9, test, casually into a machine, such as NODE3, casually into a redis instance, such as 7002,
Perform set, get test
Then enter another machine, such as Node1, to check get
10, end, thank you for reading.