Redis backup and restore, with the help of a third party tool, Redis-dump
1. Installation Redis-dump
Copy Code code as follows:
[Root@localhost tank]# yum install ruby rubygems ruby-devel/installation RubyGems and related packages
[Root@localhost tank]# gem sources-a http://ruby.taobao.org///source, add Taobao, outside the source can not access
http://ruby.taobao.org/added to sources
[root@localhost tank]# Gem install redis-dump-v//installation Redis-dump
2, Redis-dump Export data
Copy Code code as follows:
[root@localhost tank]# telnet 127.0.0.1 6379//telnet to Redis
Trying 127.0.0.1 ...
Connected to 127.0.0.1.
Escape character is ' ^] '.
Set test 11//Set a value
+ok
Get test//Take value
$
11
[Root@localhost tank]# redis-dump-u 127.0.0.1:6379 >test.json//Export Data
3, redis-load Restore data
Copy Code code as follows:
[root@localhost tank]# telnet 127.0.0.1 6379//telnet to Redis
Trying 127.0.0.1 ...
Connected to 127.0.0.1.
Escape character is ' ^] '.
Flushall//Please empty all data
+ok
Keys *//view cleared
*0
[Root@localhost tank]# < Test.json redis-load//Import data
[root@localhost tank]# telnet 127.0.0.1 6379
Trying 127.0.0.1 ...
Connected to 127.0.0.1.
Escape character is ' ^] '.
Keys *//successfully imported
*1
$
Test