redis 是持久数据存储吗? [英] Is redis a durable datastore?

查看:31
本文介绍了redis 是持久数据存储吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

耐用"是指服务器随时可能崩溃,只要磁盘保持完好,就不会丢失任何数据(参见 ACID).似乎这就是日志模式的用途,但是如果启用日志,那岂不是违背了对内存数据进行操作的目的?读取操作可能不受日志的影响,但日志似乎会降低您的写入性能.

By "durable" I mean, the server can crash at any time, and as long as the disk remains in tact, no data is lost (see ACID). Seems like that's what journaling mode is for, but if you enable journaling, doesn't that defeat the purpose of operating on in-memory data? Read operations might not be affected by journaling, but it seems like journaling would kill your write performance.

推荐答案

Redis通常部署为耐用"的数据存储(在 ACID 中的D"的意义上),甚至日志.大多数用例故意牺牲一点耐久性来换取速度.

Redis is not usually deployed as a "durable" datastore (in the sense of the "D" in ACID.), even with journaling. Most use cases intentionally sacrifice a little durability in return for speed.

但是,仅附加文件"可以选择将存储模式配置为以持久的方式运行,但会牺牲性能.它必须为每次修改支付 fsync() 费用.要进行配置,请在 .conf 文件中设置以下两个选项:

However, the "append only file" storage mode can optionally be configured to operate in a durable manner, at the cost of performance. It will have to pay for an fsync() on every modification. To configure this, set these two options in your .conf file:

 appendonly yes
 appendfsync always

来自文档:追加的持久性如何只有文件?

查看redis.conf,可以配置Redis 将 fsync() 数据多少次磁盘上.共有三个选项:

Check redis.conf, you can configure how many times Redis will fsync() data on disk. There are three options:

  • Fsync() 每次有新命令时附加到附加日志文件.非常非常慢,非常安全.
  • Fsync() 一次每一秒.足够快,你可以丢失 1 秒的数据,如果有灾难.
  • 从不使用 fsync(),只需将您的操作员手中的数据系统.更快、更不安全的方法.

(请注意,Redis 2.0.0 后随附的配置文件中 appendfsync 的默认值是 everysec,而不是 always.)

(Note that the default for appendfsync in the configuration file shipping with Redis post-2.0.0 is everysec, and not always.)

这篇关于redis 是持久数据存储吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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