王大拿
知道的越多,不知道的也就越多! 只要学不死,就往死里学!!!

系统信息

[root@centos8 ~]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
[root@centos8 ~]#

注意要安装桌面环境,如果没有安装桌面环境,登进去是黑屏。
处理:
1.安装桌面环境(yum groupinstall "Server with GUI")
2.重启VNCServer(systemctl restart vncserver@:1.service)

安装VNCServer

[root@centos8 ~]# dnf install -y tigervnc-server tigervnc-server-module

复制配置文件

[root@centos8 ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

编辑 vim /etc/tigervnc/vncserver.users 添加用户

[root@centos8 ~]# vim /etc/tigervnc/vncserver.users
# TigerVNC User assignment
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:1=root

开启服务

[root@centos8 ~]# systemctl daemon-reload
[root@centos8 ~]# systemctl start vncserver@:1.service

如果是给非root创建的话需要切换到该用户下产生vncpasswd

[root@centos8 ~]# su user
[user@centos8 ~]$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
[user@centos8 ~]$ exit
exit

测试是否VNCServer是否开起来

[root@centos8 ~]# nc -zv localhost 5901
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Connected to ::1:5901.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

关闭防火墙或开启端口权限

关闭防火墙

[root@centos8 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-06-21 22:40:18 CST; 14min ago
     Docs: man:firewalld(1)
 Main PID: 890 (firewalld)
    Tasks: 2 (limit: 11460)
   Memory: 29.7M
   CGroup: /system.slice/firewalld.service
           └─890 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid

Jun 21 22:40:16 centos8 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 21 22:40:18 centos8 systemd[1]: Started firewalld - dynamic firewall daemon.
[root@centos8 ~]# systemctl stop firewalld

开启端口权限

–permanent永久生效,没有此参数重启后失效
[root@centos8 ~]# firewall-cmd --zone=public --add-port=5901/tcp --permanent
success
[root@centos8 ~]# firewall-cmd --reload
success
posted on 2021-10-12 11:36  DevOps_SRE  阅读(104)  评论(0编辑  收藏  举报