Home > Database > Redis > Detailed explanation of data backup and recovery using Redis RDB

Detailed explanation of data backup and recovery using Redis RDB

藏色散人
Release: 2020-11-06 15:09:10
forward
2654 people have browsed it

下面由Redis教程栏目给大家介绍Redis RDB方式数据备份与恢复,希望对需要的朋友有所帮助!

Detailed explanation of data backup and recovery using Redis RDB

Redis数据备份

实例

127.0.0.1:6379> bgsave
OK
Copy after login

这里为什么用bgsave而不使用save,请参考文章:

redis 持久化详解,RDB是什么?

Redis恢复数据

1、 获取redis备份目录

127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "D:\\software\\Redis"
127.0.0.1:6379>
Copy after login

以上命令 CONFIG GET dir 输出的 redis 备份目录为 /usr/local/redis/bin。

2、 停止redis服务

src/redis-cli -p 6379 shutdown
Copy after login

src是redis安装目录

3、拷贝redis备份文件(dump.rdb)到 /usr/local/redis/bin目录下

4、重新启动redis服务

linux
src/redis-server redis.conf
windows
src/redis-server redis.windows.conf
Copy after login

5、查看是否redis恢复数据

$ src/redis-cli
127.0.0.1:6379> keys *
 1) "k1"
 2) "k2"
 3) "k3"
 4) "k4"
 5) "k5"
Copy after login

The above is the detailed content of Detailed explanation of data backup and recovery using Redis RDB. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template