安装redis-dump
[root@bogon ~] yum install ruby rubygems ruby-devel //安装rubygems 以及相关包
[root@bogon ~] gem sources -a http://gems.ruby-china.org/ //源,ruby china加入,外面的源不能访问
http://gems.ruby-china.org/ added to sources
[root@bogon ~] gem install redis-dump -V
redis-dump导出数据
[root@bogon ~] telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set test 11 //设置一个值
+OK
get test //取值
$2
11
[root@bogon ~] redis-dump -u :passwd@127.0.0.1:6379 >test.json
[root@bogon ~] telnet 127.0.0.1 6379 //telnet到redis Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. flushall //请空所有数据 +OK keys * //查看已清空 *0
redis-load还原数据
[root@bogon ~] < test.json redis-load //导入数据
[root@bogon ~] telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
keys *
*1
$4
test
redis -load 并不能指定端口号 一台多实例 ,实现不了 。redis-loab 指定另一个实例