Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Redis modifies redis-trib.rb to enable its import to support passwords

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how Redis modifies redis-trib.rb to make its import support passwords. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Requirements, now need to migrate a stand-alone redis data to the redis-cluster cluster, the password mode is turned on twice, no password mode can be directly import! Now with password, I tried the import tool and found that it does not support password mode. You can modify the redis-trib.rb script to support password authentication.

How to support password on target side has been explained in the previous blog.

The following is modified to support source side (single node side)

Modify it as follows:

Def import_cluster_cmd (argv,opt) source_addr = opt ['from'] xputs "> > Importing data from # {source_addr} to cluster # {argv [1]}" use_copy = opt [' copy'] use_replace = opt ['replace'] # use_password = opt [' password'] note # Check the existing cluster. Load_cluster_info_from_node (argv [0]) check_cluster # Connect to the source node. Xputs "> > Connecting to the source Redis instance" src_host,src_port,use_password = source_addr.split (":") # # modify and add password source = Redis.new (: host = > src_host,: port = > src_port,: password = > use_password) # # this line

The use is as follows:

[root@ip-172-31-40-224 src] # / usr/local/src/redis-4.0.8/src/redis-trib.rb import-- from 172.31.40.224:6381:inH7HkD7iXoxKZCi-- copy 172.31.40.224 copy 6379 > Importing data from 172.31.40.224:6381:inH7HkD7iXoxKZCi to cluster > Performing Cluster Check (using node 172.31.40.22424 copy 6379) M: d5a1288c289dc27c014b34a0ec8280d2d4215747 172.31.40.224 slots 6379 slots:0-5460 (5461 slots ) master 1 additional replica (s) S: 7475145029eeccdc91b8db415377888130868199 172.31.40.2244164f6a49979952479e98ccde18e463e125dd438 6380 slots: (0 slots) slave replicates c78d49f041e386723fd921cea19421e34c0262b6M: c78d49f041e386723fd921cea19421e34c0262b6 172.31.40.14 additional replica 6379 slots:10923-16383 (5461 slots) master 1 additional replica (s) M: 4164f6a49979952479e98ccde18e463e125dd438 172.31.125 master 1 additional replica (s) slots:5461-10922 (5462 slots) master 1 additional replica (s) S: 725078c24574874197707b177375ee8dbf462099 172.31.125 master 6380 slots: (0 slots) slave replicates d5a1288c289dc27c014b34a0ec8280d2d4215747S: 5a1cbcec8b540dd5d7ce6268942386ce6e48878f 172. 31.40.14All nodes agree about slots configuration 6380 slots: (0 slots) slave replicates 4164f6a49979952479e98ccde18e463e125dd438 [OK] All nodes agree about slots configuration. > > Check for open slots... > Check slots coverage... [OK] All 16384 slots covered. > > Connecting to the source Redis instance*** Importing 3 keys from DB 0Migrating chen1 to 172.31.35.125 keys from DB 0Migrating chen1 to 6379: OKMigrating chen to 172.31.40.2246379: OKMigrating chen2 to 172.31.35.125 Connecting to the source Redis instance*** Importing 6379: OK Thank you for reading! This is the end of this article on "how Redis modifies redis-trib.rb to make its import support password". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report