无法启动 VNC 服务器:超出配置的资源限制

无法启动 VNC 服务器:超出配置的资源限制

直到最近一次断电之前,VNC 服务一直运行良好。

当我尝试奔跑

systemctl start vncserver@:1.service

它给出了一条消息

Job for vncserver@:1.service failed because a configured resource limit was exceeded. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.

当我跑步的时候

systemctl status vncserver@:1.service

它给出以下输出

● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2018-08-06 11:48:03 +03; 50s ago
  Process: 1238 ExecStart=/usr/sbin/runuser -l abdullah -c /usr/bin/vncserver %i -geometry 1920x1080 (code=exited, status=255)
  Process: 1224 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

Aug 06 11:47:56 RESysLab-Server_Machine systemd[1]: Starting Remote desktop s...
Aug 06 11:48:03 RESysLab-Server_Machine systemd[1]: vncserver@:1.service: con...
Aug 06 11:48:03 RESysLab-Server_Machine systemd[1]: Failed to start Remote de...
Aug 06 11:48:03 RESysLab-Server_Machine systemd[1]: Unit vncserver@:1.service...
Aug 06 11:48:03 RESysLab-Server_Machine systemd[1]: vncserver@:1.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

日志-xe

包括以下消息:

Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: pam_unix(runuser-l:session): session opened for user abdullah by (uid=0)
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Warning: RESysLab-Server_Machine:1 is taken because of /tmp/.X11-unix/X1
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Remove this file if there is no X server RESysLab-Server_Machine:1
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: A VNC server is already running as :1
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Warning: RESysLab-Server_Machine:1 is taken because of /tmp/.X11-unix/X1
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Remove this file if there is no X server RESysLab-Server_Machine:1
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Warning: RESysLab-Server_Machine:2 is taken because of /tmp/.X11-unix/X2
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Remove this file if there is no X server RESysLab-Server_Machine:2
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Warning: RESysLab-Server_Machine:3 is taken because of /tmp/.X11-unix/X3
Aug 06 11:58:32 RESysLab-Server_Machine runuser[4805]: Remove this file if there is no X server RESysLab-Server_Machine:3
Aug 06 11:58:35 RESysLab-Server_Machine runuser[4805]: New 'RESysLab-Server_Machine:6 (abdullah)' desktop is RESysLab-Server_Machine:6
Aug 06 11:58:35 RESysLab-Server_Machine runuser[4805]: Starting applications specified in /home/abdullah/.vnc/xstartup
Aug 06 11:58:35 RESysLab-Server_Machine runuser[4805]: Log file is /home/abdullah/.vnc/RESysLab-Server_Machine:6.log
Aug 06 11:58:35 RESysLab-Server_Machine runuser[4805]: pam_unix(runuser-l:session): session closed for user abdullah
Aug 06 11:58:35 RESysLab-Server_Machine systemd[1]: PID file /home/abdullah/.vnc/RESysLab-Server_Machine:1.pid not readable (yet?) after start.
Aug 06 11:58:35 RESysLab-Server_Machine systemd[1]: Failed to start Remote desktop service (VNC).

我应该怎么做才能解决这个问题?

答案1

我找到了解决方案:删除文件X1通过rm -f /tmp/.X11-unix/X1并重新启动 VNC 服务器即可。

答案2

为了自动删除剩余的套接字文件,如接受的答案中所述,我最终得到了这个文件:/etc/systemd/system/[email protected]

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking

# Clean any existing files in /tmp/.X11-unix environment
Environment="display_temp=%i"
ExecStartPre=-/bin/sh -c "/usr/bin/vncserver -kill %i > /dev/null 2>&1"
ExecStartPre=-/bin/sh -c "/bin/rm -f /tmp/.X11-unix/X$${display_temp:1} /tmp/.X$${display_temp:1}-lock"
ExecStart=/usr/sbin/runuser -l usr1cv8 -c "/usr/bin/vncserver %i"
PIDFile=/home/usr1cv8/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1'

[Install]
WantedBy=multi-user.target

与原始配置的主要区别:

  • systemd将说明符的值保存%i为环境变量display_temp,因为我们需要在下一步中删除冒号(:1-> 1
  • vncserver -kill我们删除/tmp/.X11-unix/目录下的套接字并锁定文件之后/tmp/。为了使用环境变量替换,我们需要像这样转义美元符号:($$有关更多详细信息,请参阅该答案:https://unix.stackexchange.com/a/216786

相关内容