文章目录
- 一、场景介绍
- 二、名词解释
- 三、CentOS 图形安装
- 四、VNC 服务端安装
- 五、VNC 客户端连接
一、场景介绍
-
在某些特定场景下,我们需要通过 Linux
环境来调试代码,比如 Shell
脚本的调试
-
如果每次通过盲写好的 shell
脚本,全盘复杂到 Linux
环境的 .sh
文件中执行,很难找到问题
-
遂出现此文章:通过 VNC
连接 Linux
的图形化桌面,在图形化桌面安装 IDEA
来调试 Shell
脚本
二、名词解释
-
VNC:VNC(Virtual Network Computing)
为一种使用 RFB
协议的屏幕画面分享及远程操作软件。此软件借由网络,可发送键盘与鼠标的动作及即时的屏幕画面。VNC
与操作系统无关,因此可跨平台使用,例如可用 Windows
连线到某 Linux
的计算机,反之亦同。甚至在没有安装客户端程序的计算机中,只要有支持 JAVA
的浏览器,也可使用。VNC
包含客户端和服务器两个操作软件。
-
VNC Server:VNC
服务器,接收 VNC Viewer
的连接请求,传输画面到客户端。本例需要在 CentOS 7
上安装 VNC Server
-
VNC Viewer:VNC
客户端,将键盘和鼠标的动作转递给服务器,例如:在 Windows
上安装 Viewer
连接到远程的 Linux
服务器,Mac
通过 Royal TSX
的 VNC
插件来连接 Linux
服务器
-
Linux桌面环境:Linux
不像 Windows
,安装完系统就有可视化的图形界面,并且每个版本图形化界面完全一致,Linux
图像界面有很多种可供你选择,你可以选择你喜欢的图形界面环境进行安装,VNC
上传输的图形界面,就是你安装的界面。本例选择的是 GNOME
。
-
X Window System:X
窗口系统(X Window System
,也常称为 X11
或 X
)是一种以位图方式显示的软件窗口系统。最初是 1984 年麻省理工学院的研究,之后变成 UNIX
、类 UNIX
、以及 OpenVMS
等操作系统所一致适用的标准化软件工具包及显示架构的运作协议。X
窗口系统通过软件工具及架构协议来创建操作系统所用的图形用户界面,此后则逐渐扩展适用到各形各色的其他操作系统上。现在几乎所有的操作系统都能支持与使用 X
。更重要的是,今日知名的桌面环境—— GNOME
和 KDE
也都是以 X
窗口系统为基础建构成的
三、CentOS 图形安装
-
安装图形用户接口 X Window System
yum groupinstall "X Window System"
-
安装 GNOME
yum groupinstall "GNOME Desktop"
-
启动 X Windows
startx
xauth: file /root/.serverauth.152726 does not exist
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: 3.10.0-957.1.3.el7.x86_64
Current Operating System: Linux node44 3.10.0-1160.25.1.el7.x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.25.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=zh_CN.UTF-8
Build Date: 24 February 2021 09:09:20PM
Build ID: xorg-x11-server 1.20.4-15.el7_9
Current version of pixman: 0.34.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.2.log", Time: Mon Nov 22 10:01:23 2021
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(II) [KMS] Kernel modesetting enabled.
resizing primary to 1024x768
primary is 0x55e7f1230140
四、VNC 服务端安装
-
查看 Linux
是否已经安装 tigervnc-server
[root@node44 ~]
package tigervnc is not installed
package tigervnc-server is not installed
-
在 Linux
服务器上安装 tigervnc-server
服务
yum install tigervnc-server -y
-
启动 tigervnc-server
服务
vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
New 'node44:1 (root)' desktop is node44:1
Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/node44:1.log
P.S
-
设置 vncserver
开机启动
cp /lib/systemd/system/vncserver@.service vncserver@:1.service
ExecStart=/usr/bin/vncserver_wrapper root %i
systemctl daemon-reload
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
systemctl stop vncserver@:1.service
-
开启 vncserver
服务端防火墙端口
firewall-cmd --zone=public --add-port=5901/tcp --permanent
firewall-cmd --reload
五、VNC 客户端连接
-
RealVNC Viewer
下载地址
-
Royal TSX
下载地址
-
Royal TSX
配置截图
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)