Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use the redis data backup and migration tool redis-dump

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to install and use redis data backup and migration tool redis-dump. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

one。 Installation:

# git clone https://github.com/delano/redis-dump.git

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 KiB/s), 2.09 MiB | 53 KiB/s, done.

Resolving deltas: 100% (293amp 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", 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 192.168.184.122:6379:CommandCountByMinute" 23 ":" 22393 "," 180606 192.168.184.122:6379:CommandCountByMinute 13 "16": "945", "180606 13 192.168.184.122:6379:CommandCountByMinute 17": "3568", "180606 13 192.168.184.122:6379:CommandCountByMinute 20": "11768"}, "size": 64}

{"db": 0, "key": "192.168.184.220:6379:CommandCountByMinute", "ttl":-1, "type": "hash", "value": {"180605 type": "22998", "180606 192.168.184.220:6379:CommandCountByMinute 13": "993", "180606 13 192.168.184.220:6379:CommandCountByMinute 17": "3818", "180606 13 192.168.184.220:6379:CommandCountByMinute 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}

two。 Use:

Examples of full database backup:

# cd redis-dump/bin

#. / redis-dump-u 127.0.0.1 > / root/shell/20180928/db_all.json

An example of backing up only a library in redis:

First of all, write some data to Library 10:

# redis-cli

127.0.0.1 select 6379 [1] >

OK

127.0.0.1 set China World 6379 [10]

OK

127.0.0.1 set love chenfeng 6379 [10]

OK

127.0.0.1 set fuck America 6379 [10]

OK

Back up only Library 10:

#. / redis-dump-u 127.0.0.1-d 10 > / root/shell/20180928/db_10.json

View the content:

[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}

The above is all the contents of the article "how to install and use redis-dump, a redis data backup and migration tool". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report