redis數據導入導出的方法:
1.通過redis-dump工具進行導入導出,在終端命令行通過以下命令進行安裝。
//安裝redis-dump工具
[root@202.102.221.13 ~]$ yum install ruby rubygems ruby-devel -y
2.更改gem源,代碼如下。
[root@202.102.221.13 ~]$ 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鏡像
#gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
[root@202.102.221.13 ~]$ gem sources --add http://gems.ruby-china.org/ --remove http://rubygems.org/
http://gems.ruby-china.org/ added to sources
source http://rubygems.org/ not present in cache
[root@202.102.221.13 ~]$ gem sources -l \*\*\* CURRENT SOURCES *** http://gems.ruby-china.org/
[root@202.102.221.13 ~]$ gem install redis-dump -V
3.安裝成功后,使用redis-load導入或者redis-dump導出。
//redis-load導入
[root@202.102.221.13 ~]$ cat 202.102.221.11.json | redis-load -u :password@202.102.221.12:6379
//redis-dump導出
[root@202.102.221.13 ~]$ redis-dump -u :password@202.102.221.11:6379 \> 202.102.221.11.json
4.環境說明:
202.102.221.11 redis源實例
202.102.221.12 redis目標實例
202.102.221.13 任意linux系統