CentOS7 安装VNC
系统环境:CentOS Linux release 7.6.1810
Kernel:3.10.0-957.el7.x86_64
系统现状:最小化安装,没有安装任何图形支持软件
安装图形化支持
不建议安装GNOME Desktop,它会占用大量系统资源,安装完后大约要占用1G左右的空间,而且安装过程也较长。以root权限安装“X Window System”即可
# yum groups install "X Window System" -y
# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts -y
修改系统启动级别
# systemctl set-default graphical.target #graphical.target相当于level5,multi-user.target相当于level3
安装vncserver
# yum install tigervnc-server -y
配置vncserver实例
分别配置root用户和test用户,配置略有不同,如果只配置root用户,跳过test用户部分的设定
root用户,服务名是vncserver@:1.service:
# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
修改拷贝过来的模板配置文件,主要是[Service]部分
# vi /etc/systemd/system/vncserver@\:1.service
[Service]
Type=forking
User=root
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
test用户,服务名是vncserver@:2.service:
# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
# vi /etc/systemd/system/vncserver@\:2.service
[Service]
Type=forking
User=test
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/usr/bin/vncserver %i
PIDFile=/home/test/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i
普通用户的ExecStart不同于root,加/sbin/runuser则会在启动服务时报以下错误
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.
设置vncpasswd
# vncpasswd #root用户实例的vnc密码
# su - test
$ vncpasswd #普通用户一定要切换到用户自己的环境下
密码设置完成后回到root权限下,启动服务
加载进程,启动服务
# systemctl daemon-reload #由于在systemd中修改了内容,得让系统重新加载
# systemctl start vncserver@:1.service #启动root用户的vnc服务1
# systemctl start vncserver@:2.service #启动test用户的vnc服务2
设置服务开机启动
# systemctl enable vncserver@:1.service #开机启动服务1
# systemctl enable vncserver@:2.service #开机启动服务2
配置防火墙
# firewall-cmd --permanent --add-service vnc-server #防火墙添加相关规则,添加访问权限
或
# firewall-cmd --permanent --zone=public --add-port=5901/tcp #permanent,永久生效,没有此参数重启后失效
# firewall-cmd --permanent --zone=public --add-port=5902/tcp
更新防火墙规则
# firewall-cmd --reload
# firewall-cmd --complete-reload
两者的区别就是第一个无需断开连接,就是firewalld特性之一动态添加规则,第二个需要断开连接,类似重启服务
至此结束,vnc已经配置好防火墙,设置了开机自启,设置了访问密码
其他VNC操作
# emctl restart vncserver@:1.service #重启动
# systemctl status vncserver@:1.service #状态
# systemctl is-enabled vncserver@:1.service #是否开机启动
可能的问题:
1、重启后,发现vncserver起不来了,报错:
[root@CentOS7 ~]# systemctl start vncserver@:1.service
Job for vncserver@:1.service failed because a configured resource limit was exceeded.
See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
将vncserver@\:1.service中的type改为simple,重新启动服务或者系统即可
vim /etc/systemd/system/vncserver@\:1.service
[Service]
Type=simple
其他防火墙操作
# systemctl start firewalld.service #启动防火墙服务
# systemctl stop firewalld.service #关闭防火墙
#systemctl restart firewalld.service #重启 #systemctl enable firewalld.service #开机启动
#systemctl disable firewalld.service #禁止开机启动
[root@CentOS7 ~]# systemctl status firewalld #查看状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 二 2019-01-22 11:35:34 CST; 3h 36min ago
Docs: man:firewalld(1)
Main PID: 3670 (firewalld)
CGroup: /system.slice/firewalld.service
└─3670 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 1月 22 11:35:33 CentOS7.Caojie systemd[1]: Starting firewalld - dynamic fir....
1月 22 11:35:34 CentOS7.Caojie systemd[1]: Started firewalld - dynamic fire....
Hint: Some lines were ellipsized, use -l to show in full.
[root@CentOS7 ~]# firewall-cmd --state #查看状态
running
[root@CentOS7 ~]# firewall-cmd --list-all # 查看防火墙规则(只显示/etc/firewalld/zones/public.xml中防火墙策略)
public (active)
target: default
icmp-block-inversion: no
interfaces: enp2s1
sources:
services: ssh dhcpv6-client vnc-server
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@CentOS7 ~]# firewall-cmd --query-service vnc-server #查看服务的启用状态
yes
[root@CentOS7 ~]# firewall-cmd --list-all-zones # 查看所有的防火墙策略(即显示/etc/firewalld/zones/下的所有策略)
block
target: %%REJECT%%
icmp-block-inversion: no
interfaces:
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
dmz
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
drop
target: DROP
icmp-block-inversion: no
interfaces:
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
external
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh
ports:
protocols:
masquerade: yes
forward-ports:
source-ports:
icmp-blocks:
rich rules:
home
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh mdns samba-client dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
internal
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh mdns samba-client dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
public (active)
target: default
icmp-block-inversion: no
interfaces: enp2s1
sources:
services: ssh dhcpv6-client vnc-server
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
trusted
target: ACCEPT
icmp-block-inversion: no
interfaces:
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
work
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
参考资料:
CentOS Linux下VNC Server远程桌面配置详解
CentOS7中firewall防火墙详解和配置,.xml服务配置详解
CentOS7 安装VNC的更多相关文章
- centos7 安装vnc服务
一,安装服务器端 1,添加用户: # useradd vnc # passwd vnc 2,安装gnome桌面 # yum groupinstall "GNOME Desktop" ...
- centos7 安装vnc远程服务
避免一些系统方面的意外错误,最好更新yum到最新,生产环境有业务在运行不建议更新 yum update 安装GNOME Desktop图形桌面服务 yum groupinstall "GNO ...
- CentOS7安装VNC
#安装 yum -y install tigervnc-server 将配置表复制到etc .service 修改配置文件 vim /etc/systemd/system/vncserver@\:.s ...
- Centos7 安装VNC实现远程桌面
1.设置root用户方法: 1.# 复制一个服务设置的模板,命令如下: cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vn ...
- centos6和7安装vnc
centos6安装vnc yum安装 yum groupinstall -y "Desktop" yum install -y tigervnc-server tigervnc-s ...
- centos7下安装vnc更改vnc默认端口号
应用场景:某些情景下,需要用的linux的桌面环境,Ubuntu的桌面性能在linux发行版中算是数一数二的,如果不熟悉Debian系统,Centos/RHEL系列也行: 我这里的场景是开发人员不 ...
- CentOS7.x下安装VNC
1.检查是否安装VNC rpm -q tigervnc tigervnc-server 2.安装X-Window yum check-update yum groupinstall "X W ...
- CentOS7.x安装VNC
VNC需要系统安装的有桌面,如果是生产环境服务器,安装时使用的最小化安装,那么进行下面操作安装GNOME 桌面. # 列出的组列表里有GNOME Desktop. yum grouplist #安装 ...
- 【VNCserver】Centos7.4安装VNC连接华为云或亚马逊云
1.1 文档背景 CentOS 7 / RHEL 7部署图形化界面 安装VNCserver实现linux系统云主机桌面化,通过普通用户实现桌面化操作 2. Vncserver服务端部署 2.1 安装 ...
随机推荐
- 高性能 TCP & HTTP 通信框架 HP-Socket v4.2.1
HP-Socket 是一套通用的高性能 TCP/UDP/HTTP 通信框架,包含服务端组件.客户端组件和 Agent 组件,广泛适用于各种不同应用场景的 TCP/UDP/HTTP 通信系统,提供 C/ ...
- C# 获取指定路径下的文件结构(树形结构)
namespace Vue.Content { public class FileNames { public int id { get; set; } public string text { ge ...
- Python课程第一天作业
一.第一题:简述编译型与解释型语言的区别,且分别列出你知道的哪些语言属于编译型,哪些属于解释型? 计算机是不能理解高级语言的,更不能直接执行高级语言,它只能直接理解机器语言,所以使用任何高级语言编写的 ...
- git 每次push和pull都需要提交密码
每次从远程仓库拉代码或者向远程仓库提交代码的时候需要输入密码的解决方法 执行 $ git config --global credential.helper store 结果: 查看C:\用户\用户名 ...
- Oracle常见错误:ORA-06550、ORA-00911、ORA-02085
ORA-06550:检查标点符号,如果是在写存储过程时候,切记每行每条语句都应该以“;”结束 ORA-00911: invalid character 包含中文报错 ORA-02085:数据库连接 X ...
- 用matplotlib.pyplot画简单的折线图,直方图,散点图
#coding=utf-8 """ 用matplotlib.pyplot画简单的折线图,直方图,散点图 """ import matplot ...
- Timer与TimerTask
Timer和TimerTask Timer是一种定时器工具,用来在一个后台线程计划执行指定任务.它可以计划执行一个任务一次或反复多次.TimerTask一个抽象类,它的子类代表一个可以被Timer计划 ...
- 再见:org.apache.catalina.connector.ClientAbortException: java.io.IOException: Connection reset by peer
这个问题我之前遇见多次了,今天又遇见了 2019-03-22 16:33:27.555 WebMvcConfigurer.java:144 ERROR - 接口 [/appservice/7za.ex ...
- 浏览器端时间循环与nodejs端时间循环的不同之处(宏任务与微任务)
浏览器端与node端都有宏任务与微任务的概念.字面意思上看宏任务就是耗时间比较长的任务,而微任务是耗时短的任务. 在浏览器端,宏任务包括setTimeout,setInterval,微任务则包括Pro ...
- 【读书笔记】Segment Routing基础