redis:备份dump.rdb [英] redis: backing up dump.rdb

查看:53
本文介绍了redis:备份dump.rdb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

我有一个实时运行的 redis 服务器.

我想备份.

想法:

我想做以下事情:

cp dump.rdb ~/some-other-location/06-24-2012.rdb ?

关注

我没有看到任何东西向我保证 dump.rdb 始终是一致的数据库存储.(即在我看来,当我执行 cp 时,redis 正在写入一些数据的一半,因此 dump.rdb 未处于一致状态.)

问题:

这很糟糕,因为我现在必须关闭 redis db 才能复制 dump.rdb

问题:

在 redis-server 运行时对数据库进行实时备份的正确方法是什么?以及手册的哪一部分向我保证此方法会创建一个处于一致(非半写)状态的数据库.

谢谢!

解决方案

来自 http://redis.io/topics/persistence

<块引用><块引用>

Redis 对数据备份非常友好,因为您可以在数据库运行时复制 RDB 文件:RDB 一旦生成就永远不会修改,并且在生成时使用临时名称并使用 rename(2) 仅当新快照完成时.

因此,正确的方法是简单地将 dump.rdb 复制到您的备份位置.

Context

I have a live running redis-server.

I want to make a backup.

Idea:

I want to do the following:

cp dump.rdb ~/some-other-location/06-24-2012.rdb ?

Concern

I don't see anything that promises me that dump.rdb is always a consistent database store. (I.e. it appears possible to me that while I am executing cp, redis is halfway through writing some piece of data, and thus dump.rdb is not in a consistent state.)

Problem:

This is bad, because I will now have to shut down the redis db in order to make a copy of dump.rdb

Question:

What is the correct way, while a redis-server is running, to make a live backup of the database? And what part of the manual promises me that this method creates a database that is in a consistent (not half written) state.

Thanks!

解决方案

From http://redis.io/topics/persistence

Redis is very data backup friendly since you can copy RDB files while the database is running: the RDB is never modified once produced, and while it gets produced it uses a temporary name and is renamed into its final destination atomically using rename(2) only when the new snapshot is complete.

So, the correct way is to simply copy the dump.rdb to your backup location.

这篇关于redis:备份dump.rdb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆