REDIS-TRIB.RB is a REDIS cluster management tool implemented with Ruby. Internally through cluster related commands to simplify the common operations of cluster creation, inspection, slot migration and equalization
1.ruby Installation
Download Address: wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz
./configure-prefix=/usr/local/ruby Make make Install Cd/usr/local/ruby Cp/usr/local/ruby/bin/ruby/usr/local/bin Cp/usr/local/ruby/bin/gem/usr/local/bin |
Download: Https://rubygems.org/downloads/redis-4.0.1.gem
[Root@localhost tools]# gem install-l redis-4.0.1.gem error:loading command:install (loaderror) cannot load such file --zlib error:while executing gem ... (nomethoderror) undefined method ' Invoke_with_build_args ' for Nil:nilclass |
The solution is:
Yum-y Install Zlib-devel Enter the ruby source folder to install Ruby itself with the Zlib package CD Ruby-2.5.1/ext/zlib Ruby./extconf.rb [Root@localhost zlib]# make Make: * * * No rule to do target '/include/ruby.h ', needed by ' ZLIB.O '. Stop. This time to open the Ext/zlib/makefile file, find the following line to modify the path. #zlib. O: $ (top_srcdir)/include/ruby.h zlib.o:.. /.. /include/ruby.h |
Make make Install
2. Installation
[Root@localhost tools]# Gem install-l redis-4.0.1.gem Gem list--check Redis gem cp/usr/local/redis/src/redis-trib.rb/usr/local/bin/ |
3. After you install the Ruby environment, execute the REDIS-TRIB.RB command to confirm that it is correct
[Root@localhost src]# redis-trib.rb usage:redis-trib <command> <options> <arguments ...> Create host1 :p ort1 ... hostn:portn--replicas <arg> ... |
You can use the REDI-TRIB.RB create command to quickly build a cluster
4. Prepare the node
Configure the configuration file and start
Port 6000 Daemonize Yes LogFile "6000.log" Dir "/data/redis/data/" Dbfilename Dump-6000.rdb cluster-enabled Yes #开启集群模式 cluster-node-timeout 15000 #节点超时时间, unit milliseconds Cluster-config-file "Nodes-6000.conf" #集群内部配置文件 |
5. Start all Nodes
Redis-server/data/redis/conf/redis-6001.conf Redis-server/data/redis/conf/redis-6002.conf Redis-server/data/redis/conf/redis-6003.conf Redis-server/data/redis/conf/redis-6004.conf Redis-server/data/redis/conf/redis-6005.conf redis-server/data/redis/conf/redis-6006.conf |
6. Create a cluster
After starting 6 nodes, the process of using the REDIS-TRIB.RB Create command to complete the handshake and allocate slots
REDIS-TRIB.RB Create--replicas 1 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 127.0.0.1:6004 127.0.0.1:6005 127.0.0.1:6006 |
>>> Creating cluster >>> performing hash slots allocation on 6 nodes ... Using 3 masters:127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 Adding replica 127.0.0.1:6004 to 127.0.0.1:6001 Adding repli CA 127.0.0.1:6005 to 127.0.0.1:6002 Adding replica 127.0.0.1:6006 to 127.0.0.1:6003 M: BE3270C92BA98C1B67CE4C76569680E1CE873A10 127.0.0.1:6001 slots:0-5460 (5461 slots) Master M: 59fe00990b0675fbf9b5693aa875ab94b1a642ce 127.0.0.1:6002 |