文章目录
-
- 1. X server、Xvnc 和 VNC server
- 2. vncserver系统服务的配置和开启
-
- 2.1 配置root的VNC窗口
- 2.2 配置非root的其他用户的VNC窗口
- 2.3 设置客户端访问密码(可不设置):
- 2.4 常见问题
-
- (1)enable失败:
- (2)发现之前的系统服务实际执行的文件都在/usr/lib/systemd/system/下,但按理来说应该在/etc/systemd/system/(优先级高于/usr/lib/systemd/system/)下。
- (3)查看启动状态,发现启动失败(status=98、status=2/INVALIDARGUMENT):
- (4)远程VNC Vierwer连接192.168.213.193:5901,在客户端关闭VNC窗口时,会导致服务端的vncserver@:1.service也被关闭。
- (5)系统服务启动失败(New main PID 5869 does not belong to service, and PID file is not owned by root. Refusing.):
- (6)非root用户启动错误(status=1/FAILURE)
- 3. xvnc.socket 和 gdm.service
- 参考文献
1. X server、Xvnc 和 VNC server
X Window System
Linux的图形接口,称为 X 或 X11。
包括 X Server、X Client。
X Server
管理键盘、鼠标、手写板、显示器、屏幕分辨率与颜色深度、显示适配器 (包含驱动程序) 与显示的字型等硬件。
https://linux.die.net/man/1/xserver
X Client
处理來自 X Server 的动作,将该动作处理成为绘图数据, 再将这些绘图数据传回给 X Server。
X Client 也称为 X Application (X 应用程序)。
每个 X Client 并不知道其他 X Client 的存在。
X Window Manager
特殊的 X Client ,负责管理所有的 X client 软件。
常见的窗口管理员:
- GNOME (GNU Network Object Model Environment):http://www.gnome.org/
- KDE (K Desktop Enviroment):http://kde.org/
- twm (Tab Window Manager):http://xwinman.org/vtwm.php
- XFCE (XForms Common Environment):http://www.xfce.org/
Display Manager
提供登入的环境, 加载使用者选择的 Window Manager 和语系等资料。
X Window启动方式
方式一:startx
方式二:(如果有启动 graphical.target) display manager 提供的登录界面
主机上的 X 可能有多个同时存在,因此,当启动 X Server / Client 時, 应注明该 X Server / Client 主要是提供或接受哪个显示接口(:0、:1、…)。
Xvnc
Xvnc is the X VNC (Virtual Network Computing) server. It is based on a standard X server, but it has a “virtual” screen rather than a physical one. X applications display themselves on it as if it were a normal X display, but they can only be accessed via a VNC viewer .
By convention we have arranged that the VNC server display number will be the same as the X server display number, which means you can use eg. snoopy:2 to refer to display 2 on machine “snoopy” in both the X world and the VNC world.
2. vncserver系统服务的配置和开启
2.1 配置root的VNC窗口
[HEPS@localhost ~]$ sudo vi /etc/systemd/system/vncserver@.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
[HEPS@localhost ~]$ sudo systemctl enable vncserver@:1.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver@:1.service to /usr/lib/systemd/system/vncserver@:1.service.
[HEPS@localhost ~]$ sudo systemctl start vncserver@:1.service
2.2 配置非root的其他用户的VNC窗口
[HEPS@localhost ~]$ sudo vi /etc/systemd/system/vncserver@:2.service
[Unit]
Description=Remote desktop service (VNC