LoginSignup
9
10

More than 5 years have passed since last update.

CentOS7 + Rocket.Chatで、ある日ファイルアップロードができなくなった

Posted at

以下の補足:

Rocket.Chat構築でちょっと詰まったところまとめ#tmpufs-の権限が不足している
https://qiita.com/ine1127/items/b3d6c1498b0e520ad30f#tmpufs-%E3%81%AE%E6%A8%A9%E9%99%90%E3%81%8C%E4%B8%8D%E8%B6%B3%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B

現象

以下と同じ現象&同じエラーが出た。
しかし、出たのは運用始めてから半年経ってから。

GridFSの場合、ファイルのアップロードができない
アップロードしたファイルを保存するファイルシステムとしてGridFSを使用した場合に、ファイルをアップロードしてもプログレスバーが0%から進まないという事象です。
どれだけ待っても進まない。
/tmp/ufs の権限が不足している
/var/log/messages を見ると以下のようなエラーログが出力されていることが確認できます。

/var/log/messages
Oct 10 12:15:11 hoge rocketchat: ufs: cannot write chunk of file "hjsjd98n8ZTr9yrS7" (EACCES: permission denied, open '/tmp/ufs/hjsjd98n8ZTr9yrS7')
Oct 10 12:15:11 hoge rocketchat: ufs: cannot delete temp file "/tmp/ufs/hjsjd98n8ZTr9yrS7" (ENOENT: no such file or directory, unlink '/tmp/ufs/hjsjd98n8ZTr9yrS7')
Oct 10 12:15:11 hoge rocketchat: [Error: FileNotFound: no file with id hjsjd98n8ZTr9yrS7 found]

実際の環境を見てみると、/tmp/ufsディレクトリ自体がなくなっている。

応急処置

/tmp/ufsディレクトリを作成、権限を付与すればよい。

原因

CentOS7から導入されたsystemd-tmpfiles-clean.timer が削除したため。
CentOS7の標準では再起動するとディレクトリごと削除する設定になっている。

お前らもさっさとハマって泣くべきCentOS7の落とし穴4つ#落とし穴1-消えるtmp
https://qiita.com/suemoc/items/e29285e8e67263298f35#%E8%90%BD%E3%81%A8%E3%81%97%E7%A9%B41-%E6%B6%88%E3%81%88%E3%82%8Btmp

対策

systemd-tmpfiles-clean.timer に設定を追加する。以下、最後の2行。
ディレクトリが存在しなければ作成する。

/usr/lib/tmpfiles.d/tmp.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp

# For RocketChat File Upload
d /tmp/ufs 0755 mongod mongod -
9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10