开发者社区> 问答> 正文

centos8过一段时间vnc无法开启

vncserver@:1.service - Remote desktop service (VNC) Loaded: loaded (/usr/lib/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2020-11-02 22:35:09 CST; 15min ago Main PID: 1250 (code=exited, status=2)

重装系统可以连一段时间,过几个小时就连不上了,看状态一直是加载服务失败。 重启也不行,我看到有一句写着是服务商预设禁用,不晓得咋回事

展开
收起
游客pztdapa5tki3e 2020-11-02 22:56:30 1253 0
1 条回答
写回答
取消 提交回答
  • 安装VNCServer [root@centos8 ~]# yum install tigervnc-server CentOS-8 - AppStream 5.6 kB/s | 4.3 kB 00:00
    CentOS-8 - Base 4.5 kB/s | 3.9 kB 00:00
    CentOS-8 - Extras 1.8 kB/s | 1.5 kB 00:00
    Dependencies resolved.

    Package Architecture Version Repository Size

    Installing: tigervnc-server x86_64 1.9.0-15.el8_1 AppStream 255 k

    Transaction Summary

    Install 1 Package

    Total download size: 255 k Installed size: 849 k Is this ok [y/N]: y Downloading Packages: tigervnc-server-1.9.0-15.el8_1.x86_64.rpm 382 kB/s | 255 kB 00:00

    Total 119 kB/s | 255 kB 00:02
    warning: /var/cache/dnf/AppStream-a520ed22b0a8a736/packages/tigervnc-server-1.9.0-15.el8_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY CentOS-8 - AppStream 949 kB/s | 1.6 kB 00:00
    Importing GPG key 0x8483C65D: Userid : "CentOS (CentOS Official Signing Key) security@centos.org" Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial Is this ok [y/N]: y Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : tigervnc-server-1.9.0-15.el8_1.x86_64 1/1 Running scriptlet: tigervnc-server-1.9.0-15.el8_1.x86_64 1/1 Verifying : tigervnc-server-1.9.0-15.el8_1.x86_64 1/1

    Installed: tigervnc-server-1.9.0-15.el8_1.x86_64

    Complete! [root@centos8 ~]# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 这里检查一下,如果Installed是tigervnc-server-1.10.1-7.el8.x86_64,参考我的另一篇文章CentOS8安装VNCServer1.10

    复制配置文件 [root@centos8 ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service [root@centos8 ~]# 1 2 编辑复制后的配置文件 [root@centos8 ~]# vim /etc/systemd/system/vncserver@:1.service [root@centos8 ~]# 1 2 #修改前 ExecStart=/usr/bin/vncserver_wrapper %i

    #把 改成要登录的用户名(此处为root)

    #修改后 ExecStart=/usr/bin/vncserver_wrapper root %i 1 2 3 4 5 6 7 开启服务 [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 [root@centos8 ~]# 1 2 3 4 5 6 7 8 9 10 11 12 测试是否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 ~]# 1 2 3 4 5 关闭防火墙或开启端口权限 关闭防火墙

    [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 [root@centos8 ~]# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 开启端口权限 –permanent永久生效,没有此参数重启后失效

    [root@centos8 ~]# firewall-cmd --zone=public --add-port=5901/tcp --permanent success [root@centos8 ~]# firewall-cmd --reload success [root@centos8 ~]#

    2021-02-19 17:33:30
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载
低代码开发师(初级)实战教程 立即下载