不做过多介绍了,下面直接记录下centos7系统下安装配置vncserver的操作记录

0)更改为启动桌面或命令行模式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
获取当前系统启动模式
[root@localhost ~]# systemctl get-default
multi-user.target
 
查看配置文件
[root@localhost ~]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3          //命令行模式
# graphical.target: analogous to runlevel 5          //图形界面模式
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
 
[root@localhost ~]# systemctl set-default graphical.target           //由命令行模式更改为图形界面模式
[root@localhost ~]# systemctl set-default multi-user.target          //由图形界面模式更改为命令行模式
 
[root@localhost ~]# systemctl get-default
graphical.target

1)关闭防火墙
centos的防火墙是firewalld,关闭防火墙的命令
[root@localhost ~]# systemctl stop firewalld.service #停止firewall
[root@localhost ~]# systemctl disable firewalld.service #禁止firewall开机启动

[root@localhost ~]# setenforce 0 
[root@localhost ~]# getenforce 
[root@localhost ~]# cat /etc/sysconfig/selinux 
SELINUX=disabled
SELINUXTYPE=targeted

2)安装软件:
[root@localhost ~]# yum update
[root@localhost ~]# yum groupinstall "GNOME Desktop" "X Window System" "Desktop" 
[root@localhost ~]# yum install tigervnc-server tigervnc vnc vnc-server

3)配置vnc连接
[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service 
修改/etc/systemd/system/vncserver@:1.service
找到这一行
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid

这里直接用root 用户登录,所以我替换成
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

如果是其他用户的话比如john替换如下
ExecStart=/sbin/runuser -l john -c "/usr/bin/vncserver %i"
PIDFile=/home/john/.vnc/%H%i.pid

由于直接root用户登录,所以配置如下:
[root@localhost ~]# cat /etc/systemd/system/vncserver@:1.service
.........
[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 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 || :'

[Install]
WantedBy=multi-user.target

为VNC设密码
[root@localhost ~]# vncpasswd
123456

[root@localhost ~]# vim /etc/libvirt/qemu.conf 
vnc_password = "123456"
vnc_listen = "0.0.0.0"

重加载 systemd
[root@localhost ~]# systemctl daemon-reload

启动vnc
[root@localhost ~]# systemctl enable vncserver@:1.service
[root@localhost ~]# systemctl start vncserver@:1.service

注意,此处关闭了防火墙
如果防火墙开了,需要开通一下规则:
[root@localhost ~]# firewall-cmd --permanent --add-service vnc-server
[root@localhost ~]# systemctl restart firewalld.service
如果是iptable,则需要在/etc/sysconfig/iptables里添加:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT

关闭vnc连接
[root@localhost ~]# /usr/bin/vncserver -kill :1

测试vnc连接:
[root@localhost ~]# novnc_server --vnc 192.168.1.8:5901 --listen 6081
Warning: could not find self.pem
Starting webserver and WebSockets proxy on port 6081
WebSocket server settings:
- Listen on :6081
- Flash security policy server
- Web server. Web root: /usr/share/novnc
- No SSL/TLS support (no cert file)
- proxying from :6081 to 192.168.1.8:5901

Navigate to this URL:

http://kvm-server:6081/vnc.html?host=kvm-server&port=6081 #http访问方式

Press Ctrl-C to exit

由于kvm-server的主机名对于ip是112.112.113.56,所以在浏览器里输入:
http://112.112.113.56:6081/vnc.html?host=112.112.113.56&port=6081

1
2
3
4
5
6
7
8
9
10
也可以在本地windows机器上安装vnc viewer,远程访问
在windows下安装vnc客户端,
下载地址:https://pan.baidu.com/s/1hrSIr4K
提取密码:dqdt
    
VNC远程连接信息(下面ip是VNC服务端的地址):
VNC Server: 112.112.113.56:5901
Encrytion:Let VNC Server choose
    
然后输入vncpasswd的密码即可完成VNC远程连接!
***************当你发现自己的才华撑不起野心时,就请安静下来学习吧***************

centos7 部署vnc的更多相关文章

  1. Linux Centos7.x下安装部署VNC的实操详述

    VNC (Virtual Network Console)是虚拟网络控制台的缩写.它 是一款优秀的远程控制工具软件,由著名的AT&T的欧洲研究实验室开发的.VNC 是在基于 UNIX和 Lin ...

  2. [原]CentOS7部署osm2pgsql

    转载请注明原作者(think8848)和出处(http://think8848.cnblogs.com) 部署Postgresql和部署PostGis请参考前两篇文章 本文主要参考GitHub上osm ...

  3. CentOS6部署VNC服务端

    VNC (Virtual Network Computer)是虚拟网络计算机的缩写.VNC 是在基于 UNIX 和 Linux 操作系统的免费的开源软件,远程控制能力强大,高效实用,其性能可以和 Wi ...

  4. centos7 部署ssserver

    centos7 部署shadowsocks服务端 为什么要选centos7? 以后centos7 肯定是主流,在不重要的环境还是尽量使用新系统吧 centos7 的坑 默认可能会有firewall 或 ...

  5. Centos6.9部署vnc

    Centos部署vnc   [root@etl ~]# vncserver -kill :1 命令: service vncserver restart chkconfig --list vncser ...

  6. centos7 部署 docker compose

    =============================================== 2019/4/10_第1次修改                       ccb_warlock == ...

  7. centos7 部署 docker ce

    =============================================== 2019/4/9_第1次修改                       ccb_warlock === ...

  8. centos7 部署 open-falcon 0.2.0

    =============================================== 2019/4/29_第3次修改                       ccb_warlock 更新 ...

  9. centos7 部署 docker、shipyard

    =============================================== 2019/4/9_第3次修改                       ccb_warlock 更新说 ...

随机推荐

  1. 🍓 vue循环渲染本地图片不显示? 🍓

    teamList: [{ title: '大数据拍牌', imgUrl: './img/data.jpg', introduce: '5星服务:强烈推荐', cost: '15000', bail: ...

  2. noj 算法 八数码问题

    描述 在九宫格里放在1到8共8个数字还有一个是空格,与空格相邻的数字可以移动到空格的位置,问给定的状态最少需要几步能到达目标状态(用0表示空格):1 2 34 5 67 8 0   输入 输入一个给定 ...

  3. 计算机基础 & python基础

    五大组成部分 控制器 运算器(数学运算+逻辑运算) 存储器(存取数据) 输入设备(键盘.鼠标等) 输出设备(显示器.打印机等) CPU CPU=运算器+控制器 CPU的分类: 精简指令集(RISC): ...

  4. springboot集成mybatis源码分析(一)

    本篇文章只是简单接受使用,具体源码解析请看后续文章 1.新建springboot项目,并导入mybatis的pom配置 配置数据库驱动和mybatis dependency <dependenc ...

  5. Felx布局基础教程

    网页布局即layout是css的一个重点应用. 布局的传统解决方案,基于盒状模型,依赖 display 属性 + position属性 + float属性.它对于那些特殊布局非常不方便,比如,垂直居中 ...

  6. Java Spring Boot VS .NetCore (八) Java 注解 vs .NetCore Attribute

    Java Spring Boot VS .NetCore (一)来一个简单的 Hello World Java Spring Boot VS .NetCore (二)实现一个过滤器Filter Jav ...

  7. JavaScript我学之八善变的this---函数执行上下文

    本文是金旭亮老师网易云课堂的课程笔记,记录下来,以供备忘. 函数执行上下文 当函数运行时,通过this,函数可以获取它运行所需的外界环境的相关信息(比如某变量的值,另一个对象的引用等). this引用 ...

  8. IDEA上创建 Maven SpringBoot + zookeeper +dubbo 实例

    概述 首先声明,本文是学习总结类型的博客内容,如有雷同纯属学习.本位主要结合zookeeper和dubbo做个简单实例.目前来说,一般网站架构随着业务的发展,逻辑越来越复杂,数据量越来越大,交互越来越 ...

  9. 02.Control

    01.if ''' 제어문 = 조건문(if) + 반복문(while, for) 조건문 기본 형식1) python 블럭 if 조건식 : 실행문 실행문 cf) c언어 블럭 if 조건식 { ...

  10. ssh报错 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

    今天登陆远程主机的时候,出现如下的报错信息 ssh 10.0.0.1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WAR ...