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

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://i-blog.csdnimg.cn/blog_migrate/9f0261b2e2a75676191525170e9ece07.png

vnc connection

https://i-blog.csdnimg.cn/blog_migrate/915a853fbb9346813e2001be4a5e6a24.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://i-blog.csdnimg.cn/blog_migrate/f6fd668c04aac7fe5922f052ae8aeaba.png

vi ~/.vnc/config

https://i-blog.csdnimg.cn/blog_migrate/c1e74f4616aca5c09217762783429109.png

重启VNC服务

systemctl stop vncserver@:1

systemctl start vncserver@:1

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

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值