Redis如何修改redis-trib.rb使其import支持密码
短信预约 -IT技能 免费直播动态提醒
这篇文章给大家分享的是有关Redis如何修改redis-trib.rb使其import支持密码的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
需求,现在需要将一个单机redis数据迁移至redis-cluster集群中,两遍都是开启了密码模式的,无密码模式直接import就可以了!现在带密码我试了下import工具发现并不支持密码模式,修改下redis-trib.rb脚本即可支持密码认证了
target端如何支持密码上篇博客已经说明
以下修改为支持source端(单节点端)
修改地方为:
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'] 这行注释
# 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"
class="lazy" data-src_host,class="lazy" data-src_port,use_password = source_addr.split(":") ##这行修改添加密码
source = Redis.new(:host =>class="lazy" data-src_host, :port =>class="lazy" data-src_port, :password =>use_password) ##这行
使用如下:
[root@ip-172-31-40-224 class="lazy" data-src]# /usr/local/class="lazy" data-src/redis-4.0.8/class="lazy" data-src/redis-trib.rb import --from 172.31.40.224:6381:inH7HkD7iXoxKZCi --copy 172.31.40.224:6379
>>> Importing data from 172.31.40.224:6381:inH7HkD7iXoxKZCi to cluster
>>> Performing Cluster Check (using node 172.31.40.224:6379)
M: d5a1288c289dc27c014b34a0ec8280d2d4215747 172.31.40.224:6379
slots:0-5460 (5461 slots) master
1 additional replica(s)
S: 7475145029eeccdc91b8db415377888130868199 172.31.40.224:6380
slots: (0 slots) slave
replicates c78d49f041e386723fd921cea19421e34c0262b6
M: c78d49f041e386723fd921cea19421e34c0262b6 172.31.40.14:6379
slots:10923-16383 (5461 slots) master
1 additional replica(s)
M: 4164f6a49979952479e98ccde18e463e125dd438 172.31.35.125:6379
slots:5461-10922 (5462 slots) master
1 additional replica(s)
S: 725078c24574874197707b177375ee8dbf462099 172.31.35.125:6380
slots: (0 slots) slave
replicates d5a1288c289dc27c014b34a0ec8280d2d4215747
S: 5a1cbcec8b540dd5d7ce6268942386ce6e48878f 172.31.40.14: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 0
Migrating chen1 to 172.31.35.125:6379: OK
Migrating chen to 172.31.40.224:6379: OK
Migrating chen2 to 172.31.35.125:6379: OK
感谢各位的阅读!关于“Redis如何修改redis-trib.rb使其import支持密码”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341