Tag Archives: redistrib.rb

[Solved] Execute the redis command redis-trib.rb to view the cluster information error: cannot load such file — redis (LoadError)

Problem Description:

When you execute the redis-trib.rb command to view the cluster status, an error is reported:

[aiprd@hadoop1 ~]$ redis-trib.rb check 192.168.30.10:7000
Traceback (most recent call last):
    2: from /home/aiprd/softwares/redis-3.2.5/src/redis-trib.rb:25:in `<main>'
    1: from /home/aiprd/app/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/aiprd/app/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- redis (LoadError)

Solution:

1. Judging from the error, the redis component is missing

2. Download redis component

Download address: https://rubygems.org/downloads/redis-4.1.2.gem

3. Upload to the server and install [offline installation of gem components]

[aiprd@hadoop1 softwares]$ gem install -l redis-4.1.2.gem 
Successfully installed redis-4.1.2
Parsing documentation for redis-4.1.2
Installing ri documentation for redis-4.1.2
Done installing documentation for redis after 0 seconds
1 gem installed

Because the redis I installed is version 3, the redis component downloaded should also be version 3

Download at: http://rubygems.org/downloads/redis-3.3.5.gem

4. Execute the command to view cluster information again

[aiprd@hadoop1 softwares]$ redis-trib.rb check 192.168.30.10:7000
[ERR] Sorry, can't connect to node 192.168.30.10:7000

An error is reported and the cluster node cannot be connected. Since the redis cluster has enabled authentication, the authentication password of the redis cluster needs to be configured in the client program of the redis component

5. Enter the ruby installation path and find the redis client.rb file

[aiprd@hadoop1 ~]$ cd /home/aiprd/app/ruby/lib/ruby/gems/2.6.0/gems/redis-4.1.2/lib/redis  #/home/aiprd/app/ruby是ruby的安装路径,即--prefix指定的路径
[aiprd@hadoop1 redis]$ ls -l client.rb
-rw-r--r-- 1 aiprd aiprd 16407 Aug  2 11:06 client.rb

6. Modify the file and add the password as follows:

:password => "3GESWjNba9@pMDG",

7. Execute the command to view cluster status information again

[aiprd@hadoop1 ~]$ redis-trib.rb check 192.168.30.10:7000
>>> Performing Cluster Check (using node 192.168.30.10:7000)
M: 2c8bb60808a0b2bcb155eb45759b8c989cb409f3 192.168.30.10:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
M: 4161a6852df45ee50a065e5e275a24cb1b77f1c1 192.168.30.10:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
M: b7fdb4a783aa829818eb804c0cc04161ece5e845 192.168.30.10:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: e6b0a64e05e5f3e8dc4b369967090f78fe3c87dc 192.168.30.11:7005
   slots: (0 slots) slave
   replicates b7fdb4a783aa829818eb804c0cc04161ece5e845
S: 37168bd4232c2d1f1f9a22bd88f221e4f15bf4d9 192.168.30.11:7003
   slots: (0 slots) slave
   replicates 4161a6852df45ee50a065e5e275a24cb1b77f1c1
S: cab31dd3554524187ffb4a2758af91f72c8238ac 192.168.30.11:7004
   slots: (0 slots) slave
   replicates 2c8bb60808a0b2bcb155eb45759b8c989cb409f3
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

The command is executed successfully, and the problem is solved.