redis資料備份和遷移工具redis-dump安裝和使用初探
一.安裝:
# git clone
Initialized empty Git repository in /root/shell/20180928/redis-dump/.git/
remote: Enumerating objects: 691, done.
remote: Total 691 (delta 0), reused 0 (delta 0), pack-reused 691
Receiving objects: 100% (691/691), 2.09 MiB | 53 KiB/s, done.
Resolving deltas: 100% (293/293), done.
#gem install redis
Fetching: redis-4.0.2.gem (100%)
Successfully installed redis-4.0.2
Parsing documentation for redis-4.0.2
Installing ri documentation for redis-4.0.2
Done installing documentation for redis after 3 seconds
1 gem installed
#gem install uri-redis
Fetching: uri-redis-0.4.2.gem (100%)
Successfully installed uri-redis-0.4.2
Parsing documentation for uri-redis-0.4.2
Installing ri documentation for uri-redis-0.4.2
Done installing documentation for uri-redis after 0 seconds
1 gem installed
#gem install yajl-ruby
Fetching: yajl-ruby-1.4.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed yajl-ruby-1.4.1
Parsing documentation for yajl-ruby-1.4.1
Installing ri documentation for yajl-ruby-1.4.1
Done installing documentation for yajl-ruby after 1 seconds
1 gem installed
#gem install drydock
Fetching: drydock-0.6.9.gem (100%)
Successfully installed drydock-0.6.9
Parsing documentation for drydock-0.6.9
Installing ri documentation for drydock-0.6.9
Done installing documentation for drydock after 1 seconds
1 gem installed
#ruby -rubygems bin/redis-dump
{"db":0,"key":"192.168.184.122:6379:CommandCount:1528291051","ttl":-1,"type":"zset","value":[["LLEN",1.0],["DEL",3.0],["BRPOP",7.0],["RPOP",234.0],["SELECT",236.0],["HGET",360.0],["LPUSH",437.0],["GET",460.0]],"size":68}
{"db":0,"key":"192.168.184.226:6379:KeyCount:1528190344","ttl":-1,"type":"zset","value":[["1",1.0],["None",2.0],["zhsq_kb_comment_data",9.0],["zhsq_ecom_comment_buffer",36.0],["zhsq_topic_filter_buffer",120.0],["zhsq_filter_buffer",132.0],["zhsq_topic_data",183.0],["zhsq_mon_buffer",191.0],["zhsq_data",214.0],["zhsq_jfilter_data",225.0]],"size":190}
{"db":0,"key":"192.168.184.122:6379:CommandCountByMinute","ttl":-1,"type":"hash","value":{"180605:9:23":"22393","180606:13:16":"945","180606:13:17":"3568","180606:13:20":"11768"},"size":64}
{"db":0,"key":"192.168.184.220:6379:CommandCountByMinute","ttl":-1,"type":"hash","value":{"180605:9:23":"22998","180606:13:16":"993","180606:13:17":"3818","180606:13:20":"12101"},"size":64}
{"db":0,"key":"192.168.184.213:6379:KeyCount:1528291078","ttl":-1,"type":"zset","value":[["*",1845.0]],"size":7}
.........................................................................................................................................................................
.........................................................................................................................................................................
.........................................................................................................................................................................
.........................................................................................................................................................................
.........................................................................................................................................................................
{"db":1,"key":"hello","ttl":-1,"type":"string","value":"world","size":5}
{"db":5,"key":"dsf","ttl":-1,"type":"string","value":"chenfeng","size":8}
{"db":5,"key":"hello","ttl":-1,"type":"string","value":"world","size":5}
{"db":6,"key":"love","ttl":-1,"type":"string","value":"peihy","size":5}
{"db":6,"key":"dsf","ttl":-1,"type":"string","value":"chenfeng","size":8}
{"db":6,"key":"hello","ttl":-1,"type":"string","value":"world","size":5}
{"db":7,"key":"love","ttl":-1,"type":"string","value":"peihy","size":5}
{"db":7,"key":"chenfeng","ttl":-1,"type":"string","value":"dsf","size":3}
二.使用:
全庫備份例子:
#cd redis-dump/bin
#./redis-dump -u 127.0.0.1 > /root/shell/20180928/db_all.json
只備份redis某個庫的例子:
首先往10號庫裡寫點資料:
#redis-cli
127.0.0.1:6379[1]> select 10
OK
127.0.0.1:6379[10]> set China World
OK
127.0.0.1:6379[10]> set love chenfeng
OK
127.0.0.1:6379[10]> set fuck America
OK
只備份10號庫:
#./redis-dump -u 127.0.0.1 -d 10 > /root/shell/20180928/db_10.json
檢視內容:
[root@alpha-mongo-140-52 ~/shell/20180928/redis-dump/bin]#cat /root/shell/20180928/db_10.json
{"db":10,"key":"fuck","ttl":-1,"type":"string","value":"America","size":7}
{"db":10,"key":"love","ttl":-1,"type":"string","value":"chenfeng","size":8}
{"db":10,"key":"China","ttl":-1,"type":"string","value":"World","size":5}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2215122/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Alibaba 資料庫遷移開源工具 Datax 安裝和使用資料庫開源工具
- Redis migrate 資料遷移工具Redis
- redis 單機和cluster資料遷移Redis
- dnf資料庫備份&遷移資料庫
- Velero:備份、遷移Kubernetes叢集資源和PV
- 在Ubuntu 14.04上備份,還原和遷移MongoDB資料庫UbuntuMongoDB資料庫
- SSDB安裝和使用初探
- Redis資料遷移同步工具(redis-shake)Redis
- SVN倉庫備份和遷移基本操作
- Jira/Confluence的備份、恢復和遷移
- MongoDB 資料遷移 備份 匯入(自用)MongoDB
- mysql 備份與遷移 資料同步方法MySql
- 【Redis】 redis資料遷移Redis
- 工作日誌,多租戶模式下的資料備份和遷移模式
- Mac硬碟備份遷移資料工具:Carbon Copy Cloner 簡稱CCCMac硬碟
- 初探MySQL資料備份及備份原理MySql
- redis效能監控工具redis-stat安裝初探Redis
- redis資料庫遷移Redis資料庫
- Redis(1)- Redis資料庫的安裝和配置Redis資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- clickhouse for centos7安裝和使用初探CentOS
- 資料同步和資料備份
- redis 備份和恢復Redis
- 使用docker安裝mysql和redisDockerMySqlRedis
- 快速實現本地資料備份與FTP遠端資料遷移FTP
- TDSQL資料同步和備份SQL
- MySQL備份遷移之mydumperMySql
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- windows下Redis的安裝和使用WindowsRedis
- elasticdump資料遷移與內外網安裝AST
- redis叢集 資料遷移方案Redis
- 實際使用Elasticdump工具對Elasticsearch叢集進行資料備份和資料還原Elasticsearch
- 【Redis破障之路】二:Redis安裝和基本資料結構Redis資料結構
- Mysql資料備份和還原MySql
- NBU 8.0客戶端安裝和備份配置客戶端
- 安裝和使用 otter (資料同步利器)
- docker 容器操作、應用部署、mysql,redis,nginx、遷移與備份、DockerfileDockerMySqlRedisNginx
- Laravel資料庫遷移和填充(支援中文)Laravel資料庫