Redis cluster Features: Many machines, can ensure that Redis server problems, small impact, self-master structure, Automatically according to the algorithm to divide the master-slave structure. Dynamic implementation, can be based on the master-slave structure of the automatic implementation of high availability, the realization of data file backup, this article for you to share a Redis cluster construction graphics tutorial, has a good reference value, hope to help everyone.
3.Redis Cluster Setup steps:
Prepare 9 Servers 3 master 6 from a host with 2 child nodes
7000-7008
2. Copy the redis.conf file into the folder
CP redis.conf 7000/redis-7000.conf
mkdir 7000 7001 7002 7003 7004 7005 7006 7007 7008
3. Modifying configuration file Parameters Vim redis-conf
1. Unregister the bound port number
2. Turn off protection mode
3. Modify the port number
4. Background Operation Open
5. Specify the path to the PID file
Create the relevant file directory yourself by absolute path indicating where the file is stored
6. Modify the Dump log file path
If you do not modify the dump file, then each log file is common
7. Enable the binary log
8. Enable Cluster
9. Modify the cluster mate file
Change the port number to 7000 to open the cluster time-out
10. If you mount the master-slave relationship, you need to delete
Remove Master-Slave mount Delete get is comment
11. Copy the configuration files to 7001-7008 separately, you need to modify the port number
Execute the following command to first modify all 7000 in the file to 7001
:%s/7000/7001/g Note: The delegate replaces all 7000 of the current text with 7001
12. Modify the 7002-7008 configuration file, respectively
13. Create a shell script file to start multiple Redis services from 7000-7008
#!/bin/sh
Redis-server 7000/redis-7000.conf &
Redis-server 7001/redis-7001.conf &
Redis-server 7002/redis-7002.conf &
Redis-server 7003/redis-7003.conf &
Redis-server 7004/redis-7004.conf &
Redis-server 7005/redis-7005.conf &
Redis-server 7006/redis-7006.conf &
Redis-server 7007/redis-7007.conf &
Redis-server 7008/redis-7008.conf
#!/bin/sh indicates that a shell script is being edited
14. Start the shell script
15. See if the Redis service is started
The above indicates that the Redis file started successfully
16. Turn off the firewall
Service Iptables Stop
17. Check if cluster startup is successful
3. Start the Redis cluster with ruby files (if not the network may not be able to Baidu how to install ruby)
1. Add plugin using Yum installation has been added without action
Yum Install Ruby
Ruby–v #ruby 1.8.7
Yum install rubygems #也可以一句执行 yum install ruby Rubygems-y
Gem Install Redis #安装redis的接口包
Gem list #查看是否安装了gem相关的接口包 to check if Redis already exists
The ruby plug-in is already installed in the virtual machine that was issued, so there is no need to install it again
2. Command execution configuration 1 Master 2 from structure
./SRC/REDIS-TRIB.RB Create--replicas 2 192.168.247.150:7000 192.168.247.150:7001 192.168.247.150:7002 192.168.247.150:7003 192.168.247.150:7004 192.168.247.150:7005 192.168.247.150:7006 192.168.247.150:7007 192.168.247.150:7008
One of the 2 represents a host under which several slave nodes are mounted. This cluster is configured with a Master 2 slave, 3 hosts, 6 slave machines, and a total of 9 Redis servers.
Indicates a successful mount
M indicates that the primary node s represents the slave node information
Indicates whether the mount is OK: Enter Yes or the error will be
4.Redis Cluster Start-up
1. Do not shut down the service. Save in a suspended form
2. If you start after shutdown, first note that the firewall is turned off first.
3. If the cluster starts correctly. But the Java program error jediscluster error.
1. Check that the jar package files are correct
2. Check the IP address of the Redis cluster. 192.168.154.196