Redis如何修改redis-trib.rb使其import支持密码
这篇文章给大家分享的是有关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" src_host,src_port,use_password = source_addr.split(":") ##这行修改添加密码 source = Redis.new(:host =>src_host, :port =>src_port, :password =>use_password) ##这行
使用如下:
[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: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支持密码”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
新闻名称:Redis如何修改redis-trib.rb使其import支持密码
路径分享:http://azwzsj.com/article/jddsoo.html