本文主要讲述的是通过vnc方式访问虚拟机不是在kvm虚拟机安装配置vnc,通过虚拟主机的IP地址与端口进行访问,kvm虚拟化对vnc的支持相对比较好,在虚拟主机上配置vnc访问虚拟机也是多提供一种方式访问虚拟机,以下是相关的配置步骤:
1,修改qemu.conf配置文件
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
30
|
[root@KVM qemu]
# vi /etc/libvirt/qemu.conf
# Master configuration file for the QEMU driver.
# All settings described here are optional - if omitted, sensible
# defaults are used.
# VNC is configured to listen on 127.0.0.1 by default.
# To make it listen on all public interfaces, uncomment
# this next option.
#
# NB, strong recommendation to enable TLS + x509 certificate
# verification when allowing public access
#
vnc_listen =
"0.0.0.0"
# Enable this option to have VNC served over an automatically created
# unix socket. This prevents unprivileged access from users on the
# host machine, though most VNC clients do not support it.
#
# This will only be enabled for VNC configurations that do not have
# a hardcoded 'listen' or 'socket' value. This setting takes preference
# over vnc_listen.
#
#vnc_auto_unix_socket = 1
# Enable use of TLS encryption on the VNC server. This requires
# a VNC client which supports the VeNCrypt protocol extension.
# Examples include vinagre, virt-viewer, virt-manager and vencrypt
# itself. UltraVNC, RealVNC, TightVNC do not support this
#
# It is necessary to setup CA and issue a server certificate
# before enabling this.
#
#vnc_tls = 1
|
说明1:vnclisten默认绑定127.0.0.1 在配置文件里指定VNC 绑定0.0.0.0IP,就不用在安装kvm虚拟机时指定vnclisten参数了。
说明2:在虚拟主机上有很多个虚拟机的时候,需要指定每个虚拟机的端口。
2,修改虚拟机的配置文件添加如下配置:
<graphics type='vnc' port='5913' autoport='no' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
[root@KVM qemu]# virsh edit hadoop3
3,启动并测试VNC,查看VNC端口
1
|
[root@KVM qemu]
# netstat -lntp |grep 59*
|
最后使用vnc登录的效果如下图:
备注:第一次在使用vnc访问虚拟机的时候会出现一闪就不见了的问题?具体的解决方法如下:
依次打开vnc客户端--->依次点击option--->Advanced--->Expert--->找到ColourLevel,默认的值是pal8,修改为rgb222或full.,见下图一图二:1,2,3
本文转自 lqbyz 51CTO博客,原文链接:http://blog.51cto.com/liqingbiao/1741103