一、KVM 概述
虚拟化:在一台计算机上虚拟出多个逻辑的计算机,而且每个逻辑计算机,它可以是不同操作系统
虚拟化技术:可以扩大硬件容量,单个cpu模拟出多个cpu并行,允许一个平台上同时运行多个作系统,应用程序都可以在相互独立的空间内运行,而且互不影响。
- KVM 是 Kernel-based Virtual Machine 的缩写,是一种用于虚拟化的开源硬件虚拟化技术。它使用 Linux 内核的虚拟化模块,将物理服务器划分为多个虚拟机。
- KVM 允许虚拟机直接访问物理硬件资源,从而提供出色的性能和稳定性,同时还支持许多常见的操作系统和应用程序。
- KVM 使用了 QEMU (Quick Emulator) 作为其默认的虚拟机监控程序。
- 除此之外,KVM 还支持多种嵌入式和云计算场景,并且得到了广泛的应用。
KVM有一个内核模块叫 kvm.ko,只用于管理虚拟 CPU 和内存
Qemu 是纯软件实现的虚拟化模拟器,几乎可以模拟任何硬件设备,我们最熟悉的就是能够模拟一台能够独立运行操作系统的虚拟机,虚拟机认为自己和硬件打交道,但其实是和 Qemu 模拟出来的硬件打交道,Qemu 将这些指令转译给真正的硬件。
正因为 Qemu 是纯软件实现的,所有的指令都要经 Qemu 过一手,性能非常低,所以,在生产环境中,大多数的做法都是配合 KVM 来完成虚拟化工作,因为 KVM 是硬件辅助的虚拟化技术,主要负责 比较繁琐的 CPU 和内存虚拟化,而 Qemu 则负责 I/O 虚拟化,两者合作各自发挥自身的优势,相得益彰.
作为一个 Hypervisor,KVM 本身只关注虚拟机调度和内存管理这两个方面。IO 外设的任务交给 Linux 内核和 Qemu。
Libvirt 就是 KVM 的管理工具。管理虚拟机和虚拟化功能的软件,其实,Libvirt 除了能管理 KVM 这种 Hypervisor,还能管理 Xen,VirtualBox 等。
Libvirt 包含 3 个东西:后台 daemon 程序 libvirtd、API 库和命令行工具 virsh
1、libvirtd是服务程序,接收和处理 API 请求;
2、API 库使得其他人可以开发基于 Libvirt 的高级工具,比如 virt-manager,这是个图形化的 KVM 管理工具;
3、virsh 是我们经常要用的 KVM 命令行工具
二.KVM的基本特点和优势
(1)硬件虚拟化支持:KVM利用CPU的虚拟化扩展,可以实现将物理主机的处理能力划分给虚拟机,提供高效的硬件资源管理。
(2)完全虚拟化:KVM可以在虚拟机中运行未经修改的操作系统,实现对多种操作系统和应用程序的支持。
(3)性能优化:KVM的硬件虚拟化技术允许虚拟机直接访问物理硬件资源,降低了虚拟化的性能消耗,提供了接近原生性能的运行效果。
(4)弹性和可伸缩性:KVM支持动态添加、删除、调整虚拟机的资源,可以根据需求灵活配置虚拟机的CPU、内存和存储等资源。
(5)安全性:KVM采用严格的隔离机制,保护不同虚拟机之间的安全,防止一台虚拟机的故障对其他虚拟机造成影响。
(6)社区支持:KVM是一个开源项目,拥有庞大的社区支持,提供了丰富的文档和资源,可以帮助用户更好地理解和使用该技术。
kvm部署
使用的镜像CentOS-7版本
部署前需要打开cpu虚拟功能,并添加一块200G的硬盘
新建分区,硬盘所有大小分配到一个分区
[root@server ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
新的磁盘标签类型? msdos
警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
是/Yes/否/No? yes
(parted) unit
Unit? [compact]? MiB
(parted) mkpart
分区类型? primary/主分区/extended/扩展分区? primary
文件系统类型? [ext2]? xfs
起始点? 10MiB
结束点? 204790MiB
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 204800MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 10.0MiB 204790MiB 204780MiB primary
(parted)
挂载
[root@server ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=13105920 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=52423680, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=25597, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@server ~]# blkid /dev/sdb1
/dev/sdb1: UUID="00e54dd9-b7ba-432f-bdd8-d924ef5b0d22" TYPE="xfs"
[root@server ~]# mkdir /kvmdata
[root@server ~]# vim /etc/fstab
[root@server ~]# mount -a
[root@server ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 xfs 95G 3.7G 92G 4% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 174M 841M 18% /boot
tmpfs tmpfs 378M 12K 378M 1% /run/user/42
tmpfs tmpfs 378M 0 378M 0% /run/user/0
/dev/sdb1 xfs 200G 33M 200G 1% /kvmdata
[root@server ~]#
关闭selinux和防火墙
[root@server ~]# systemctl stop firewalld
[root@server ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@server ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@server ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
重启
部署yum源
[root@server ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2024-07-26 00:11:38-- https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 45.253.17.235, 45.253.17.234, 45.253.17.229, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|45.253.17.235|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[==========================================================================================>] 2,523 --.-K/s 用时 0.008s
2024-07-26 00:11:38 (296 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
[root@server ~]#
安装epel源,如果出现进程直接杀死
[root@server yum.repos.d]# yum -y install epel-release
已加载插件:fastestmirror, langpacks
/var/run/yum.pid 已被锁定,PID 为 24203 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:yum
内存: 24 M RSS (898 MB VSZ)
已启动: Fri Jul 26 00:13:29 2024 - 01:19之前
状态 :跟踪/停止,进程ID:24203
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:yum
内存: 24 M RSS (898 MB VSZ)
已启动: Fri Jul 26 00:13:29 2024 - 01:21之前
状态 :跟踪/停止,进程ID:24203
^C
Exiting on user cancel.
[root@server yum.repos.d]# kill -9 24203 // 杀死进程
[root@server yum.repos.d]# yum -y install epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
updates/7/x86_64/primary_db | 27 MB 00:00:18
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成
安装需要软件包
[root@server yum.repos.d]# yum -y install epel-release vim wget net-tools unzip zip gcc gcc-c++ qemu-kvm qemu-kvm-tools qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils libguestfs-tools
配置网络,因为虚拟机中的网络,我们一般是都和公司服务器处在同一网段的,所以我们需要把kvm的网卡配置成桥接模式
[root@server ~]# cd /etc/sysconfig/network-scripts/
[root@server network-scripts]# ls
ifcfg-ens33 ifdown-ib ifdown-ppp ifdown-tunnel ifup-ib ifup-plusb ifup-Team network-functions
ifcfg-lo ifdown-ippp ifdown-routes ifup ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6
ifdown ifdown-ipv6 ifdown-sit ifup-aliases ifup-ipv6 ifup-ppp ifup-tunnel
ifdown-bnep ifdown-isdn ifdown-Team ifup-bnep ifup-isdn ifup-routes ifup-wireless
ifdown-eth ifdown-post ifdown-TeamPort ifup-eth ifup-plip ifup-sit init.ipv6-global
[root@server network-scripts]# cp ifcfg-ens33 ifcfg-br0
[root@server network-scripts]# vim ifcfg-ens33
[root@server network-scripts]# cat ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=none
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE=br0
[root@server network-scripts]# cat ifcfg-br0
TYPE=Bridge
BOOTPROTO=none
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.100.10
PREFIX=24
GATEWAY=192.168.100.254
DNS1=114.114.114.114
// 启动服务
[root@server network-scripts]# systemctl restart network
[root@server network-scripts]# systemctl restart NetworkManager
[root@server network-scripts]# ifdown ens33
成功断开设备 'ens33'。
[root@server network-scripts]# ifup ens33
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
[root@server network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether 00:0c:29:79:11:39 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:f4:c8:71 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:f4:c8:71 brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:79:11:39 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.10/24 brd 192.168.100.255 scope global noprefixroute br0
valid_lft forever preferred_lft forever
inet6 fe80::c48:58ff:fe84:7065/64 scope link
valid_lft forever preferred_lft forever
重启libvirtd服务
[root@server ~]# systemctl restart libvirtd
[root@server ~]# systemctl enable libvirtd
查看kvm模块是否加载
[root@server ~]# lsmod | grep kvm
kvm_amd 2177212 0
kvm 586948 1 kvm_amd
irqbypass 13503 1 kvm
验证安装结果
[root@server ~]# virsh -c qemu:///system list
Id 名称 状态
----------------------------------------------------
[root@server ~]# virsh --version
4.5.0
[root@server ~]# virt-install --version
1.5.0
将qemu-kvm这个命令做一个软链接到/usr/bin/qemu-kvm,普通用户就有权执行命令了,管理kvm
[root@server ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
[root@server ~]# ll /usr/bin/qemu-kvm
lrwxrwxrwx 1 root root 21 7月 26 00:59 /usr/bin/qemu-kvm -> /usr/libexec/qemu-kvm
查看网桥信息
[root@server ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29791139 no ens33
virbr0 8000.525400f4c871 yes virbr0-nic
创建web界面
KVM管理界面安装
Kvm的web界面是由webvirtmgr程序提供的
安装所需要的依赖包
[root@server ~]# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx python-devel
从github上下载webvirtmgr代码
[root@server ~]# cd /usr/local/src/
[root@server src]# git clone http://github.com/retspen/webvirtmgr.git
正克隆到 'webvirtmgr'...
fatal: unable to access 'http://github.com/retspen/webvirtmgr.git/': Encountered end of file
下载不下来去在如下目录下添加一个文本hosts
此时已经下载完成
[root@server src]# git clone http://github.com/retspen/webvirtmgr.git
正克隆到 'webvirtmgr'...
remote: Enumerating objects: 5614, done.
remote: Total 5614 (delta 0), reused 0 (delta 0), pack-reused 5614
接收对象中: 100% (5614/5614), 2.97 MiB | 1.86 MiB/s, done.
处理 delta 中: 100% (3606/3606), done.
[root@server src]#
进到下载好webvirtmgr中的安装webvirtmgr
[root@server webvirtmgr]# pip --trusted-host pypi.python.org install -r requirements.txt
Collecting django==1.5.5 (from -r requirements.txt (line 1))
检查sqlite3是否安装
[root@server webvirtmgr]# python
Python 2.7.5 (default, Nov 14 2023, 16:14:06)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> exit()
初始化账号信息
[root@server ~]# cd /usr/local/src/webvirtmgr
[root@server webvirtmgr]# python manage.py syncdb
WARNING:root:No local_settings file found.
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table servers_compute
Creating table instance_instance
Creating table create_flavor
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes // 是否设置超级管理员
Username (leave blank to use 'root'): // 指定超级管理员账号用户名,默认留白为root
Email address: admin@example.com // 设置超级管理员邮箱
Password: // 设置管理员密码
Password (again): // 再次输入管理员密码
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)
拷贝web网页到指定目录
[root@server ~]# mkdir /var/www
[root@server ~]# cp -r /usr/local/src/webvirtmgr/ /var/www/
[root@server ~]# chown -R nginx.nginx /var/www/webvirtmgr/
生成一对公钥与私钥,由于这里webvirtmgr和kvm服务部署在同一台主机中,所以这里本地信任。如果kvm部署在其他机器上的时候,那么就需要把公钥发送到kvm主机中
[root@server ~]# ssh-keygen
[root@server ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.100.10
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.100.10 (192.168.100.10)' can't be established.
ECDSA key fingerprint is SHA256:G7hz/6PMQHqIpk1vMB490+Mi/Je1tOSJCeEr1A/oGd4.
ECDSA key fingerprint is MD5:1f:30:a0:f4:11:f9:4a:6a:dd:36:c2:9a:6e:a6:39:a2.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.100.10's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.100.10'"
and check to make sure that only the key(s) you wanted were added.
[root@server ~]#
配置端口转发
localhost:8000:localhost:8000 -L localhost:6080:localhost:60
查看端口信息
[root@server ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:6000 *:*
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:6080 *:*
LISTEN 0 128 127.0.0.1:8000 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::6000 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 ::1:6080 :::*
LISTEN 0 128 ::1:8000
配置nginx
server {
listen 80;
server_name _;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root html;
index index.html index.html
}
配置nginx虚拟主机
[root@server nginx]# cat /etc/nginx/conf.d/webvirtmgr.conf
erver {
listen 80 default_server;
server_name $hostname;
#access_log /var/log/nginx/webvirtmgr_access_log;
location /static/ {
root /var/www/webvirtmgr/webvirtmgr;
expires max;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $remote_addr;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M;
}
}
确保bind绑定本机的8000端口
vim /var/www/webvirtmgr/conf/gunicorn.conf.py
bind = '127.0.0.1:8000' //确保此处绑定的是本机的8000端口,这个在nginx配置中定义了,被代理的端口
backlog = 2048
重启nginx服务,查看端口是否开启
[root@server ~]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
[root@server ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:6000 *:*
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:6080 *:*
LISTEN 0 128 127.0.0.1:8000 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::6000 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 ::1:6080 :::*
LISTEN 0 128 ::1:8000
设置supervisor
vim /etc/supervisord.conf
// 在文件最后添加如下信息
[program:webvirtmgr]
command=/usr/bin/python2 /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx
[program:webvirtmgr-console]
command=/usr/bin/python2 /var/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx
启动supervisor并设置开机自启
[root@server ~]# systemctl restart supervisord.service
[root@server ~]# systemctl enable supervisord.service
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
配置nginx用户
[root@server ~]# su - nginx -s /bin/bash
-bash-4.2$ ssh-keygen
-bash-4.2$ touch ~/.ssh/config
-bash-4.2$ vim ~/.ssh/config
-bash-4.2$ cat ~/.ssh/config // 添加两行信息
StrictHostKeyChecking=no
UserKnownHostsFile=/dev/null
-bash-4.2$ chmod 0600 ~/.ssh/config
-bash-4.2$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.100.10 // 免密钥
-bash-4.2$ ssh root@192.168.100.10
Warning: Permanently added '192.168.100.10' (ECDSA) to the list of known hosts.
Last login: Fri Jul 26 09:43:54 2024 from server.example.com
[root@server ~]# exit
登出 // 可以登录
[root@server ~]# vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[root@server ~]# cat /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[Remote libvirt SSH access]
Identity=unix-user:root
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
[root@server ~]# chown -R root.root /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
启动nginx和libvirtd
[root@server ~]# systemctl restart libvirtd
[root@server ~]# systemctl restart nginx
KVM web界面管理
使用浏览器访问192.168.100.10,服务器出现了accept:Too many open files
解决方法:
修改nginx配置文件
[root@server ~]# vim /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
worker_rlimit_nofile 655350; //添加此行
// 对系统参数进行设置
[root@server ~]# vim /etc/security/limits.conf
//在文件最末尾写入
* soft nofile 655350
* hard nofile 655350
// 重启服务,重读文件
[root@server ~]# sysctl -p
[root@server ~]# systemctl restart nginx
在使用浏览器访问
使用root之前设置的密码登录
添加ssh连接
点击红色框框的地方
创建虚拟机
新建存储
使用filezilla上传镜像,将镜像文件上传到服务器的/kvmdata目录下存放
添加网络
创建新的虚拟机
/
/
/
启动出现超时
解决方法
如果出现了连接超时,则做如下步骤,如果没有出现,则不管
解决方法:
//安装novnc,并通过novnc_server启动一个vnc
[root@server ~]# yum -y install novnc
[root@server ~]# chmod +x /etc/rc.d/rc.local
[root@server ~]# vim /etc/rc.d/rc.local
//在最末尾加入如下行
nohup novnc_server 192.168.100.100:5920 &
[root@server ~]# . /etc/rc.d/rc.local
解决完成以后在开启虚拟机
创建虚拟机成功