问题起源:手贱yum upgrade,重启服务器后无法使用vnc viewer远程连接
查看状态
# systemctl status vncserver@:1
● 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 Thu 2020-12-10 21:38:43 CST; 1h 5min ago
Process: 1154 ExecStart=/usr/bin/vncserver_wrapper root :1 (code=exited, status=203/EXEC)
Process: 1141 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Main PID: 1154 (code=exited, status=203/EXEC)
12月 10 21:38:43 VM-0-9-centos systemd[1]: Starting Remote desktop service (VNC)...
12月 10 21:38:43 VM-0-9-centos systemd[1]: Started Remote desktop service (VNC).
12月 10 21:38:43 VM-0-9-centos systemd[1154]: vncserver@:1.service: Failed to execute command: No such file or directory
12月 10 21:38:43 VM-0-9-centos systemd[1154]: vncserver@:1.service: Failed at step EXEC spawning /usr/bin/vncserver_wrapper: No such file >
12月 10 21:38:43 VM-0-9-centos systemd[1]: vncserver@:1.service: Main process exited, code=exited, status=203/EXEC
12月 10 21:38:43 VM-0-9-centos systemd[1]: vncserver@:1.service: Failed with result 'exit-code'.
看官方文档发现升级后有变更,解决步骤整理如下:
vim /etc/tigervnc/vncserver.users
:1=root(窗口及默认用户)
vim $HOME/.vnc/config
session=gnome(远程桌面的名称,可在/usr/share/xsessions查看)
restorecon -RFv /home/root/.vnc(有远程访问密码的需要执行)
rm -f /etc/systemd/system/vncserver@:1.service(删除旧版本配置,不然无法启动)
systemctl daemon-reload(重新加载配置文件)
systemctl start vncserver@:1(启动)
成功启动,无报错,查看状态OK:
systemctl status vncserver@:1
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/usr/lib/systemd/system/vncserver@.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-12-10 22:46:46 CST; 9s ago
Process: 18003 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)
Main PID: 18009 (vncsession)
Tasks: 1 (limit: 49372)
Memory: 2.0M
CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
‣ 18009 /usr/sbin/vncsession root :1
12月 10 22:46:46 VM-0-9-centos systemd[1]: Starting Remote desktop service (VNC)...
12月 10 22:46:46 VM-0-9-centos systemd[1]: Started Remote desktop service (VNC).
重启服务器后远程连接依然可用,问题解决。