安装、创建用户、编辑等后,当我尝试启动服务时,我得到(从 tmp 删除 .Xfiles 后,@SivaPrasath 建议)
systemctl start vncserver@:1.service
Job for vncserver@:1.service failed because the control process exited with error code.
See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
systemctl
说:
[root@localhost ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
Active: failed (Result: protocol) since Tue 2018-05-15 19:26:13 -03; 1min 36s ago
Process: 4284 ExecStart=/usr/sbin/runuser -l r_vnc -c /usr/bin/vncserver :1 -geometry 1280x1024 (code=exited, status=0/SUCCESS)
Process: 4282 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
May 15 19:26:10 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
May 15 19:26:13 localhost.localdomain systemd[1]: vncserver@:1.service: PID file /home/r_vnc/.vnc/localhost.localdomain:1.pid not readable (yet?) after start: Permission denied
May 15 19:26:13 localhost.localdomain systemd[1]: Failed to start Remote desktop service (VNC).
May 15 19:26:13 localhost.localdomain systemd[1]: vncserver@:1.service: Unit entered failed state.
May 15 19:26:13 localhost.localdomain systemd[1]: vncserver@:1.service: Failed with result 'protocol'.
journalctl
说:
- Unit UNIT has begun starting up.
May 15 16:42:15 localhost.localdomain systemd[13394]: Received SIGRTMIN+24 from PID 13453 (kill).
May 15 16:42:15 localhost.localdomain systemd[1]: Stopped User Manager for UID 1002.
-- Subject: Unit [email protected] has finished shutting down
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has finished shutting down.
May 15 16:42:15 localhost.localdomain audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user@1002 comm="systemd" exe="/usr/lib/systemd/systemd" hostname
May 15 16:42:15 localhost.localdomain systemd[1]: Removed slice User Slice of r_vnc.
-- Subject: Unit user-1002.slice has finished shutting down
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-1002.slice has finished shutting down.
我该如何修复该错误?
答案1
如果您终止了 vncserver 或意外死亡,请阅读 /var/log/messages,您可以找到 .X 启动的文件,其中包含如下错误。首先,请验证 Xvnc 进程未运行。
Aug 13 12:11:11 www runuser: Warning: www.example.com:2 is taken because of /tmp/.X2-lock
...
Aug 13 12:12:52 www runuser: Warning: www.example.com:2 is taken because of /tmp/.X22-unix/X2
然后你删除
# rm -f /tmp/.X2-lock
# rm -f /tmp/.X22-unix/X2
如果未设置,则为用户设置 VNC 密码。设置密码后,您应该能够按预期启动 VNC 服务器。
# su - <user name>
$ vncpasswd
并重新启动你的vnc服务器。
# systemctl restart vncserver@:2.sevice