CentOS 6.8 minimal version installs RedisCluster of Redis cluster

Environment: CentOS6.8 minimal version

1, install yum install gcc
2, install yum install tcl
3, install curl -sSL https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash
4, Execute source /etc/profile.d/rvm.sh
5. Install rvm install 1.9.3
6. Install yum install -y rubygems
7. Install gem install redis --version 3.0.0
8. Download redis-3.2 from the official website. 5.tar.gz
9. Unzip tar -xvsf redis-3.2.5.tar.gz
10. Execute cd redis-3.2.5 to enter the directory and execute the make command So

far , the C compilation environment is installed, redis is installed, and ruby ​​is installed , ruby ​​is mainly a cluster cluster creation tool that requires a ruby ​​environment.

Next, deploy the redis_cluster cluster environment

11. Prepare three machines A, B, and C (more than half of the redis cluster master will go down, so two machines are meaningless for high availability)
12. Create directories mkdir /opt/redis_cluster respectively
13, Enter the directory cd /opt/redis_cluster
14.
Create folders named "7000" and "7001" in the
/opt/redis_cluster directory on machine A: mkdir 7000 7001 Create folders named "7002" and "7003" in the /opt/redis_cluster directory on machine B: mkdir 7002 7003
Create folders named "7004" and "7005" in the /opt/redis_cluster directory on the C machine: mkdir 7004 7005
15.
Enter the /opt/redis-3.2.5/src directory for the three machines respectively, and make a copy of cp The redis.conf file comes out to the /opt/redis_cluster/7000 directory, and the redis.conf file is modified. The original directory does not need to be moved. Specific modification matters: (only A machine)
original: port 6379
now: port 7000 (modified operating port)

original: bind 127.0.0.1
now: bind 192.168.10.239 127.0.0.1 (Note, the LAN IP must be placed in front of the local IP )

original: daemonize no
now: daemonize yes (modify background startup)

original: # cluster-enabled yes
now: cluster-enabled yes

original: # cluster-config-file nodes-6379.conf
Now: cluster-config-file /opt/redis_cluster/7000/nodes.conf

Original: # cluster-node-timeout 15000
Now: cluster-node-timeout 15000

Original: appendonly no
Now: appendonly yes

OK Save, modify this one The redis.conf file is placed under /opt/redis_cluster/7000. Note that the file name must be the same as the port value in redis.conf. The port is 7000, so the name of the directory where this conf file is stored must also be 7000.
Similarly, 7000 on machine A has been modified, and 7001 is also created.
Similarly, the 7002 and 7003 on the B machine are also created in this way.
Similarly, the 7004 and 7005 on the C machine are also created in this way.


16. Execute the redis A machine on the A, B, and C machines respectively
:
/opt/redis-3.2.5/src/redis-server /opt/redis_cluster/7000/redis.conf
/opt/redis-3.2.5/ src/redis-server /opt/redis_cluster/7001/redis.conf

Machine B executes:
/opt/redis-3.2.5/src/redis-server /opt/redis_cluster/7002/redis.conf
/opt/redis-3.2.5/src/redis-server /opt/redis_cluster/7003/redis.conf

C machine execution:
/opt/redis-3.2.5/src/redis-server /opt/redis_cluster/7004/redis .conf
/opt/redis-3.2.5/src/redis-server /opt/redis_cluster/7005/redis.conf

17. On machine A, go to /opt/redis-3.2.5/src and execute
./redis- trib.rb create --replicas 1 192.168.10.239:7000 192.168.10.239:7001 192.168.10.240:7002 192.168.10.240:7003 192.168.10.241:7004 192.168.10.241

OK prompt success.
18. Set test: (remember to use cluster mode connection, otherwise a movedError will occur)
/opt/redis-3.2.5/src/redis-cli -c -h 192.168.10.239 -p 7000
set aa
prompts reslove to other IP machines .

19. If there is an error in the middle, and want to reset it completely:
enter the 7000-7005 directory of the three machines, delete the nodes.conf file, kill all the redis processes, and restart the redis process.
rm -rf /opt/redis_cluster/7000/nodes.conf
rm -rf /opt/redis_cluster/7001/nodes.conf
rm -rf /opt/redis_cluster/7002/nodes.conf
rm -rf /opt/redis_cluster/7003/nodes.conf
rm -rf /opt/redis_cluster/7004/nodes.conf
rm -rf /opt/redis_cluster/7005/nodes.conf

20、参考文章:
http://www.cnblogs.com/junl0513/p/833f4d3eefc69485958fe83b5c9057d7.html
http://www.cnblogs.com/yuanermen/p/5717885.html
http://blog.csdn.net/ownfire/article/details/46624005
http://blog.csdn.net/prl18353364833/article/details/52459828
http://blog.csdn.net/c77_cn/article/details/38227797
http://blog.51yip.com/nosql/1726.html
http://www.cnblogs.com/kreo/p/4423362.html
http://blog.csdn.net/rockstar541/article/details/30245493

21. Common problems:

[ERR] Node is not empty. Either the node already knows other nodes
Solutions:
1) Put the new nodes under the Delete local backup files such as aof and rdb;
2) At the same time, delete the cluster configuration file of the new Node, that is: delete the file where the cluster-config-file is located in your redis.conf;
3) If the new node is added again, if an error is reported, Then log in to the new Node, ./redis-cli–hx –p to clear the database:
172.168.63.201:7001> flushdb #Clear the current database

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326852765&siteId=291194637
Recommended