su切换用户报错cannot set user id: Resource temporarily unavailable

本文介绍了当Linux系统中进程数达到默认上限1024时出现的问题及解决方案。通过调整宿主机与虚拟机上的进程数限制,成功解决了因进程数量不足而导致的应用不可用问题。
su: cannot set user id: 资源暂时不可用
 
登录root
su - tomcat
报错:
cannot set user id: Resource temporarily unavailable
tomcat账号突然不可用。
根本原因是:linux操作系统默认最大允许进程数是1024. 随着应用的增加,我们的需求已超过了1024
 
曾经改过nproc配置:
cat >> /etc/security/limits.conf << EOF
*           soft   nofile       65535
*           hard   nofile       65535
EOF
据说这个更改只是增加了读文件的句柄数。并未真正增加最大允许进程中。
 
 
我们所使用的是lxc虚拟机,共享宿主机资源。今天某个lxc上的java增加了20个线程(Java里面的一个线程在Linux下会最终映射成操作系统的一个进程),导致宿主机进程数超过1024。
解决方法:在宿主机和每一台虚拟机上修改文件
[root@vm]# vim /etc/security/limits.d/90-nproc.conf
   *          soft    nproc     1024        (改成4096)
 
问题解决。
用ulimit -u -n -a 查看相关信息
 

转载于:https://www.cnblogs.com/wclwcw/p/9993801.html

vnc链接黑屏,Dec 1 16:08:00 node2 journal[3194128]: gsd-wacom: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 journal[3194161]: gsd-media-keys: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 org.gtk.vfs.Daemon[3193754]: A connection to the bus can't be made Dec 1 16:08:00 node2 org.a11y.Bus[3193754]: X connection to :1 broken (explicit kill or server shutdown). Dec 1 16:08:00 node2 gnome-session[3193739]: gnome-session-binary[3193739]: WARNING: Lost name on bus: org.gnome.SessionManager Dec 1 16:08:00 node2 journal[3194162]: gsd-keyboard: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 gnome-session-binary[3193739]: WARNING: Lost name on bus: org.gnome.SessionManager Dec 1 16:08:00 node2 tracker-miner-fs.desktop[3194308]: Received signal:15->'Terminated' Dec 1 16:08:00 node2 tracker-miner-apps.desktop[3194307]: Received signal:15->'Terminated' Dec 1 16:08:00 node2 tracker-miner-apps.desktop[3194307]: OK Dec 1 16:08:00 node2 journal[3194151]: gsd-clipboard: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 tracker-miner-fs.desktop[3194308]: OK Dec 1 16:08:00 node2 journal[3194127]: gsd-xsettings: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 journal[3194146]: gsd-color: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 journal[3194107]: gsd-power: Fatal IO error 11 (Resource temporarily unavailable) on X server :1. Dec 1 16:08:00 node2 cupsd[4302]: REQUEST localhost - - "POST / HTTP/1.1" 200 151 Cancel-Subscription successful-ok Dec 1 16:08:00 node2 cupsd[4302]: REQUEST localhost - - "POST / HTTP/1.1" 200 151 Cancel-Subscription client-error-not-found Dec 1 16:08:00 node2 journal[3194108]: Source ID 3 was not found when attempting to remove it Dec 1 16:08:00 node2 journal[3194308]: Error while sending AddMatch() message: The connection is closed Dec 1 16:08:00 node2 journal[3194308]: Error while sending AddMatch() message: The connection is closed Dec 1 16:08:00 node2 journal[3194308]: Error while sending AddMatch() message: The connection is closed Dec 1 16:08:00 node2 gnome-session[3193739]: Unable to init server: Could not connect: Connection refused Dec 1 16:08:00 node2 journal[3328590]: Cannot open display: Dec 1 16:08:00 node2 org.freedesktop.Tracker1[3193754]: Received signal:15->'Terminated' Dec 1 16:08:00 node2 org.freedesktop.Tracker1[3193754]: OK Dec 1 16:08:01 node2 systemd[1]: Started Session 74848 of user root. Dec 1 16:08:01 node2 systemd[1]: session-74848.scope: Succeeded. Dec 1 16:08:15 node2 su[3328613]: (to msk) root on pts/0 Dec 1 16:09:00 node2 journal[3194194]: Service not used for 60 seconds. Shutting down.. Dec 1 16:09:00 node2 systemd[1]: geoclue.service: Succeeded. Dec 1 16:09:01 node2 systemd[1]: Started Session 74849 of user root. Dec 1 16:09:01 node2 systemd[1]: session-74849.scope: Succeeded. Dec 1 16:10:01 node2 systemd[1]: Started Session 74850 of user root. Dec 1 16:10:01 node2 systemd[1]: Starting system activity accounting tool... Dec 1 16:10:01 node2 systemd[1]: sysstat-collect.service: Succeeded. Dec 1 16:10:01 node2 systemd[1]: Started system activity accounting tool. Dec 1 16:10:01 node2 systemd[1]: session-74850.scope: Succeeded. Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.0' (uid=0 pid=3328955 comm="systemctl --user import-environment DISPLAY XAUTHO") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.3' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.a11y.Bus' requested by ':1.4' (uid=0 pid=3328974 comm="/usr/libexec/gnome-session-check-accelerated ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.a11y.Bus' Dec 1 16:10:16 node2 org.a11y.Bus[3328913]: dbus-daemon[3329017]: Activating service name='org.a11y.atspi.Registry' requested by ':1.0' (uid=0 pid=3328974 comm="/usr/libexec/gnome-session-check-accelerated ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gtk.vfs.Daemon' requested by ':1.6' (uid=0 pid=3328974 comm="/usr/libexec/gnome-session-check-accelerated ") Dec 1 16:10:16 node2 org.a11y.Bus[3328913]: dbus-daemon[3329017]: Successfully activated service 'org.a11y.atspi.Registry' Dec 1 16:10:16 node2 org.a11y.Bus[3328913]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.Registry Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gtk.vfs.Daemon' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.11' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.13' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.15' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.17' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.19' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.20' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 gnome-keyring-pkcs11.desktop[3329062]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-TA7WG3 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.20' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 gnome-keyring-secrets.desktop[3329059]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-TA7WG3 Dec 1 16:10:16 node2 gnome-keyring-ssh.desktop[3329060]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-TA7WG3 Dec 1 16:10:16 node2 gnome-keyring-ssh.desktop[3329060]: SSH_AUTH_SOCK=/root/.cache/keyring-TA7WG3/ssh Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.20' (uid=0 pid=3328903 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:16 node2 org.gnome.Shell.desktop[3329077]: Xlib: extension "DPMS" missing on display ":2". Dec 1 16:10:16 node2 org.gnome.Shell.desktop[3329077]: Xlib: extension "DPMS" missing on display ":2". Dec 1 16:10:16 node2 journal[3329077]: Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly. Dec 1 16:10:16 node2 journal[3329077]: Will monitor session 74711 Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.portal.IBus' requested by ':1.25' (uid=0 pid=3329163 comm="ibus-daemon --xim --panel disable ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.freedesktop.portal.IBus' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.impl.portal.PermissionStore' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.freedesktop.impl.portal.PermissionStore' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gnome.Shell.CalendarServer' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gnome.evolution.dataserver.Sources5' requested by ':1.31' (uid=0 pid=3329192 comm="/usr/libexec/gnome-shell-calendar-server ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gnome.OnlineAccounts' requested by ':1.32' (uid=0 pid=3329198 comm="/usr/libexec/evolution-source-registry ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gnome.evolution.dataserver.Sources5' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gnome.Shell.CalendarServer' Dec 1 16:10:16 node2 dbus-daemon[2203]: [system] Activating via systemd: service name='org.freedesktop.GeoClue2' unit='geoclue.service' requested by ':1.155415' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:16 node2 systemd[1]: Starting Location Lookup Service... Dec 1 16:10:16 node2 journal[3329077]: Telepathy is not available, chat integration will be disabled. Dec 1 16:10:16 node2 journal[3329204]: goa-daemon version 3.28.2 starting Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gnome.Identity' requested by ':1.34' (uid=0 pid=3329204 comm="/usr/libexec/goa-daemon ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gtk.vfs.UDisks2VolumeMonitor' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gnome.OnlineAccounts' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gnome.Identity' Dec 1 16:10:16 node2 journal[3329215]: GoaKerberosIdentityManager: Using polling for change notification for credential cache type 'KCM' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gtk.vfs.UDisks2VolumeMonitor' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gtk.vfs.MTPVolumeMonitor' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gtk.vfs.MTPVolumeMonitor' Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gtk.vfs.GPhoto2VolumeMonitor' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:16 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gtk.vfs.GPhoto2VolumeMonitor' Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gtk.vfs.AfcVolumeMonitor' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:17 node2 org.gtk.vfs.AfcVolumeMonitor[3328913]: Volume monitor alive Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gtk.vfs.AfcVolumeMonitor' Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gtk.vfs.GoaVolumeMonitor' requested by ':1.24' (uid=0 pid=3329077 comm="/usr/bin/gnome-shell ") Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gtk.vfs.GoaVolumeMonitor' Dec 1 16:10:17 node2 pulseaudio.desktop[3329256]: W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified). Dec 1 16:10:17 node2 org.gnome.Shell.desktop[3329077]: Xlib: extension "DPMS" missing on display ":2". Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Activating via systemd: service name='org.bluez' unit='dbus-org.bluez.service' requested by ':1.155424' (uid=0 pid=3329285 comm="/usr/bin/pulseaudio --start ") Dec 1 16:10:17 node2 journal[3329291]: Loading NVML: libnvidia-ml.so: cannot open shared object file: No such file or directory Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.155433' (uid=0 pid=3329252 comm="/usr/libexec/gsd-rfkill ") Dec 1 16:10:17 node2 org.gnome.SettingsDaemon.Keyboard.desktop[3329299]: error: XDG_RUNTIME_DIR not set in the environment. Dec 1 16:10:17 node2 systemd[1]: Starting Hostname Service... Dec 1 16:10:17 node2 org.gnome.SettingsDaemon.Mouse.desktop[3329303]: error: XDG_RUNTIME_DIR not set in the environment. Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gnome.evolution.dataserver.Calendar7' requested by ':1.31' (uid=0 pid=3329192 comm="/usr/libexec/gnome-shell-calendar-server ") Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Activating via systemd: service name='org.freedesktop.locale1' unit='dbus-org.freedesktop.locale1.service' requested by ':1.155437' (uid=0 pid=3329299 comm="/usr/libexec/gsd-keyboard ") Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.systemd1' requested by ':1.44' (uid=0 pid=3329254 comm="/usr/libexec/gsd-sharing ") Dec 1 16:10:17 node2 journal[3329254]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:17 node2 journal[3329254]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:17 node2 journal[3329254]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:17 node2 journal[3329254]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:10:17 node2 systemd[1]: Starting Locale Service... Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Successfully activated service 'org.freedesktop.GeoClue2' Dec 1 16:10:17 node2 systemd[1]: Started Location Lookup Service. Dec 1 16:10:17 node2 vmware-user.desktop[3329355]: vmware-user: could not open /proc/fs/vmblock/dev Dec 1 16:10:17 node2 vmware-user.desktop[3329355]: Error: /usr/bin/vmtoolsd must be run inside a virtual machine on a VMware hypervisor product. Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.freedesktop.Tracker1' requested by ':1.60' (uid=0 pid=3329361 comm="gdbus call -e -d org.freedesktop.DBus -o /org/free") Dec 1 16:10:17 node2 gnome-session-binary[3328903]: Entering running state Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.freedesktop.Tracker1' Dec 1 16:10:17 node2 tracker-store.desktop[3329361]: (uint32 1,) Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gnome.evolution.dataserver.Calendar7' Dec 1 16:10:17 node2 NetworkManager[2206]: <info> [1764576617.1924] agent-manager: agent[1eaebaa131647e84,:1.155415/org.gnome.Shell.NetworkAgent/0]: agent registered Dec 1 16:10:17 node2 journal[3329077]: Error looking up permission: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for geolocation Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='ca.desrt.dconf' requested by ':1.70' (uid=0 pid=3329409 comm="/usr/libexec/evolution-calendar-factory-subprocess") Dec 1 16:10:17 node2 journal[3329353]: enabled plugins: desktop-categories, fwupd, os-release, packagekit, packagekit-local, packagekit-offline, packagekit-proxy, packagekit-refresh, packagekit-upgrade, packagekit-url-to-app, shell-extensions, appstream, desktop-menu-path, flatpak, hardcoded-blacklist, hardcoded-popular, modalias, packagekit-refine, rewrite-resource, odrs, packagekit-history, provenance, systemd-updates, generic-updates, packagekit-refine-repos, provenance-license, icons, key-colors, key-colors-metadata Dec 1 16:10:17 node2 journal[3329353]: disabled plugins: dummy, fedora-langpacks, fedora-pkgdb-collections, repos Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Activating service name='org.gnome.evolution.dataserver.AddressBook9' requested by ':1.70' (uid=0 pid=3329409 comm="/usr/libexec/evolution-calendar-factory-subprocess") Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'ca.desrt.dconf' Dec 1 16:10:17 node2 journal[3329286]: no xrandr-VGA-1 device found: Failed to find output xrandr-VGA-1 Dec 1 16:10:17 node2 dbus-daemon[3328913]: [session uid=0 pid=3328911] Successfully activated service 'org.gnome.evolution.dataserver.AddressBook9' Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Activating via systemd: service name='org.freedesktop.fwupd' unit='fwupd.service' requested by ':1.155445' (uid=0 pid=3329353 comm="/usr/bin/gnome-software --gapplication-service ") Dec 1 16:10:17 node2 systemd[1]: Starting Firmware update daemon... Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Successfully activated service 'org.freedesktop.hostname1' Dec 1 16:10:17 node2 systemd[1]: Started Hostname Service. Dec 1 16:10:17 node2 cupsd[4302]: REQUEST localhost - - "POST / HTTP/1.1" 200 360 Create-Printer-Subscriptions successful-ok Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Successfully activated service 'org.freedesktop.locale1' Dec 1 16:10:17 node2 systemd[1]: Started Locale Service. Dec 1 16:10:17 node2 fwupd[3329449]: 08:10:17:0535 FuDeviceList ignoring device 7d29f2075dcafb4488b40c73f199cf46bb76bddb [optionrom:(null)] existing device ce4c74a5188d5b9cdb1e72ed32dad2d313c1c999 [optionrom:(null)] already exists Dec 1 16:10:17 node2 gnome-shell[3329077]: GNOME Shell started at Mon Dec 01 2025 16:10:17 GMT+0800 (CST) Dec 1 16:10:17 node2 dbus-daemon[2203]: [system] Successfully activated service 'org.freedesktop.fwupd' Dec 1 16:10:17 node2 systemd[1]: Started Firmware update daemon. Dec 1 16:10:17 node2 PackageKit[4929]: uid 0 is trying to obtain org.freedesktop.packagekit.system-sources-refresh auth (only_trusted:0) Dec 1 16:10:17 node2 PackageKit[4929]: uid 0 obtained auth for org.freedesktop.packagekit.system-sources-refresh Dec 1 16:10:21 node2 journal[3329207]: Failed to query location: Error resolving “location.services.mozilla.com”: Name or service not known Dec 1 16:10:37 node2 journal[4929]: LRO_MIRRORLISTURL processing failed: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=extras&infra=stock [Could not resolve host: mirrorlist.centos.org] Dec 1 16:10:42 node2 dbus-daemon[2203]: [system] Failed to activate service 'org.bluez': timed out (service_start_timeout=25000ms) Dec 1 16:10:42 node2 pulseaudio[3329285]: GetManagedObjects() failed: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. Dec 1 16:10:47 node2 systemd[1]: systemd-localed.service: Succeeded. Dec 1 16:10:47 node2 systemd[1]: systemd-hostnamed.service: Succeeded. Dec 1 16:11:01 node2 systemd[1]: Started Session 74851 of user root. Dec 1 16:11:01 node2 systemd[1]: session-74851.scope: Succeeded. Dec 1 16:11:51 node2 journal[4929]: LRO_MIRRORLISTURL processing failed: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=extras&infra=stock [Could not resolve host: mirrorlist.centos.org] Dec 1 16:12:01 node2 systemd[1]: Started Session 74852 of user root. Dec 1 16:12:01 node2 systemd[1]: session-74852.scope: Succeeded. Dec 1 16:13:01 node2 systemd[1]: Started Session 74853 of user root. Dec 1 16:13:01 node2 systemd[1]: session-74853.scope: Succeeded. Dec 1 16:14:01 node2 systemd[1]: Started Session 74854 of user root. Dec 1 16:14:01 node2 systemd[1]: session-74854.scope: Succeeded. Dec 1 16:14:18 node2 journal[4929]: LRO_METALINKURL processing failed: Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=epel-modular-8&arch=x86_64&infra=stock&content=centos [Could not resolve host: mirrors.fedoraproject.org] Dec 1 16:14:30 node2 journal[3329077]: gnome-shell: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 org.gtk.vfs.Daemon[3328913]: A connection to the bus can't be made Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: Lost name on bus: org.gnome.SessionManager Dec 1 16:14:30 node2 org.gnome.Shell.CalendarServer[3328913]: gnome-shell-calendar-server[3329192]: Lost (or failed to acquire) the name org.gnome.Shell.CalendarServer - exiting Dec 1 16:14:30 node2 tracker-miner-apps.desktop[3329359]: Received signal:15->'Terminated' Dec 1 16:14:30 node2 tracker-miner-apps.desktop[3329359]: OK Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: Lost name on bus: org.gnome.SessionManager Dec 1 16:14:30 node2 tracker-miner-fs.desktop[3329360]: Received signal:15->'Terminated' Dec 1 16:14:30 node2 journal[3329360]: Owner of volume monitor org.gtk.vfs.UDisks2VolumeMonitor disconnected from the bus; removing drives/volumes/mounts Dec 1 16:14:30 node2 tracker-miner-fs.desktop[3329360]: OK Dec 1 16:14:30 node2 journal[3329360]: Owner of volume monitor org.gtk.vfs.MTPVolumeMonitor disconnected from the bus; removing drives/volumes/mounts Dec 1 16:14:30 node2 journal[3329360]: Owner of volume monitor org.gtk.vfs.GPhoto2VolumeMonitor disconnected from the bus; removing drives/volumes/mounts Dec 1 16:14:30 node2 journal[3329360]: Owner of volume monitor org.gtk.vfs.AfcVolumeMonitor disconnected from the bus; removing drives/volumes/mounts Dec 1 16:14:30 node2 journal[3329360]: Owner of volume monitor org.gtk.vfs.GoaVolumeMonitor disconnected from the bus; removing drives/volumes/mounts Dec 1 16:14:30 node2 systemd[3326885]: root-.gvfs.mount: Succeeded. Dec 1 16:14:30 node2 systemd[3319485]: root-.gvfs.mount: Succeeded. Dec 1 16:14:30 node2 journal[3329360]: Error while sending AddMatch() message: The connection is closed Dec 1 16:14:30 node2 journal[3329360]: Error while sending AddMatch() message: The connection is closed Dec 1 16:14:30 node2 journal[3329360]: Error while sending AddMatch() message: The connection is closed Dec 1 16:14:30 node2 cupsd[4302]: REQUEST localhost - - "POST / HTTP/1.1" 200 152 Cancel-Subscription successful-ok Dec 1 16:14:30 node2 cupsd[4302]: REQUEST localhost - - "POST / HTTP/1.1" 200 152 Cancel-Subscription client-error-not-found Dec 1 16:14:30 node2 journal[3329251]: Source ID 3 was not found when attempting to remove it Dec 1 16:14:30 node2 journal[3329249]: gsd-power: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 journal[3329268]: gsd-xsettings: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 journal[3329271]: gsd-wacom: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 journal[3329288]: gsd-clipboard: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 journal[3329296]: gsd-media-keys: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 journal[3329299]: gsd-keyboard: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 journal[3329286]: gsd-color: Fatal IO error 11 (Resource temporarily unavailable) on X server :2. Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Clipboard.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Clipboard.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Power.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Power.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Wacom.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Wacom.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Keyboard.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Keyboard.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.MediaKeys.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.MediaKeys.desktop' exited with code 1 Dec 1 16:14:30 node2 org.freedesktop.Tracker1[3328913]: Received signal:15->'Terminated' Dec 1 16:14:30 node2 org.freedesktop.Tracker1[3328913]: OK Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.XSettings.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.XSettings.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session[3328903]: gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Color.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session-binary[3328903]: WARNING: App 'org.gnome.SettingsDaemon.Color.desktop' exited with code 1 Dec 1 16:14:30 node2 gnome-session[3328903]: Unable to init server: Could not connect: Connection refused Dec 1 16:14:30 node2 journal[3329759]: Cannot open display: Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.0' (uid=0 pid=3329882 comm="systemctl --user import-environment DISPLAY XAUTHO") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.3' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.a11y.Bus' requested by ':1.4' (uid=0 pid=3329900 comm="/usr/libexec/gnome-session-check-accelerated ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Successfully activated service 'org.a11y.Bus' Dec 1 16:14:52 node2 org.a11y.Bus[3329840]: dbus-daemon[3329943]: Activating service name='org.a11y.atspi.Registry' requested by ':1.0' (uid=0 pid=3329900 comm="/usr/libexec/gnome-session-check-accelerated ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.gtk.vfs.Daemon' requested by ':1.6' (uid=0 pid=3329900 comm="/usr/libexec/gnome-session-check-accelerated ") Dec 1 16:14:52 node2 org.a11y.Bus[3329840]: dbus-daemon[3329943]: Successfully activated service 'org.a11y.atspi.Registry' Dec 1 16:14:52 node2 org.a11y.Bus[3329840]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.Registry Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Successfully activated service 'org.gtk.vfs.Daemon' Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.11' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.13' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.15' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.17' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.19' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.20' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 gnome-keyring-pkcs11.desktop[3329980]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-HV2SG3 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.20' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 gnome-keyring-secrets.desktop[3329977]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-HV2SG3 Dec 1 16:14:52 node2 gnome-keyring-ssh.desktop[3329979]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-HV2SG3 Dec 1 16:14:52 node2 gnome-keyring-ssh.desktop[3329979]: SSH_AUTH_SOCK=/root/.cache/keyring-HV2SG3/ssh Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.systemd1' requested by ':1.20' (uid=0 pid=3329830 comm="/usr/libexec/gnome-session-binary ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 Dec 1 16:14:52 node2 org.gnome.Shell.desktop[3329995]: Xlib: extension "DPMS" missing on display ":2". Dec 1 16:14:52 node2 org.gnome.Shell.desktop[3329995]: Xlib: extension "DPMS" missing on display ":2". Dec 1 16:14:52 node2 journal[3329995]: Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly. Dec 1 16:14:52 node2 journal[3329995]: Will monitor session 74711 Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.portal.IBus' requested by ':1.25' (uid=0 pid=3330081 comm="ibus-daemon --xim --panel disable ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.freedesktop.impl.portal.PermissionStore' requested by ':1.24' (uid=0 pid=3329995 comm="/usr/bin/gnome-shell ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Successfully activated service 'org.freedesktop.portal.IBus' Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Successfully activated service 'org.freedesktop.impl.portal.PermissionStore' Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.gnome.Shell.CalendarServer' requested by ':1.24' (uid=0 pid=3329995 comm="/usr/bin/gnome-shell ") Dec 1 16:14:52 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.gnome.evolution.dataserver.Sources5' requested by ':1.31' (uid=0 pid=3330109 comm="/usr/libexec/gnome-shell-calendar-server ") Dec 1 16:14:53 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.gnome.OnlineAccounts' requested by ':1.32' (uid=0 pid=3330114 comm="/usr/libexec/evolution-source-registry ") Dec 1 16:14:53 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Successfully activated service 'org.gnome.evolution.dataserver.Sources5' Dec 1 16:14:53 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Successfully activated service 'org.gnome.Shell.CalendarServer' Dec 1 16:14:53 node2 journal[3329995]: Telepathy is not available, chat integration will be disabled. Dec 1 16:14:53 node2 dbus-daemon[3329840]: [session uid=0 pid=3329838] Activating service name='org.gtk.vfs.UDisks2VolumeMonitor' requested by ':1.24' (uid=0 pid=3329995 comm="/usr/bin/gnome-shell ")
最新发布
12-02
<think>我们正在处理一个Android编译错误:FAILED: posix_spawn: Resource temporarily unavailable 这个错误通常与系统资源限制有关,特别是在并行编译(如使用make -j或ninja)时,进程数或文件描述符数可能达到系统限制。 根据引用[4]和[5],这类错误往往是由于用户进程数达到上限(maxuproc)或文件描述符限制(ulimit -n)引起的。 因此,我们可以从以下几个方面进行排查和解决: 1. 检查并增加用户进程数限制(max user processes) 在Linux系统中,可以通过`ulimit -u`查看当前用户的进程数限制。编译时可能会启动大量子进程,如果限制太低,就会导致资源不可用。 临时增加:`ulimit -u 2048`(需要先退出编译环境,然后重新进入) 永久增加:修改/etc/security/limits.conf文件,添加: * soft nproc 2048 * hard nproc 4096 2. 检查并增加文件描述符限制(open files) 同样使用`ulimit -n`查看当前限制。编译过程中会打开大量文件,如果不够用也会报错。 临时增加:`ulimit -n 4096` 永久增加:在/etc/security/limits.conf中添加: * soft nofile 4096 * hard nofile 8192 3. 检查系统级别的进程限制(maxuproc) 对于整个系统的最大进程数,可以通过`sysctl kernel.pid_max`查看,如果系统总进程数接近上限,也可能影响。 修改:`sudo sysctl -w kernel.pid_max=65535` 4. 调整并行编译的进程数 如果上述方法不能解决,可以尝试减少并行编译的进程数,例如将make的-j参数调小,或者使用ninja时指定-j。 例如:`make -j4` 或者 `ninja -j4` 5. 检查内存和交换空间 编译过程中内存不足也可能导致资源不可用。确保有足够的物理内存和交换空间(swap)。可以通过`free -h`查看。 如果内存不足,可以尝试增加交换空间,或者减少并行编译的进程数。 6. 检查Docker环境(如果使用Docker编译) 如果是在Docker容器中编译,根据引用[2],Docker默认的TasksMax(任务数)限制可能会导致问题。可以设置TasksMax为无限: `sudo systemctl set-property docker.service TasksMax=infinity` 然后重新加载并重启docker。 7. 检查inotify限制(文件监控数) 编译过程中可能会用到inotify,可以通过以下命令查看当前限制: `cat /proc/sys/fs/inotify/max_user_watches` 如果值较小(如8192),可以增加: `echo 65536 | sudo tee /proc/sys/fs/inotify/max_user_watches` 8. 检查是否有僵尸进程或未关闭的文件 使用`ps aux`查看是否有大量僵尸进程,或者使用`lsof`查看是否有大量打开的文件未关闭。 9. 重启编译环境 有时候,简单地重启一下系统或者重新进入编译环境,可以释放一些资源。 由于Android编译是一个资源密集型任务,建议在开始编译前,先检查并调整这些限制。 注意:修改系统限制需要管理员权限,请谨慎操作。 下面给出一个具体的解决步骤示例: 步骤1:修改进程数和文件描述符限制 编辑/etc/security/limits.conf,添加: * soft nproc 20480 * hard nproc 40960 * soft nofile 8192 * hard nofile 65536 步骤2:修改系统进程数上限 编辑/etc/sysctl.conf,添加: kernel.pid_max = 65535 然后运行`sudo sysctl -p`生效。 步骤3:增加inotify限制 编辑/etc/sysctl.conf,添加: fs.inotify.max_user_watches = 65536 同样运行`sudo sysctl -p`生效。 步骤4:如果使用Docker,修改Docker服务配置(如引用[2]所述) sudo systemctl set-property docker.service TasksMax=infinity sudo systemctl daemon-reload sudo systemctl restart docker 步骤5:重新登录用户,使limits.conf生效(或者重启系统) 步骤6:在编译时,适当控制并行任务数,例如: make -j8 # 根据你的CPU核心数合理设置,一般不超过CPU核心数的2倍 如果问题仍然存在,可以尝试进一步增加这些限制,或者检查系统日志(/var/log/syslog)获取更多错误信息。 希望这些方法能帮助你解决编译错误。</think>### 解决 Android 编译错误:`FAILED: posix_spawn: Resource temporarily unavailable` 该错误通常由 **系统资源限制** 引起,尤其是在并行编译(如 `make -j`)时进程数或文件描述符超过限制。以下是系统级解决方案: --- #### **1. 增加用户进程数限制** ```bash # 查看当前限制 ulimit -u # 临时增加(仅当前会话有效) ulimit -u 8192 # 永久修改(需 root) echo "* soft nproc 16384" | sudo tee -a /etc/security/limits.conf echo "* hard nproc 32768" | sudo tee -a /etc/security/limits.conf ``` **说明**:Android 编译会启动大量子进程,默认限制(通常 1024)易被耗尽[^4]。 --- #### **2. 提升系统级进程上限** ```bash # 检查系统最大进程数 cat /proc/sys/kernel/pid_max # 永久修改(需 root) sudo sysctl -w kernel.pid_max=65535 echo "kernel.pid_max=65535" | sudo tee -a /etc/sysctl.conf ``` **原理**:系统总进程数上限需高于所有用户进程之和[^4]。 --- #### **3. 调整文件描述符限制** ```bash # 查看当前限制 ulimit -n # 永久修改(需 root) echo "* soft nofile 65536" | sudo tee -a /etc/security/limits.conf echo "* hard nofile 131072" | sudo tee -a /etc/security/limits.conf ``` **原因**:编译过程中频繁读写文件,需更多文件句柄[^5]。 --- #### **4. 减少并行编译任务数** 在编译命令中显式降低并行度: ```bash # 将 -j 后的数值改为 CPU 核心数的 1.5 倍(如 8 核改为 12) make -j12 # 替代 make -j$(nproc) ``` **注意**:过度并行(如 `make -j` 无参数)易触发资源竞争[^1]。 --- #### **5. 检查内存与交换空间** ```bash # 确保交换空间(Swap)足够(建议 ≥ 物理内存的 50%) free -h # 临时增加交换文件(示例增加 8GB) sudo fallocate -l 8G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile ``` --- #### **6. 系统级深度排查** - **检查僵尸进程**:`ps aux | grep 'Z'` - **监控资源使用**: ```bash top -c # 按 CPU 排序 htop # 交互式资源监控 vmstat 2 # 每 2 秒输出系统状态 ``` --- #### **若在 Docker 中编译** 根据引用[^2]调整 Docker 服务配置: ```bash # 解除 Docker 任务数限制 sudo systemctl set-property docker.service TasksMax=infinity sudo systemctl daemon-reload sudo systemctl restart docker ``` --- ### 验证修复 1. 重新登录终端使配置生效 2. 执行编译前运行: ```bash ulimit -a # 确认 nproc/nofile 已提升 ``` 3. 重新编译观察错误是否消失 > **关键提示**:修改系统级限制需重启或重新登录生效。若问题持续,检查内核日志:`dmesg | grep -i "resource"`[^1][^4]。 --- ### 相关问题 1. 如何诊断 Linux 中 `Resource temporarily unavailable` 的具体原因? 2. Android 编译优化:如何平衡并行任务数与系统资源? 3. 除资源限制外,还有哪些常见原因会导致 `posix_spawn` 失败? 4. 如何在 Docker 容器中动态调整资源限制? [^1]: Linux 编程中 EAGAIN 错误的常见场景分析 [^2]: Docker 容器资源限制的调整方法 [^3]: POSIX 优先级限制与系统实现差异 [^4]: 进程数超限导致 fork 失败的解决方案 [^5]: Linux 资源限制调整的综合指南
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值