首页 > 代码库 > [redis] redis-dump导出导入数据

[redis] redis-dump导出导入数据

环境说明:

172.20.0.1 旧redis

172.20.0.2 新redis

node101 任意linux系统

  1.安装redis-dump工具

[root@node111 ~]# yum install ruby rubygems ruby-devel -y
# 更改gem源
[root@node111 ~]# gem sources -a http://ruby.taobao.org
Error fetching http://ruby.taobao.org:
	bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)

  访问http://ruby.taobao.org,公告通知镜像维护站点已迁往Ruby China镜像

[root@node111 ~]# gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
https://gems.ruby-china.org/ added to sources
source https://rubygems.org/ not present in cache
[root@node111 ~]# gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.org/
[root@node111 ~]# gem install redis-dump -V

  2.node101导出

[root@node111 ~]# redis-dump -u :password@172.20.0.1:6379 > 172.20.0.1.json

  3.node101导入

[root@node111 ~]# cat 172.20.0.1.json | redis-load -u :password@172.20.0.2:6379

  

[redis] redis-dump导出导入数据