LXC:19番目のコンテナの後にsystemdが失敗する

LXC:19番目のコンテナの後にsystemdが失敗する

私はArchlinuxでLXCを実行しています。

私はそれぞれsystemdに基づいているArch、Fedora、Centos、Debian、およびUbuntu LXCコンテナの組み合わせを持っています。

19を超えるLXCコンテナを開こうとすると、20番目のコンテナが起動しますが、内部的にsystemdは実行されません。 (、ps auxおよびのみ表示)bashinitps

poweroffLXCコンテナをたくさん実行すると、centosコンテナは時々「開いたファイルが多すぎます」と報告するので、これが開かれたファイルの数に関連している可能性があると思います。しかし、ファイルの制限を増やしました。このリンクで述べたように、再起動して変更を確認しましたが、問題は解決しません。

原因は何ですか?

ベストアンサー1

これは、権限のある (ルートなど) コンテナーではなく、権限のない (たとえば、ユーザーの名前空間を使用する) コンテナーで問題が発生した場合、コンテナーを実行する同じユーザーの inotify インターフェースの使用が制限されているためです。明らかにsystemdはinotifyに依存しています。 Debian バスター LXC パッケージには、sysctl を軽減するfs.inotify.max_user_instances設定が含まれています。/etc/sysctl.d/30-lxc-inotify.conf:

# Defines the maximum number of inotify listeners.
# By default, this value is 128, which is quickly exhausted when using
# systemd-based LXC containers (15 containers are enough).
# When the limit is reached, systemd becomes mostly unusable, throwing
# "Too many open files" all around (both on the host and in containers).
# See https://kdecherf.com/blog/2015/09/12/systemd-and-the-fd-exhaustion/
# Increase the user inotify instance limit to allow for about
# 100 containers to run before the limit is hit again
fs.inotify.max_user_instances = 1024

これこの設定に関するドキュメント言う:

/proc/sys/fs/inotify/max_user_instances
これは、実際のユーザーIDごとに作成できるinotifyインスタンスの数の上限を指定します。

LXCのインストールにこれらの設定が含まれていない場合は、ホストシステムで実行されていることを確認できます。

sysctl -w fs.inotify.max_user_instances=1024

問題を解決します。

おすすめ記事