用的好好的vncserver 突然遇到这个错误:
[vnc@localhost ~]$ sudo systemctl status vncserver@:1.service -l
● 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 日 2016-05-29 22:13:19 EDT; 6min ago
Process: 2888 ExecStart=/usr/sbin/runuser -l vnc -c /usr/bin/vncserver %i (code=exited, status=2)
Process: 1576 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
5月 29 22:13:12 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
5月 29 22:13:19 localhost.localdomain systemd[1]: vncserver@:1.service: control process exited, code=exited status=2
5月 29 22:13:19 localhost.localdomain systemd[1]: Failed to start Remote desktop service (VNC).
5月 29 22:13:19 localhost.localdomain systemd[1]: Unit vncserver@:1.service entered failed state.
5月 29 22:13:19 localhost.localdomain systemd[1]: vncserver@:1.service failed.
5月 29 22:13:19 localhost.localdomain runuser[2888]: Warning: localhost.localdomain:1 is taken because of /tmp/.X11-unix/X1
5月 29 22:13:19 localhost.localdomain runuser[2888]: Remove this file if there is no X server localhost.localdomain:1
5月 29 22:13:19 localhost.localdomain runuser[2888]: A VNC server is already running as :1
查看日志的最后一行是“A VNC server is already running as :1”,
于是我就把/etc/systemd/system/下的 vncserver@:1.service 改成 vncserver@:2.service
执行:
# systemctl disable vncserver@:1.service
# systemctl daemon-reload
# systemctl start vncserver@:2.service
# systemctl enable vncserver@:2.service
查了一下:
# systemctl status vncserver@:2.service
运行状态是active:-)
# netstat -nlp | grep vnc
发现vncserver在监听 5902端口
这时运行 vncviewer, 访问 IP:5902, 成功,OK了。