在vmware上安装kvm(debian)

简介:
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
我的博客已迁移到xdoujiang.com请去那边和我交流
kvm全称(Kernel-based Virtual Machine),是一个开源的系统虚拟化模块,
自Linux 2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,
所以相对于Xen,其核心源码很少。KVM目前已成为学术界的主流VMM之一。
KVM的虚拟化需要硬件支持(如Intel VT技术或者AMD V技术)。是基于硬件的完全虚拟化。
而Xen早期则是基于软件模拟的Para-Virtualization,新版本则是基于硬件支持的完全虚拟化。
但Xen本身有自己的进程调度器,存储管理模块等,所以代码较为庞大。
广为流传的商业系统虚拟化软件VMware ESX系列是基于软件模拟的Full-Virtualization。
一、基础环境
1、版本
cat  /etc/debian_version 
7.8
 
2、内核
uname  -r
3.2.0-4-amd64
 
3、涉及ip
10.1.10.117(debian7.8)
10.1.10.131(windows)
 
4、虚拟机
vmware 11
内存1G
 
二、kvm安装
1、在vmware设置里打开支持虚拟化
在虚拟化引擎这边选择Intel VT-x /EPT 或AMD-V /RVI ,并在第二个方框内打钩

wKioL1WLSrWiYoHqAAIOve2eoWk069.jpg

1
2
2、进入系统后查看下是否支持了
egrep  '(vmx|svm)'  --color  /proc/cpuinfo

wKioL1WLS0WT3s3qAAG1ykwDoo0726.jpg

1
看到有vmx说明硬件支持kvm安装
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
3、安装kvm所需要的包并查看kvm模块是否加载成功
1)安装包
apt-get -y  install  libvirt-bin
apt-get -y  install  bridge-utils 
apt-get -y  install  qemu-kvm
apt-get -y  install  virtinst
PS:相关包说明
libvirt-bin - programs  for  the libvirt library
bridge-utils - Utilities  for  configuring the Linux Ethernet bridge(brctl桥接命令)
qemu-kvm - Full virtualization on x86 hardware
virtinst - Programs to create and clone virtual machines(virt- install  virt-clone等命令)
2)查看kvm模块是否加载成功
lsmod | grep  kvm
kvm_intel             122053  3 
kvm                   291965  1 kvm_intel
 
4、配置网络
1)查看当前桥接情况
brctl show
bridge name    bridge  id         STP enabled    interfaces
2)修改配置
cat  /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
#auto eth0 
#iface eth0 inet static 
#address 10.1.10.117 
#netmask 255.255.255.0 
#gateway 10.1.10.254
auto br0
iface br0 inet static
address 10.1.10.117
netmask 255.255.255.0
gateway 10.1.10.254
bridge_ports eth0
bridge_stp off
bridge_waitport 0
bridge_fd 0
3)使用ifup命令将br0网口启来
ifup br0
Waiting  for  a max of 0 seconds  for  eth0 to become available.
Waiting  for  br0 to get ready (MAXWAIT is 2 seconds).
4)再次查看桥接情况
brctl show
bridge name    bridge  id         STP enabled    interfaces
br0        8000.000c29c887a1    no        eth0
5)修改内核参数并使永久生效
/etc/sysctl .conf添加到最后
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
sysctl -p
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
 
5、创建磁盘镜像文件
1)创建目录
mkdir  /opt/kvmimage  -p
2)使用qemu-img命令创建
qemu-img create -f raw  /opt/kvmimage/debian7 .raw 10G
Formatting  '/opt/kvmimage/debian7.raw' fmt =raw size=10737418240 
3)查看
qemu-img info  /opt/kvmimage/debian7 .raw 
image:  /opt/kvmimage/debian7 .raw
file  format : raw
virtual size: 10G (10737418240 bytes)
disk size: 0
 
6、使用virt- install 命令创建系统
1)virt- install  --virt- type  kvm --name debian7 -- ram  256 --vcpus=1 --cdrom= /opt/debian-7 .8.0-amd64-CD-1.iso --network bridge=br0 --graphics vnc,listen=10.1.10.117,port=5900 --noautoconsole --os- type =linux --disk path= /opt/kvmimage/debian7 .raw --debug
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (cli:226) Launched with  command  line:
/usr/bin/virt-install  --virt- type  kvm --name debian7 -- ram  256 --vcpus=1 --cdrom= /opt/debian-7 .8.0-amd64-CD-1.iso --network bridge=br0 --graphics vnc,listen=10.1.10.117,port=5900 --noautoconsole --os- type =linux --disk path= /opt/kvmimage/debian7 .raw --debug
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (cli:332) Requesting libvirt URI default
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (cli:334) Received libvirt URI qemu: ///system
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (virt- install :259) Requesting virt method  'default' , hv  type  'kvm' .
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (virt- install :469) Received virt method  'hvm'
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (virt- install :470) Hypervisor name is  'kvm'
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (DistroInstaller:210) DistroInstaller location is a  local  file /path /opt/debian-7 .8.0-amd64-CD-1.iso
[Thu, 21 May 2015 00:44:16 virt- install  2599] DEBUG (virt- install :623) Guest.has_install_phase: True
Starting  install ...
[Thu, 21 May 2015 00:44:17 virt- install  2599] DEBUG (virt- install :707) Domain state after  install : 1
Domain installation still  in  progress. You can reconnect to 
the console to complete the installation process.
参数说明:
--name          新客户虚拟机实例名字
--virt- type      类型
-- ram            以M为单位指定分配给虚拟机的内存大小
--vcpus         虚拟机的虚拟CPU数
--cdrom         对应全虚拟化客户机,文件或设备作为一个虚拟化CD-ROM设备使用,可以是ISO映像路径或者一个CDROM设备,它也可以是一个能够提取/访问最小引导ISO映像的URL
--network       连接客户机到主机网络
--graphics      在客户机中设置一个虚拟控制台并且将其导出为一个VNC服务
--noautoconsole 使用本选项指定不自动试图连接到客户机控制台
--os- type        针对一类操作系统优化虚拟机配置
--disk path     客户机存储
2)查看kvm进程
ps  aux| grep  kvm
root        580  0.0  0.0      0     0 ?        S<   00:15   0:00 [kvm-irqfd-clean]
103        5990 29.0  1.9 527476 20220 ?        Sl   08:34   0:01  /usr/bin/kvm  -S -M pc-1.1 - enable -kvm -m 256 -smp 1,sockets=1,cores=1,threads=1 -name debian7 -uuid 576f2558-10c5-670a-0013-d0f8297de467 -no-user-config -nodefaults -chardev socket, id =charmonitor,path= /var/lib/libvirt/qemu/debian7 .monitor,server,nowait -mon chardev=charmonitor, id =monitor,mode=control -rtc base=utc -no-reboot -no- shutdown  -device piix3-usb-uhci, id =usb,bus=pci.0,addr=0x1.0x2 -drive  file = /opt/kvmimage/debian7 .raw, if =none, id =drive-ide0-0-0, format =raw -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0, id =ide0-0-0,bootindex=2 -drive  file = /opt/debian-7 .8.0-amd64-CD-1.iso, if =none, id =drive-ide0-1-0, readonly =on, format =raw -device ide- cd ,bus=ide.1,unit=0,drive=drive-ide0-1-0, id =ide0-1-0,bootindex=1 -netdev tap,fd=20, id =hostnet0 -device rtl8139,netdev=hostnet0, id =net0,mac=52:54:00:23:b3:c2,bus=pci.0,addr=0x3 -chardev pty, id =charserial0 -device isa-serial,chardev=charserial0, id =serial0 -vnc 10.1.10.117:0 -vga cirrus -device virtio-balloon-pci, id =balloon0,bus=pci.0,addr=0x4
root       5999  0.0  0.0      0     0 ?        S<   08:34   0:00 [kvm-pit-wq]
root       6004  0.0  0.0   7836   880 pts /0     S+   08:34   0:00  grep  --color=auto kvm
3)查看kvm端口
netstat  -tupnl| grep  kvm
tcp        0      0 10.1.10.117:5900        0.0.0.0:*               LISTEN      2662 /kvm 
4)使用virsh查看机器列表和状态       
virsh --connect qemu: ///system  list --all
  Id    Name                           State
----------------------------------------------------
  1     debian7                        running
5)运行状态说明
running  虚拟机正在运行在cpu上
idel     虚拟机是闲置的,没有在运行,在等待IO或者休眠时虚拟机会进入这种状态
paused   虚拟机处于暂停状态,一般情况下是被admin运行了virsh   suspend才会处于这种状态,但是仍然消耗资源,只不过不被超级管理程序调度而已。
shutdown  虚拟机在关闭过程中
shut off 虚拟机没有运行,已经完全关闭
crashed  虚拟机崩溃
dying    虚拟机处于垂死的状态,但是又没完全关闭或崩溃 
6)查看下新建的虚拟机基本信息
virsh dominfo debian7
Id:             2
Name:           debian7
UUID:           576f2558-10c5-670a-0013-d0f8297de467
OS Type:        hvm
State:          running
CPU(s):         1
CPU  time :       1.7s
Max memory:     262144 KiB
Used memory:    262144 KiB
Persistent:      yes
Autostart:      disable
Managed save:   no
 
三、客户端连接
1、先查看vnc
virsh vncdisplay debian7
10.1.10.117:0
 
2、windows(10.1.10.131)
1)安装软件
TightVNC Version 2.7.7

wKiom1WLSsHjai7dAAGK8qWXV40136.jpg

wKioL1WLTI6igEczAAJxBQfKZqc637.jpg

1
四、安装完成后结果

wKiom1WLSuyw4LXnAAJUXoa2r8w484.jpg

1
2
3
五、参考文章
http: //xmodulo .com /use-kvm-command-line-debian-ubuntu .html
http: //wiki .libvirt.org /page/Networking










本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1665296,如需转载请自行联系原作者
目录
相关文章
|
7月前
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
1349 69
|
11月前
|
Linux 网络安全 虚拟化
阿里云开发者分享VMware17 Pro保姆级安装秘籍,详细步骤助你轻松搞定安装!
这是一篇超详细的VMware 17 Pro虚拟机下载与安装教程。VMware 17 Pro支持多操作系统模拟运行,适合开发、测试及教育使用。文章涵盖从下载到安装的全流程,包括解压安装包、接受协议、配置安装路径等步骤,并提供虚拟机优化(如安装VMware Tools、配置快照和共享文件夹)及使用指南。同时,针对常见问题如虚拟化未启用或软件阻止启动,提供了具体解决方案,帮助用户顺利部署和使用虚拟机环境。
5912 36
阿里云开发者分享VMware17 Pro保姆级安装秘籍,详细步骤助你轻松搞定安装!
|
7月前
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
629 78
|
5月前
|
Ubuntu 关系型数据库 MySQL
MySQL包安装 -- Debian系列(离线DEB包安装MySQL)
本文详细介绍了在Ubuntu 24.04、22.04、20.04及Debian 12系统上,通过离线DEB包安装MySQL 8.0和8.4版本的完整步骤。涵盖下载地址、依赖处理、dpkg安装顺序、配置方法及服务启动验证,确保用户可顺利部署MySQL数据库。
2221 0
MySQL包安装 -- Debian系列(离线DEB包安装MySQL)
|
5月前
|
运维 Ubuntu 关系型数据库
MySQL包安装 -- Debian系列(Apt资源库安装MySQL)
本文介绍了在Debian系列系统(如Ubuntu、Debian 11/12)中通过APT仓库安装MySQL 8.0和8.4版本的完整步骤,涵盖添加官方源、配置国内镜像、安装服务及初始化设置,并验证运行状态,适用于各类Linux运维场景。
1710 0
MySQL包安装 -- Debian系列(Apt资源库安装MySQL)
|
8月前
|
编解码 网络协议 网络安全
OpenWrt x86 虚拟机VMware ESXi安装
OpenWrt x86 虚拟机VMware ESXi安装
|
8月前
|
运维 Linux 虚拟化
VMware虚拟机安装教程,Windows下安装VMware虚拟机,附VMware下载,Windows各版本系统镜像下载
虚拟机技术允许一台物理机运行多个操作系统,提升资源利用率,节省成本。通过快照、克隆等功能,实现系统快速恢复与复制,提高运维效率。本文详细介绍VMware虚拟机的安装步骤、Windows镜像下载及系统安装激活流程,适合初学者快速入门。
9701 0
|
10月前
|
人工智能 安全 虚拟化
企业级Win11纯净部署指南|VMware虚拟机安装+GPT分区优化+绕过限制详解(小白必看)
Windows 11 是微软推出的新一代操作系统,以其直观交互和 AI 技术为核心升级亮点。界面采用圆角设计与居中任务栏布局,支持多窗口贴靠分屏、虚拟桌面功能,大幅提升多任务处理效率。系统深度集成了 Copilot 智能助手,提供语音写作、照片编辑等便捷功能,并通过 DirectStorage 和 DirectX 12 Ultimate 技术优化游戏体验。本文详细介绍 Windows 11 的下载、U盘制作及安装步骤,帮助用户快速上手全新系统。
1899 37
|
9月前
|
Ubuntu Linux Shell
Linux环境下VSCode快速安装终极指南:debian/ubuntu/linux平台通用
以上就是在Linux环境下安装VSCode的终极指南,抛开繁复的专业词汇,以平易近人的文字、形象生动的比喻让你轻松学会这一过程。别忘了,你的小伙伴VSCode已经在应用菜单里等你了!
2704 23
|
12月前
|
Ubuntu 安全 调度
在Ubuntu下安装Debian包:dpkg与apt命令的深度解构。
安装Debian包的知识,就像掌握了海上的航行技术,虽然起初会让人感到陌生甚至困惑,但只要你积累熟练,就能在Ubuntu的世界里畅游无阻。就像每一位成功的航海家,掌握好这些工具,去探索属于你的Ubuntu新世界吧!
498 21