我的编程空间,编程开发者的网络收藏夹
学习永远不晚

redis数据备份和迁移工具redis-dump如何安装使用

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

redis数据备份和迁移工具redis-dump如何安装使用

这篇文章主要介绍redis数据备份和迁移工具redis-dump如何安装使用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

一.安装:

# git clone https://github.com/delano/redis-dump.git

Initialized empty Git repository in /root/shell/20180928/redis-dump/.git/

remote: Enumerating objects: 691, done.

remote: Total 691 (delta 0), reused 0 (delta 0), pack-reused 691

Receiving objects: 100% (691/691), 2.09 MiB | 53 KiB/s, done.

Resolving deltas: 100% (293/293), done.

#gem install redis

Fetching: redis-4.0.2.gem (100%)

Successfully installed redis-4.0.2

Parsing documentation for redis-4.0.2

Installing ri documentation for redis-4.0.2

Done installing documentation for redis after 3 seconds

1 gem installed

#gem install uri-redis

Fetching: uri-redis-0.4.2.gem (100%)

Successfully installed uri-redis-0.4.2

Parsing documentation for uri-redis-0.4.2

Installing ri documentation for uri-redis-0.4.2

Done installing documentation for uri-redis after 0 seconds

1 gem installed

#gem install yajl-ruby

Fetching: yajl-ruby-1.4.1.gem (100%)

Building native extensions.  This could take a while...

Successfully installed yajl-ruby-1.4.1

Parsing documentation for yajl-ruby-1.4.1

Installing ri documentation for yajl-ruby-1.4.1

Done installing documentation for yajl-ruby after 1 seconds

1 gem installed

#gem install drydock

Fetching: drydock-0.6.9.gem (100%)

Successfully installed drydock-0.6.9

Parsing documentation for drydock-0.6.9

Installing ri documentation for drydock-0.6.9

Done installing documentation for drydock after 1 seconds

1 gem installed

#ruby -rubygems bin/redis-dump

{"db":0,"key":"192.168.184.122:6379:CommandCount:1528291051","ttl":-1,"type":"zset","value":[["LLEN",1.0],["DEL",3.0],["BRPOP",7.0],["RPOP",234.0],["SELECT",236.0],["HGET",360.0],["LPUSH",437.0],["GET",460.0]],"size":68}

{"db":0,"key":"192.168.184.226:6379:KeyCount:1528190344","ttl":-1,"type":"zset","value":[["1",1.0],["None",2.0],["zhsq_kb_comment_data",9.0],["zhsq_ecom_comment_buffer",36.0],["zhsq_topic_filter_buffer",120.0],["zhsq_filter_buffer",132.0],["zhsq_topic_data",183.0],["zhsq_mon_buffer",191.0],["zhsq_data",214.0],["zhsq_jfilter_data",225.0]],"size":190}

{"db":0,"key":"192.168.184.122:6379:CommandCountByMinute","ttl":-1,"type":"hash","value":{"180605:9:23":"22393","180606:13:16":"945","180606:13:17":"3568","180606:13:20":"11768"},"size":64}

{"db":0,"key":"192.168.184.220:6379:CommandCountByMinute","ttl":-1,"type":"hash","value":{"180605:9:23":"22998","180606:13:16":"993","180606:13:17":"3818","180606:13:20":"12101"},"size":64}

{"db":0,"key":"192.168.184.213:6379:KeyCount:1528291078","ttl":-1,"type":"zset","value":[["*",1845.0]],"size":7}

.........................................................................................................................................................................

.........................................................................................................................................................................

.........................................................................................................................................................................

.........................................................................................................................................................................

.........................................................................................................................................................................

{"db":1,"key":"hello","ttl":-1,"type":"string","value":"world","size":5}

{"db":5,"key":"dsf","ttl":-1,"type":"string","value":"chenfeng","size":8}

{"db":5,"key":"hello","ttl":-1,"type":"string","value":"world","size":5}

{"db":6,"key":"love","ttl":-1,"type":"string","value":"peihy","size":5}

{"db":6,"key":"dsf","ttl":-1,"type":"string","value":"chenfeng","size":8}

{"db":6,"key":"hello","ttl":-1,"type":"string","value":"world","size":5}

{"db":7,"key":"love","ttl":-1,"type":"string","value":"peihy","size":5}

{"db":7,"key":"chenfeng","ttl":-1,"type":"string","value":"dsf","size":3}

二.使用:

全库备份例子:

#cd redis-dump/bin

#./redis-dump -u 127.0.0.1  > /root/shell/20180928/db_all.json

只备份redis某个库的例子:

首先往10号库里写点数据:

#redis-cli

127.0.0.1:6379[1]> select 10

OK

127.0.0.1:6379[10]> set China World

OK

127.0.0.1:6379[10]> set love chenfeng

OK

127.0.0.1:6379[10]> set fuck America

OK

只备份10号库:

#./redis-dump -u 127.0.0.1 -d 10  > /root/shell/20180928/db_10.json

查看内容:

[root@alpha-mongo-140-52 ~/shell/20180928/redis-dump/bin]#cat /root/shell/20180928/db_10.json

{"db":10,"key":"fuck","ttl":-1,"type":"string","value":"America","size":7}

{"db":10,"key":"love","ttl":-1,"type":"string","value":"chenfeng","size":8}

{"db":10,"key":"China","ttl":-1,"type":"string","value":"World","size":5}

以上是“redis数据备份和迁移工具redis-dump如何安装使用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

redis数据备份和迁移工具redis-dump如何安装使用

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

如何使用PHP数据库迁移工具Phinx

这篇文章给大家分享的是有关如何使用PHP数据库迁移工具Phinx的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。1.安装composer require nhzex/think-phinx2.执行php vendo
2023-06-29

如何使用Go语言和Redis实现数据库备份

如何使用Go语言和Redis实现数据库备份云计算时代,数据的备份和恢复已经成为每个应用程序开发者和系统管理员必备的技能之一。而在进行数据库备份时,选择合适的工具和方法可以大大简化操作,并提高备份的效率。本文将介绍如何使用Go语言和Redis
2023-10-27

如何进行Linux系统上数据库管理和开发工具DBeaver使用安装

这篇文章给大家介绍如何进行Linux系统上数据库管理和开发工具DBeaver使用安装,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。简介在Windows上,有很多的MySQL客户端,但是在Linux上的好用的、兼容性好的
2023-06-28

如何使用MySQL的备份和还原技术保护数据的安全性?

如何使用MySQL的备份和还原技术保护数据的安全性?数据作为现代社会中最重要的资产之一,对于任何组织或个人来说都至关重要。在数据库管理系统中,MySQL是最受欢迎和广泛使用的开源关系数据库管理系统之一。然而,数据丢失或数据泄露风险始终存在,
2023-10-22

编程热搜

目录