Centos 7.5 安装 VNC服务及调整VNC分辨率

发布于:2023-01-14 ⋅ 阅读:(1900) ⋅ 点赞:(0)

1、安装 VNC 服务

[root@hadoop102 ~]# yum install tigervnc tigervnc-server tigervnc-server-module  –y     

2、复制 vnc 配置文件

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

3、编辑 vnc 配置文件

[root@hadoop101 system]# vi vncserver@\:1.service   
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"   
PIDFile=/root/.vnc/%H%i.pid   

4、查看 vnc 配置文件

[root@hadoop102 system]# ls -l | grep -i vnc  

5、系统加载

[root@hadoop101 system]# systemctl daemon-reload  

6、设置 vnc 密码

[root@hadoop101 system]# vncpasswd   

7、关闭防火墙

[root@hadoop101 system]# systemctl stop firewalld
[root@hadoop101 system]# systemctl disable firewalld   

8、启动 vnc 服务

[root@hadoop102 system]# systemctl start vncserver@\:1.service
[root@hadoop102 system]# systemctl status vncserver@\:1.service
[root@hadoop102 system]# systemctl enable vncserver@\:1.service

9、查看 vnc 服务

[root@hadoop102 system]# vncserver -list   

10、查看 vnc 端口

[root@hadoop101 system]# netstat -anpt | grep 5901   

11、赋予权限

[root@hadoop101 ~]# vi ~/.vnc/xstartup#!/bin/sh   
unset SESSION_MANAGER   
unset DBUS_SESSION_BUS_ADDRESS   
/etc/X11/xinit/xinitrc   
# Assume either Gnome or KDE will be started by default when installed   
# We want to kill the session automatically in this case when user logs out. In case you    modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should       
# be responsible to modify below code to avoid that your session will be automatically killed   
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then    
    vncserver -kill $DISPLAY    
   fi    
[root@hadoop101 ~]# chmod 755 ~/.vnc/xstartup 

尖叫提示:如果vnc连接不上,再执行这一步

12、vnc 连接

https://img-blog.csdnimg.cn/img_convert/a6c5d5b595568c3971db2b705c24e1ca.png

vnc connection

https://img-blog.csdnimg.cn/img_convert/816a588dd0c1325e2aa9a105d7567137.png

vnc 连接成功

CentOS7中调整VNC分辨率

我用的版本配置文件路径如下:

/etc/systemd/system/vncserver@:1.service

数字 1是变量可以为其他的值,这里的数字1将用与此服务特定实例的显示编号,这一点很重要。因为它还将确定我们的 VNC 服务器将使用的 TCP 端口,等于 5900 + 显示编号。第一个是5901,然后是5902,等等。

配置分辨率

配置文件路径:~/.vnc/config
切换到用于连接vnc的用户,也就是/etc/systemd/system/vncserver@:1.service文件中配置的用户。

https://img-blog.csdnimg.cn/20210127143928515.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2x4eW91Y2Fu,size_16,color_FFFFFF,t_70

vi ~/.vnc/config

https://img-blog.csdnimg.cn/20210127143321388.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2x4eW91Y2Fu,size_16,color_FFFFFF,t_70

重启VNC服务

systemctl stop vncserver@:1

systemctl start vncserver@:1

再次连接发现分辨率已经修改成功啦!

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到