centos8安装部署vnc

环境:
[root@cos8 yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 8.5.2111

 

说明:安装步骤也适用于rocky 8,AnolisOS-8.6

 

 

1.检查是否安装了Graphical Administration Tools

[root@cos8 yum.repos.d]# yum grouplist
Last metadata expiration check: 0:14:21 ago on Mon 24 Apr 2023 03:53:43 PM CST.
Available Environment Groups:
   Server
   Minimal Install
   Workstation
   Custom Operating System
   Virtualization Host
Installed Environment Groups:
   Server with GUI
Installed Groups:
   Container Management
   Headless Management
Available Groups:
   Legacy UNIX Compatibility
   Development Tools
   .NET Core Development
   Graphical Administration Tools
   Network Servers
   RPM Development Tools
   Scientific Support
   Security Tools
   Smart Card Support
   System Tools

 

安装操作系统的时候默认选项是安装图形界面的,若没有安装,执行如下命令安装:
[root@cos8 yum.repos.d]#dnf groupinstall "Server with GUI" -y
可以使用本地iso盘安装,详细步骤请参考:https://www.cnblogs.com/hxlasky/p/17349847.html
mount CentOS-8.5.2111-x86_64-dvd1.iso -o loop /mnt

 

2.检查是否安装了vnc
[root@cos8 yum.repos.d]# rpm -qa|grep vnc
libvncserver-0.9.11-17.el8.x86_64
tigervnc-license-1.11.0-9.el8.noarch
tigervnc-server-minimal-1.11.0-9.el8.x86_64
gvnc-0.9.0-2.el8.x86_64
gtk-vnc2-0.9.0-2.el8.x86_64


安装
[root@cos8 yum.repos.d]# dnf install tigervnc-server -y

 

3.关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service
vi /etc/selinux/config
set "SELINUX=disabled" and comment the rest lines.

 

4.添加用户

[root@cos8 yum.repos.d]# vi /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=oracle

5.默认配置文件
[root@test1 ~]# vim /etc/tigervnc/vncserver-config-defaults

## 增加以下配置
session=gnome
##geometry=1366x768 ## 可以手动调整VNC连接分辨率,我这里保持默认的没有做任何修改

 

6.配置VNC密码
[oracle@cos8 ~]$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? y
Password:
Verify:

 

7.启动服务

[root@cos8 yum.repos.d]#systemctl start vncserver@:1
[root@cos8 yum.repos.d]#systemctl status vncserver@:1
a—? vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-04-24 16:40:59 CST; 6s ago
  Process: 36242 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)
 Main PID: 36249 (vncsession)
    Tasks: 0 (limit: 36742)
   Memory: 1.1M
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           a€£ 36249 /usr/sbin/vncsession oracle :1

Apr 24 16:40:59 cos8 systemd[1]: Starting Remote desktop service (VNC)...
Apr 24 16:40:59 cos8 systemd[1]: Started Remote desktop service (VNC).

 

8.查看5901端口

[root@cos8 yum.repos.d]# ss -nlp|grep 5901
tcp   LISTEN 0      5                                                               0.0.0.0:5901             0.0.0.0:*      users:(("Xvnc",pid=36283,fd=6))                                                             
tcp   LISTEN 0      5                                                                  [::]:5901                [::]:*      users:(("Xvnc",pid=36283,fd=7))

 

posted @ 2023-04-24 16:55  slnngk  阅读(446)  评论(0编辑  收藏  举报