-
利用gem命令安装redis-dump ,必须先安装ruby:
下载 https://rubyinstaller.org/downloads/ -
安装ruby后,执行 gem install redis-dump
C:\Windows\system32>gem install redis-dump
Fetching redis-dump-0.4.0.gem
Fetching yajl-ruby-1.4.1.gem
Fetching redis-4.1.2.gem
Fetching uri-redis-0.4.2.gem
Fetching drydock-0.6.9.gem
Temporarily enhancing PATH for MSYS/MINGW…
Building native extensions. This could take a while…
Successfully installed yajl-ruby-1.4.1
Successfully installed redis-4.1.2
Successfully installed uri-redis-0.4.2
Successfully installed drydock-0.6.9
Successfully installed redis-dump-0.4.0
Parsing documentation for yajl-ruby-1.4.1
Installing ri documentation for yajl-ruby-1.4.1
Parsing documentation for redis-4.1.2
Installing ri documentation for redis-4.1.2
Parsing documentation for uri-redis-0.4.2
Installing ri documentation for uri-redis-0.4.2
Parsing documentation for drydock-0.6.9
Installing ri documentation for drydock-0.6.9
Parsing documentation for redis-dump-0.4.0
Installing ri documentation for redis-dump-0.4.0
Done installing documentation for yajl-ruby, redis, uri-redis, drydock, redis-dump after 2 seconds
5 gems installed -
验证redis-dump是否安装成功
C:\Windows\system32>redis-dump
ERROR (Errno::ENOENT): No such file or directory - ps -o rss= -p 42676
C:\Ruby26-x64\lib\ruby\gems\2.6.0\gems\redis-dump-0.4.0\lib\redis\dump.rb
注释掉该行
ps -o rss= -p #{Process.pid}
.to_i # in kb
导出数据: -d 0 代表第1个数据库.
redis-dump -u 127.0.0.1:6379 -d 0 >test.json
导入数据:
<test.json redis-load -u 127.0.0.1:6379 -d 3
测试下来,发现导出数据没有问题,但是把数据从db=0 导入到db=3 有点问题,执行命令是正常的,但是从数据库中查看db=3 却没有数据
备注: 修改test.json里的数据,然后 执行:
<test.json redis-load -u 127.0.0.1:6379
查看db=0对应的数据库是有更新的…
有哪位大神知道,为什么从db=0 导入到 db=3不行?