redis是耐用的数据存储区吗? [英] Is redis a durable datastore?

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

问题描述

耐用我的意思是,服务器可以在任何时候崩溃,只要磁盘保持在生产,没有数据丢失(参见 ACID )。看起来像日志模式是什么,但如果您启用日志记录,这不会破坏在内存中的数据操作的目的?读取操作可能不受日志记录的影响,但看起来日志记录会影响您的写入性能。

解决方案

Redis不是通常部署为持久数据存储(在ACID中的D的意义上),甚至使用日志记录。大多数使用情况有意牺牲一点耐久性来换取速度。



但是,仅附加文件存储模式可以选择配置为以持久方式操作,性能的成本。每次修改都必须支付 fsync()。要配置它,请在.conf文件中设置以下两个选项:

  appendonly yes 
appendfsync always

从文件:


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




  • Fsync()每次新命令是
    附加到追加日志文件。非常
    非常缓慢,非常安全。

  • Fsync()一次
    每秒。足够快,如果有
    的灾难,你可以
    丢失1秒的数据。

  • 从不fsync(),只需将
    数据放在操作
    系统的手中。更快和更安全的方法。


(请注意,配置中的appendfsync文件传输与Redis post-2.0.0是 everysec ,而不是总是。) >

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 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.

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

From the docs: How durable is the append only file?

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

  • Fsync() every time a new command is appended to the append log file. Very very slow, very safe.
  • Fsync() one time every second. Fast enough, and you can lose 1 second of data if there is a disaster.
  • Never fsync(), just put your data in the hands of the Operating System. The faster and unsafer method.

(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天全站免登陆