NeoKylin Linux Advanced Server release V7Update6 (Chromium)
查看操作系统信息
[root@ecs-f61c-0001 ~]# nkvers ############## NeoKylin Linux Version################# Release: NeoKylin Linux Advanced Server release V7Update6 (Chromium) Kernel: 4.14.0-115.5.1.el7a.06.aarch64 Build: NeoKylin Linux Advanced Server release V7Update6/(Chromium)-aarch64 b06.lic/20190619
安装vncserver
以root用户运行以下命令来安装vncserver
[root@ecs-f61c-0001 sysconfig]# yum install tigervnc-server
同样运行以下命令来安装vncviewer
[root@ecs-f61c-0001 sysconfig]# yum install vnc
停止并禁用防火墙,或者开放5901,5902端口
[root@ecs-f61c-0001 sysconfig]# systemctl stop firewalld.service [root@ecs-f61c-0001 sysconfig]# systemctl disable firewalld.service
VNC配置和应用
vncserver的配置,创建一个新的配置文件,以开启1号窗口为例(也可以同时开启多个窗口,修改数字即可),方法如下(以下命令复制了两个vncserver服务,也就是可以同时允许2个桌面启动,多个桌面以此类推):
[root@ecs-f61c-0001 sysconfig]# cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service [root@ecs-f61c-0001 sysconfig]# cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:2.service
编辑/lib/systemd/system/vncserver@:1.service,设置用户root相关参数,最终内容如下(如果有多个服务,全部需要查看一下,一般不需要修改):
# The vncserver service unit file # # Quick HowTo: # 1. Copy this file to /etc/systemd/system/vncserver@.service # 2. Replace <USER> with the actual user name and edit vncserver # parameters appropriately # (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" # PIDFile=/home/<USER>/.vnc/%H%i.pid) # 3. Run `systemctl daemon-reload` # 4. Run `systemctl enable vncserver@:<display>.service` # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, you should # limit connections to the local host and then tunnel from # the machine you want to view VNC on (host A) to the machine # whose VNC output you want to view (host B) # # [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB # # this will open a connection on port 590N of your hostA to hostB's port 590M # (in fact, it ssh-connects to hostB and then connects to localhost (on hostB). # See the ssh man page for details on port forwarding) # # You can then point a VNC client on hostA at vncdisplay N of localhost and with # the help of ssh, you end up seeing what hostB makes available on port 590M # # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP. # # Use "-localhost" to prevent remote VNC clients connecting except when # doing so through a secure tunnel. See the "-via" option in the # `man vncviewer' manual page. [Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" PIDFile=/home/<USER>/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target
更新systemctl以使其生效
[root@ecs-f61c-0001 sysconfig]# systemctl daemon-reload
设置vncserver的密码
[root@ecs-f61c-0001 sysconfig]# vncpasswd root Password: Verify: Would you like to enter a view-only password (y/n)? y Password: Verify:
按提示输入密码以及确认密码
启动指定的桌面服务
[root@ecs-f61c-0001 sysconfig]# systemctl start vncserver@:1.service 或者 [root@ecs-f61c-0001 sysconfig]# vncserver :1
其他桌面类似
关闭指定的桌面服务
[root@ecs-f61c-0001 sysconfig]# systemctl stop vncserver@:1.service 或者 [root@ecs-f61c-0001 sysconfig]# vncserver -kill :1
其他桌面类似
设置为开机自动启动
[root@ecs-f61c-0001 sysconfig]# systemctl enable vncserver@:1.service [root@ecs-f61c-0001 sysconfig]# systemctl enable vncserver@:2.service
测试VNC连接
安装VNC客户端
RealVNC官网:https://www.realvnc.com/en/connect/download/viewer/
下载地址:https://www.realvnc.com/download/file/viewer.files/VNC-Viewer-6.20.529-Windows.exe
安装客户端(略)
启动客户端:
连接服务器桌面:
输入密码连接成功:
正常登录服务器并且进行操作:
可能遇到的问题(CentOS环境下)
1.设置为非root用户报错:
[root@ecs-f61c-0001 sysconfig]# systemctl status -l vncserver@:2.service vncserver@:2.service - Remote desktop service (VNC) Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since 一 2016-04-25 19:07:23 CST; 7s ago Process: 10305 ExecStart=/usr/sbin/runuser -l fang -c /usr/bin/vncserver %i (code=exited, status=1/FAILURE) Process: 10291 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS) 4月 25 19:07:23 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)... 4月 25 19:07:23 localhost.localdomain systemd[1]: vncserver@:2.service: control process exited, code=exited status=1 4月 25 19:07:23 localhost.localdomain systemd[1]: Failed to start Remote desktop service (VNC). 4月 25 19:07:23 localhost.localdomain systemd[1]: Unit vncserver@:2.service entered failed state. 4月 25 19:07:23 localhost.localdomain systemd[1]: vncserver@:2.service failed.
2.Type=forking报错,改为Type=simple
[root@ecs-f61c-0001 sysconfig]# systemctl start vncserver@:2.service Job for vncserver@:2.service failed because the control process exited with error code. See "systemctl status vncserver@:2.service" and "journalctl -xe" for details. [root@ecs-f61c-0001 sysconfig]# systemctl status -l vncserver@:2.service ● vncserver@:2.service - Remote desktop service (VNC) Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since 一 2016-04-25 19:09:41 CST; 6s ago Process: 12367 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=98) Process: 12354 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS) 4月 25 19:09:41 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)... 4月 25 19:09:41 localhost.localdomain systemd[1]: vncserver@:2.service: control process exited, code=exited status=98 4月 25 19:09:41 localhost.localdomain systemd[1]: Failed to start Remote desktop service (VNC). 4月 25 19:09:41 localhost.localdomain systemd[1]: Unit vncserver@:2.service entered failed state. 4月 25 19:09:41 localhost.localdomain systemd[1]: vncserver@:2.service failed.
3.vnc viewer客户端连接黑屏,改变xstartup的权限
这个问题是很多人容易忽视的问题,也是造成连接成功后黑屏的原因之一。
在CentOS中,xstartup的文件路径为:/root/.vnc/ (可以通过locate xstartup来查看xstartup的文件路径)
所以需要执行:
[root@ecs-f61c-0001 sysconfig]# chmod 777 /root/.vnc/xstartup
关闭防火墙
[root@ecs-f61c-0001 sysconfig]# systemctl stop firewalld.service #停止 [root@ecs-f61c-0001 sysconfig]# systemctl disable firewalld.service #禁用
推荐文章:
开发知识-Vue篇:使用Vue-CLI开发O2应用
2021-04-29
Vue-CLI是Vue官方提供的CLI工具,用于为应用快速搭建繁杂的脚手架。本章我们介绍使用Vue-CLI工具在Node,js环境下,Vue和O2集成应用开
组织人员导入-根据Excel模板导入组织人员数据
2021-03-03
O2OA允许管理员根据Excel模板批量对组织和人员数据进行导入导出操作。本文主要介绍如何在O2OA中完成组织和人员的导入导出操作。
数据中心-简介
2021-11-22
开发知识-React篇:在O2OA门户页面中使用React
2021-02-07
O2OA提供了门户平台,使用可视化方式设计页面,用于设计系统主页、列表等系统中的各类页面,在一定程度上降低了开发者的技能要求。但是对于有经验的前端开发人员,
论坛管理
2021-09-23
O2OA平台论坛管理为企业提供了一个员工公开交流的场所,经过配置后,论坛可以拥有丰富的栏目、版块,可以进行版块的权限设置,可见性,发贴回复权限设置。
开发知识-单个端口模式的Nginx和系统配置
2021-02-07
配置目的部分企事业单位外网地址不能开通太多的端口,我们使用单个端口,上下文根的方式配置访问地址。Nginx服务器域名:harbor.o2oa.net(172.1
流程设计-拆分流程样例
2021-03-01
在复杂的流程设计中通常需要使用到拆分功能,比如公文管理流程中的各部门办理。本文主要介绍如何在O2OA平台中设计流程时使用流程拆分功能。
门户开发-HTML模板导入
2021-03-01
O2OA提供的门户管理平台可以让用户自由地为企业定制符合企业特色的门户系统,门户页面。可以让页面展现的内容真正满足企业自身的需求。平台支持将完整的HTML文件导
快速入门-流程表单载入基础数据
2021-02-07
表单载入数据以联系电话为例:联系电话字段默认值写脚本:returnthis.session.user.mobile(脚本详解在下方)即可人员基础信息当前用户信息
日志管理-审计日志相关配置
2021-02-25
O2OA平台默认未开启审计日志,可以通过配置来开启平台的审计日志,用于记录用户的系统访问情况。本篇主要介绍如何将在O2OA中开启审计日志。