AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 123957
Accepted
Jeremy Friesner
Jeremy Friesner
Asked: 2010-03-19 10:20:49 +0800 CST2010-03-19 10:20:49 +0800 CST 2010-03-19 10:20:49 +0800 CST

“强化”嵌入式 ext4 文件服务器以防止意外断电的最佳方法?

  • 772

首先,介绍一点背景知识:我的公司生产一种音频流设备,它是一种无头、机架安装的 Linux 机器,带有一个固态 e-SATA 驱动器。该驱动器使用 ext4 格式化。用户可以使用 Samba/CIFS 连接到系统以上传新的音频文件或访问现有的文件。还有用于通过网络流式传输音频的自定义软件。

这一切都很好。唯一的问题是用户是音频人员,而不是计算机人员,并且将系统视为“黑匣子”,而不是计算机。这意味着在一天结束时,他们不会 ssh 进入盒子并输入“/sbin/shutdown -h”;他们只是要切断机架的电源并离开,并期望第二天仍能正常工作。

由于 ext4 有日志、日志校验和等,所以这主要是有效的。唯一不起作用的情况是有人通过 Samba 上传新文件,然后在上传的数据完全刷新到磁盘之前切断系统电源。在这种情况下,他们第二天来,发现他们的新文件被截断或完全丢失,并且很不高兴。

我的问题是,避免这个问题的最佳方法是什么?有没有办法让 smbd 在每次上传结束时调用“同步”?(上传性能并不那么重要,因为它们只是偶尔发生)。或者有没有办法告诉 ext4 在对文件进行任何更改后的几秒钟内自动刷新?(再次,为了安全,可以牺牲性能)我应该设置特定的写入顺序模式,激活屏障等吗?

ext4 data-protection
  • 3 3 个回答
  • 1651 Views

3 个回答

  • Voted
  1. The Unix Janitor
    2010-03-19T10:40:05+08:002010-03-19T10:40:05+08:00

    对,我一直在处理同样的问题。如果您在系统中禁用任何类型的写入缓存,任何数据都将尽快写入磁盘。

    您将失去性能,但您将获得更好的数据完整性。

    磁盘上的数据与操作系统认为的磁盘上的数据(但它实际上缓存在内存中)之间的差异会大大降低。

    如果您不能使用 UPS 作为解决方案,或者某些硬件解决方案可以在交流电源断电时优雅地关闭机器,那么您将不得不使用这样的技巧。

    使用更简单的文件系统来存储媒体并从 ramdisk 引导操作系统可能是一个想法。从而避免损坏机器的引导/根分区的机会。

    所以回顾一下,

    使用同步挂载文件系统,您将失去性能,但不会缓存所有写入。

    关闭硬件磁盘写入缓存,您将再次失去性能。

    你应该对这篇文章感兴趣

    http://sr5tech.com/write_back_cache_experiments.htm

    • 4
  2. Best Answer
    Warner
    2010-03-19T10:29:41+08:002010-03-19T10:29:41+08:00

    使用 fstab中指定的挂载文件系统sync可能会有所帮助。我怀疑有人会有更适合您的特定应用程序的建议。

    我开始对与闪存一起使用的文件系统进行初步研究,因为我想将家庭影院 PC 定制为设备。您可能会找到更适合您设备的不同存储解决方案。不幸的是,我还没有找到我喜欢的东西,所以我没有详细的推荐。

    编辑 1

    根据 smb.conf(5) 手册页,它支持在 SAMBA 中立即同步:

       strict sync (S)
              Many Windows applications (including the Windows 98
              explorer  shell)  seem  to  confuse flushing buffer
              contents to disk with doing a sync to  disk.  Under
              UNIX,  a  sync  call  forces the process to be sus-
              pended until the kernel has ensured that  all  out-
              standing  data  in  kernel  disk  buffers  has been
              safely stored onto stable  storage.  This  is  very
              slow  and  should only be done rarely. Setting this
              parameter to no (the default)  means  that  smbd(8)
              ignores  the  Windows  applications  requests for a
              sync call. There is only a  possibility  of  losing
              data  if  the operating system itself that Samba is
              running on crashes, so there is  little  danger  in
              this  default setting. In addition, this fixes many
              performance problems that people have reported with
              the new Windows98 explorer shell file copies.
    
              Default: strict sync = no
    
       sync always (S)
              This  is  a boolean parameter that controls whether
              writes will always be  written  to  stable  storage
              before  the  write call returns. If this is no then
              the server will be guided by the  client's  request
              in  each write call (clients can set a bit indicat-
              ing that a particular write should be synchronous).
              If this is yes then every write will be followed by
              a fsync()  call to ensure the data  is  written  to
              disk.  Note  that the strict sync parameter must be
              set to yes in order for this parameter to have  any
              affect.
    
              Default: sync always = no
    
    • 3
  3. BillN
    2010-03-19T10:48:00+08:002010-03-19T10:48:00+08:00

    既然您提到您的公司制造了这些,我建议您从硬件角度看。我见过在驱动器控制器上有备用电池的服务器,以允许缓存的数据在断电时仍然存在。如果您的工程师内置了一个小电池以保持系统运行足够长的时间以干净地关机怎么办?它不需要是一个大的、独立的 UPS,它可以是内部的,并设置为一旦失去 A/C 电源就关闭系统。它可能会增加几美元的成本,但它也可能是一个营销点。

    • 3

相关问题

  • ext4 准备好用于生产了吗?

  • 仅连接到 Linux 的外部驱动器的文件系统

  • 慢速 ext4 fsck

  • ext3、ext4、ReiserFS 之间有什么区别?

  • 关于 ext4 的 FUD 是否合理?或者在某些生产系统中使用是否安全?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve