Jira サーバーの Too many open files エラー
症状
Jira アプリケーションの複数の領域で機能が全体的に悪化する。
atlassian-jira.log
ログに次のエラーが表示される。
java.io.IOException: java.io.IOException: Too many open files
現在のオープン ファイル ハンドラの上限を確認するには、次のコマンドを実行します。
ulimit -aS | grep open
その後、次のような行を確認します。
open files (-n) 2560
診断
オプション 1
In order to identify the open files that are completely unlinked, the lsof +L1 command can be used, for example:
lsof +L1 > open_files.txt
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
java 2565 dos 534r REG 8,17 11219 0 57809485 /home/dos/deploy/applinks-jira/temp/jar_cache3983695525155383469.tmp (deleted)
java 2565 dos 536r REG 8,17 29732 0 57809486 /home/dos/deploy/applinks-jira/temp/jar_cache5041452221772032513.tmp (deleted)
java 2565 dos 537r REG 8,17 197860 0 57809487 /home/dos/deploy/applinks-jira/temp/jar_cache6047396568660382237.tmp (deleted)
オプション 2
Linux kernel exports information about all of the running processes on a Linux system via the proc pseudo filesystem, usually mounted at /proc.
In the /proc pseudo filesystem, we can find the open file descriptors under /proc/<pid>/fd/ where <pid> is the JAVA PID.
To count the open files opened by the JAVA process, we can use the command below to get a count:
ls -U /proc/\{JAVA-PID}/fd | wc -l
or to show files:
ls -lU /proc/\{JAVA-PID}/fd | tail -n+2
上記のソリューションが動作しない場合はアトラシアン サポートで詳細な調査を行うことができます。調整を依頼するには次のものをアトラシアン サポートに提供してください。
- The output of Option 1 and/or Option 2
The commands must be executed by the JIRA user, or a user who can view the files. For example if JIRA is running as
root
(which is not at all recommended), executing this command asjira
will not show the open files. - 例外が返されたタイミングで取得されたヒープ ダンプ。詳細については「ヒープ ダンプの生成」をご確認ください。
- Jira アプリケーションのサポート zip
原因
UNIX システムでは、任意の 1 つのプロセスで同時にオープン可能なファイルの数に制限があります。ほとんどのディストリビューションのデフォルトは 1024 ファイルで、Jira アプリケーションの構成によってはこの数字は小さすぎます。この上限に達すると、上記の例外が生成され、Jira アプリケーションは現在の操作の完了に必要なファイルを開けないために動作に失敗します。
この挙動を発生させることが確認されているアプリケーション バグがあります。
- - JRA-29587課題詳細を取得中... ステータス
- - JRA-35726課題詳細を取得中... ステータス
- - JRA-39114Getting issue details... STATUS (Jira 6.2 以降に影響)
- JRASERVER-68653 - 課題詳細を取得中... ステータス
Jira アプリケーションでの処理を改善する、次の改善リクエストがあります。
ソリューション
These changes will only work on installation that uses built in initd script for starting Jira. For installations that uses custom build service for systemd (latest versions of linux OS-es) changes will need to be applied directly in that systemd service configuration (ie, update the /usr/lib/systemd/system/jira.service file, followed by systemctl daemon-reload) in a form of:
[Service]
LimitNOFILE=20000
ほとんどの場合、Jira の setnenv.sh で ulimit を設定すると効果があります。
$JIRA_HOME/caches/indexes
フォルダが NFS でマウントされている場合はローカル マウントに移動します (Jira インスタンスと同じサーバー上のストレージ)。Jira アプリケーションのサポート対象プラットフォームにあるように NFS はサポートされておらず、NFS が利用されていると、この問題が非常に頻繁に発生します。- Jira アプリケーションを停止します。
$JIRA_INSTALL/bin/setenv.sh
を編集し、次の内容をファイル上部に含めます。ulimit -n 16384
これにより、Jira アプリケーションが開始されるたびにこの値が設定されます。ただし、Jira アプリケーションのアップグレードを行う際は手動の移行が必要です。
- Jira アプリケーションを開始します。
/proc/<pid>/limits
を実行することで変更を確認できます。ここで <pid> はアプリケーションのプロセス ID です。
- JRA-29587Getting issue details... STATUS のバグがある Jira アプリケーション バージョンをご利用の場合は最新バージョンにアップグレードします。NFS をご利用の場合はローカル ストレージ マウントに移行します。
Notice that some operating systems may require additional configuration for setting the limits.
For most Linux systems you would modify the limits.conf file:
- To modify the limits.conf file, use the following command:
sudo vim /etc/security/limits.conf Add/Edit the following for the user that runs Jira application. If you have used the bundled installer, this will be
jira
.limits.conf#<domain> <type> <item> <value> # #* soft core 0 #root hard core 100000 #* hard rss 10000 #@student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #ftp - chroot /ftp #@student - maxlogins 4 jira soft nofile 16384 jira hard nofile 32768
common-session ファイルを次のように変更します。
sudo vim /etc/pam.d/common-session
common-session
is a file only available in debian/ubuntu.次の行を追加します。
common-session# The following changes were made from the JIRA KB (https://confluence.atlassian.com/display/JIRAKB/Loss+of+Functionality+due+to+Too+Many+Open+Files+Error): session required pam_limits.so
In some circumstances it is necessary to check and configure the changes globally, this is done in 2 different places, it is advised to check all of this for what is in effect on your system and configure accordingly:
- The first place to check is the systctl.conf file.
- Modify the systctl.conf file with the following command:
sudo vim /etc/sysctl.conf Add the following to the bottom of the file or modify the existing value if present:
sysctl.conffs.file-max=16384
Users will need to logout and login again for the changes to take effect. If you want to apply the limit immediately, you can use the following command:
-
sysctl -p
- Modify the systctl.conf file with the following command:
- The other place to configure this is within the
sysctl.d
directory, the filename can be anything you as long as it follows with ".conf" e.g. "30-jira.conf", the number here helps to give an order of precedence see the previous link for more info.- To create/edit the file use the following:
sudo vim /etc/sysctl.d/30-jira.conf
Add the following to the bottom of the file or modify the existing value if present:
30-jira.conffs.file-max=16384
N.B., for RHEL/CentOS/Fedora/Scientific Linux, you'll need to modify the login file with the following:
sudo vim /etc/pam.d/login
Add the following line to the bottom of the file:
ログイン# The following changes were made from the JIRA KB (https://confluence.atlassian.com/display/JIRAKB/Loss+of+Functionality+due+to+Too+Many+Open+Files+Error): session required pam_limits.so
- See this external blog post for a more detailed write-up on configuring the open file limits in Linux: Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)
N.B. For any other operating system (please see your operating system's manual for details).
Lastly, restart the JIRA server application to take effect.
非常に大規模なインスタンスの場合、Jira アプリケーションのスケールについては当社のパートナーにご相談いただくことをおすすめします。Jira のクラスタリングやロード バランサについての記事をご確認ください。