1、查看是否安装vnc
rpm -qa | grep vnc
2、centos安装vnc
yum install vnc vnc-server yum install tightvnc-server
3、去除端口防火墙
iptables -I INPUT -p tcp --dport 5901 -j ACCEPT查看防火墙状态:firewall-cmd --state
4、查看是否安装Gnome桌面环境【vnc viewer连接黑屏可能没安装这个桌面环境】
yum grouplist
5、安装Gnome桌面环境
yum groupinstall "GNOME Desktop"
安装失败截图
该问题是由于fwupdate-efi 组件与grub2-common冲突导致安装出错,这时可以通过更新grub2-common组件,来处理。
yum update grub2-common
Is this ok[y/d/N]:y
重新安装:yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y
更新成功界面:
6、新建桌面:1
vncserver :1
输入“vncserver :1”后设置密码
Password: 设置使用VNC连接服务器的密码
Verify: 再次输入一遍密码
Would you like to enter a view-only password (y/n)? 选择n,以使连接到服务器后可以操作服务器
其他命令:
设置VNC密码
vncpasswd
查看vncserver的服务情况
vncserver -list
查看vncserver进程
ps -ef|grep vnc
开启编号为:1的桌面
vncserver :1
关闭编号为:1的vncserver
vncserver -kill :1
更新systemctl使配置生效
systemctl daemon-reload
客户端黑屏 CentOS 执行
chmod 755 /root/.vnc/xstartup
卸载vnc软件
yum remove tigervnc-server -y
删除vnc下的配置
rm -rf /root/.vnc rm -rf /etc/.X11-unit rm -rf /etc/.X*-lock