ディレクトリ
1、問題
新年の後、一部の事業者は、スタッフの反応舞台裏操作はエラー内容を見つけ、写真をアップロードして、ログを表示することができないと述べました/tmp/tomcat* 目录不存在
。
環境:
- 春ブーツ1.5.15
Centos7.6(aliyun)
2、問題は解決します
- なぜこれを使いますか
/tmp/tomcat*
? - その
/tmp/tomcat*
ディレクトリがなぜ存在しないのですか?
2.1なぜ私たちはこれを使用する必要がありますか/tmp/tomcat*
?
デフォルトでは、ビルトインのTomcatの春ブーツは、う/tmp
二つのディレクトリを作成/tmp/tomcat*
し、アップロードファイルを、このディレクトリは、コンパイル済みのJSPを格納するために使用されます。
2.2、/tmp/tomcat*
ディレクトリがなぜ存在しないのですか?
クリアしているLinuxによる機構がないので。
このメカニズムはどのような作品です:
まず、我々はサービスから持ってsystemd-tmpfiles-clean
開始します。
[root@djx ~]# systemctl status systemd-tmpfiles-clean
● systemd-tmpfiles-clean.service - Cleanup of Temporary Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.service; static; vendor preset: disabled)
Active: inactive (dead) since Tue 2020-02-25 09:10:36 CST; 12h ago
Docs: man:tmpfiles.d(5)
man:systemd-tmpfiles(8)
Process: 21819 ExecStart=/usr/bin/systemd-tmpfiles --clean (code=exited, status=0/SUCCESS)
Main PID: 21819 (code=exited, status=0/SUCCESS)
Feb 25 09:10:36 djx systemd[1]: Starting Cleanup of Temporary Directories...
Feb 25 09:10:36 djx systemd[1]: Started Cleanup of Temporary Directories.
今日は、このサービスを参照することができ、午前9時実行一度、我々はサービスが実行コマンドに対応するかを確認し続けますか?
cat /usr/lib/systemd/system/systemd-tmpfiles-clean.service
# 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.
[Unit]
Description=Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target time-sync.target
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemd-tmpfiles --clean
IOSchedulingClass=idle
のは、この順序が実行されていることを覚えてみましょう/usr/bin/systemd-tmpfiles --clean
、我々はケアの下に来る、タイマーに関連するサービスを/usr/lib/systemd/system/systemd-tmpfiles-clean.timer
cat /usr/lib/systemd/system/systemd-tmpfiles-clean.timer
# 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.
[Unit]
Description=Daily Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
これは知っている启动后的15分钟或者距离上一次执行一天
私たちのコマンドで実行されます/usr/bin/systemd-tmpfiles --clean
。
そして、上記のコマンドの特定と何をしましたか?私たちはman systemd-tmpfiles
中にいくつかのものを見つけました。
DESCRIPTION
systemd-tmpfiles creates, deletes, and cleans up volatile and temporary files and directories, based on the configuration file format and location
specified in tmpfiles.d(5).
If invoked with no arguments, it applies all directives from all configuration files. If one or more filenames are passed on the command line, only
the directives in these files are applied. If only the basename of a configuration file is specified, all configuration directories as specified in
tmpfiles.d(5) are searched for a matching file.
上記の説明から、私は2つのメッセージを得ました:
- systemdに-TMPFILESを作成し、一時ディレクトリとファイルをクリーンアップするために使用されます。
- systemdに-TMPFILESがでtmpfiles.dから設定ファイルを取得します。
もちろん、我々はman systemd-tmpfiles
また、パラメータコマンドのいくつかを理解することができます。
私たちは、その後、参照tmpfiles.d
、我々がいることman tmpfiles.d
で見ることができますtmpfiles.d
設定は一時的なファイルやディレクトリをきれいにするために使用される役割。また、構成ストアでそれを見ることができます
/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf
ここでは、ノートを関連の設定ファイルを見ることができます。
次に、我々はクリーンアップに関連するかどうかを確認するために上記の3つのディレクトリ、見た目に行った/tmp
もの。
最後に、/usr/lib/tmpfiles.d/tmp.conf
そこに発見され、
cat /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
私たちは、これらの構成の2を見ることができます
v /tmp 1777 root root 10d # 就是当 /tmp 目录不存在的时间进行创建(权限为777,用户和用户组为root),并清理/tmp下超过10天的文件。
x /tmp/systemd-private-%b-* # 忽略清理的目录
X /tmp/systemd-private-%b-*/tmp # 这个只忽略目录,但不忽略该目录下面的内容
クリーンアップすることを意味/tmp
10日以上は、ファイルディレクトリを変更しませんでしたが、きれいにしない/tmp/systemd-private-%b-*
と/tmp/systemd-private-%b-*/tmp
。
集計システムは自動的に10日間/のtmpディレクトリをクリーンアップしますが、ファイルやディレクトリを変更しませんでした
10日の場合は新年当社のTomcat生成したディレクトリ中に変化しない、それも削除されます。
第三に、ソリューション
設定を変更Springboot、いない/tmp
ディレクトリを作成します
設定パラメータ:server.tomcat.basedir
下記のメカニズムのクリーンアップ/ tmpファイルを変更します。
では/usr/lib/tmpfiles.d/tmp.conf
、次の増加x /tmp/tomcat*
四、春ブーツ公式の回答
公式関連する問題:
- https://github.com/spring-projects/spring-boot/issues/5009
- https://github.com/spring-projects/spring-boot/issues/9616
https://github.com/spring-projects/spring-boot/issues/9616で、
我々はできる底に
You can see the list of releases that contain the fix in the commit that closed this issue. In the 2.1.x line it was fixed in 2.1.4.
参照してください。2.1.4バージョンでは、この問題を解決しました。シリーズのバージョンでは、我々は、また、1.5.20で修正を見ることができますGitHubのレコードをコミット対応します
参考ます。https://www.cnblogs.com/samtech/p/9490166.html