一、需求背景
查看系统版本信息:
[root@XAYL YLMonitor]# cat /etc/os-releaseNAME="Anolis OS"VERSION="8.8"ID="anolis"ID_LIKE="rhel fedora centos"VERSION_ID="8.8"PLATFORM_ID="platform:an8"PRETTY_NAME="Anolis OS 8.8"ANSI_COLOR="0;31"HOME_URL="https://openanolis.cn/"
需要在该服务器上配置VNC服务,以便通过远程进行操作。
二、图形化UI安装
安装图像化GUI界面并设置默认
yum groupinstall "Server with GUI" -y
systemctl set-default graphical
三、配置VNC
1、基础包安装
yum install tigervnc-server tigervnc-server-module -y
2、VNC配置初始化
vncpasswd注释:Password:第一次输入密码Verify:确认密码Would you like to enter a view-only password (y/n)?:n
3、手动启动vnc
# vncserver
[WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.Please read /usr/share/doc/tigervnc/HOWTO.md for more information.New 'XAYL:1 (root)' desktop is XAYL:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/XAYL:1.log
四、将VNC集成到系统服务
vim /etc/systemd/system/vncserver@.service
[Unit]Description=Remote Desktop VNC ServiceAfter=syslog.target network.target[Service]Type=forkingWorkingDirectory=/rootUser=rootGroup=rootExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/bin/vncserver -autokill %iExecStop=/usr/bin/vncserver -kill %i[Install]WantedBy=multi-user.target
五、服务常用命令
// 启动服务
# systemctl start vncserver@:1.service
// 开机启动
# systemctl enable vncserver@:1.service
// 查看状态
# systemctl status vncserver@:1.service

手动终止命令:
vncserver -kill :1
vncserver :1 -geometry 1536x864
六、连接测试
防火墙先放行对应的端口。
然后使用VNC客户端进行连接测试。
地址输入:192.168.3.104:5901

七、常见报错处理
1、启动时提示:Make sure an X server isn't already running(EE)
Fatal server error:_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed_XSERVTransMakeAllCOTSServerListeners: server already runningFatal server error:
解决方案:
touch /tmp/.X11-unix/X1
chmod 777 /tmp/.X11-unix/X1
2、启动时提示:(EE) Cannot establish any listening sockets - Make sure an X server isn't already r>
解决方案:
sudo pkill Xorg
3、连接后提示:系统出错并无法恢复,请尝试注销。

暂时未解决此问题。

