KVM虚拟化笔记(二)------kvm虚拟机Linux系统安装

简介:

1,在根目录下创建images目录,然后依次创建iso和test。其中ISO目录是存放ISO镜像的,test是存放虚拟机的主机名的,然后把Linux安装镜像的iso文件,上传到iso文件夹里

1
2
[root@KVM ~] # mkdir -p /images/iso
[root@KVM ~] # mkdir -p /images/test
1
2
3
[root@KVM ~] # ll /data/iso/
total 407556
-rw-r--r-- 1 qemu qemu 417333248 Aug  5 09:11 CentOS-6.5-x86_64-minimal.iso

2,安装Linux虚拟主机:

 a)安装raw磁盘格式的虚拟机:

1
[root@KVM images] #virt-install --name hadoop2  --ram 1024 --vcpus 1 --disk path=/images/test/hadoop2.img,size=10    --network bridge=br0,model=virtio --noautoconsole --accelerate  --vnc --vncport=5912 --vnclisten=0.0.0.0  --cdrom /images/iso/CentOS-6.5-x86_64-minimal.iso -d

  b)安装qcow2格式的磁盘(空间动态增长),首先要先创建qcow2格式的磁盘。

1
2
3
[root@KVM  test ] # qemu-img create -f qcow2 hadoop3.img 10G
Formatting  'hadoop3.img' fmt =qcow2 size=10737418240 encryption=off cluster_size=65536 
[root@KVM  test ] # virt-install --name=hadoop3 --ram 512 --vcpus=1 --disk path=/images/test/hadoop3.img,format=qcow2,size=7,bus=virtio --accelerate --cdrom /images/iso/CentOS-6.5-x86_64-minimal.iso -d --vnc --vncport=5913   --network network:default --noautoconsole

具体的安装信息,如下:

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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
[root@KVM  test ] # qemu-img create -f qcow2 hadoop3.img 10G
Formatting  'hadoop3.img' fmt =qcow2 size=10737418240 encryption=off cluster_size=65536 
[root@KVM  test ] # virt-install --name=hadoop3 --ram 512 --vcpus=1 --disk path=/images/test/hadoop3.img,format=qcow2,size=7,bus=virtio --accelerate --cdrom /images/iso/CentOS-6.5-x86_64-minimal.iso -d --vnc --vncport=5913   --network network:default --noautoconsole
Tue, 02 Feb 2016 14:12:36 DEBUG    Launched with  command  line:
/usr/sbin/virt-install  --name=hadoop3 -- ram  512 --vcpus=1 --disk path= /images/test/hadoop3 .img, format =qcow2,size=7,bus=virtio --accelerate --cdrom  /images/iso/CentOS-6 .5-x86_64-minimal.iso -d --vnc --vncport=5913 --network network:default --noautoconsole
Tue, 02 Feb 2016 14:12:36 DEBUG    Requesting libvirt URI default
Tue, 02 Feb 2016 14:12:36 DEBUG    Received libvirt URI qemu: ///system
Tue, 02 Feb 2016 14:12:36 DEBUG    Requesting virt method  'default' , hv  type  'default' .
Tue, 02 Feb 2016 14:12:36 WARNING  KVM acceleration not available, using  'qemu'
Tue, 02 Feb 2016 14:12:36 DEBUG    Received virt method  'hvm'
Tue, 02 Feb 2016 14:12:36 DEBUG    Hypervisor name is  'qemu'
Tue, 02 Feb 2016 14:12:36 DEBUG    --graphics compat generated: vnc,port=5913
Tue, 02 Feb 2016 14:12:36 DEBUG    DistroInstaller location is a  local  file /path /images/iso/CentOS-6 .5-x86_64-minimal.iso
Tue, 02 Feb 2016 14:12:36 DEBUG    Guest.has_install_phase: True
Starting  install ...
Tue, 02 Feb 2016 14:12:36 DEBUG    Generated  install  XML: 
<domain  type = 'qemu' >
   <name>hadoop3< /name >
   <uuid>ae9def17-b45b-f9ea-4ff9-ece22c95503e< /uuid >
   <memory>524288< /memory >
   <currentMemory>524288< /currentMemory >
   <vcpu>1< /vcpu >
   <os>
     < type  arch= 'x86_64' >hvm< /type >
     <boot dev= 'cdrom' />
     <boot dev= 'hd' />
   < /os >
   <features>
     <acpi/><apic/><pae/>
   < /features >
   <clock offset= "utc" />
   <on_poweroff>destroy< /on_poweroff >
   <on_reboot>destroy< /on_reboot >
   <on_crash>destroy< /on_crash >
   <devices>
     <emulator> /usr/libexec/qemu-kvm < /emulator >
     <disk  type = 'file'  device= 'disk' >
       <driver name= 'qemu'  type = 'qcow2'  cache= 'none' />
       < source  file = '/images/test/hadoop3.img' />
       <target dev= 'vda'  bus= 'virtio' />
     < /disk >
     <disk  type = 'file'  device= 'cdrom' >
       <driver name= 'qemu' />
       < source  file = '/images/iso/CentOS-6.5-x86_64-minimal.iso' />
       <target dev= 'hdc'  bus= 'ide' />
       < readonly />
     < /disk >
     <controller  type = 'usb'  index= '0'  model= 'ich9-ehci1' >
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci1' >
         <master startport= '0' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci2' >
         <master startport= '2' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci3' >
         <master startport= '4' />
     < /controller >
     <interface  type = 'network' >
       < source  network= 'default' />
       <mac address= '52:54:00:87:5b:c0' />
     < /interface >
     <input  type = 'mouse'  bus= 'ps2' />
     <graphics  type = 'vnc'  port= '5913' />
     <console  type = 'pty' />
     <video>
       <model  type = 'cirrus' />
     < /video >
   < /devices >
< /domain >
Tue, 02 Feb 2016 14:12:36 DEBUG    Generated boot XML: 
<domain  type = 'qemu' >
   <name>hadoop3< /name >
   <uuid>ae9def17-b45b-f9ea-4ff9-ece22c95503e< /uuid >
   <memory>524288< /memory >
   <currentMemory>524288< /currentMemory >
   <vcpu>1< /vcpu >
   <os>
     < type  arch= 'x86_64' >hvm< /type >
     <boot dev= 'hd' />
   < /os >
   <features>
     <acpi/><apic/><pae/>
   < /features >
   <clock offset= "utc" />
   <on_poweroff>destroy< /on_poweroff >
   <on_reboot>restart< /on_reboot >
   <on_crash>restart< /on_crash >
   <devices>
     <emulator> /usr/libexec/qemu-kvm < /emulator >
     <disk  type = 'file'  device= 'disk' >
       <driver name= 'qemu'  type = 'qcow2'  cache= 'none' />
       < source  file = '/images/test/hadoop3.img' />
       <target dev= 'vda'  bus= 'virtio' />
     < /disk >
     <disk  type = 'block'  device= 'cdrom' >
       <target dev= 'hdc'  bus= 'ide' />
       < readonly />
     < /disk >
     <controller  type = 'usb'  index= '0'  model= 'ich9-ehci1' >
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci1' >
         <master startport= '0' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci2' >
         <master startport= '2' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci3' >
         <master startport= '4' />
     < /controller >
     <interface  type = 'network' >
       < source  network= 'default' />
       <mac address= '52:54:00:87:5b:c0' />
     < /interface >
     <input  type = 'mouse'  bus= 'ps2' />
     <graphics  type = 'vnc'  port= '5913' />
     <console  type = 'pty' />
     <video>
       <model  type = 'cirrus' />
     < /video >
   < /devices >
< /domain >
Creating domain...                                                             |    0 B     00:00     
Tue, 02 Feb 2016 14:12:36 DEBUG    Started guest, connecting to console  if  requested
Tue, 02 Feb 2016 14:12:36 DEBUG    XML fetched from libvirt object:
<domain  type = 'qemu'  id = '15' >
   <name>hadoop3< /name >
   <uuid>ae9def17-b45b-f9ea-4ff9-ece22c95503e< /uuid >
   <memory unit= 'KiB' >524288< /memory >
   <currentMemory unit= 'KiB' >524288< /currentMemory >
   <vcpu placement= 'static' >1< /vcpu >
   <os>
     < type  arch= 'x86_64'  machine= 'rhel6.6.0' >hvm< /type >
     <boot dev= 'cdrom' />
     <boot dev= 'hd' />
   < /os >
   <features>
     <acpi/>
     <apic/>
     <pae/>
   < /features >
   <clock offset= 'utc' />
   <on_poweroff>destroy< /on_poweroff >
   <on_reboot>destroy< /on_reboot >
   <on_crash>destroy< /on_crash >
   <devices>
     <emulator> /usr/libexec/qemu-kvm < /emulator >
     <disk  type = 'file'  device= 'disk' >
       <driver name= 'qemu'  type = 'qcow2'  cache= 'none' />
       < source  file = '/images/test/hadoop3.img' />
       <target dev= 'vda'  bus= 'virtio' />
       < alias  name= 'virtio-disk0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x05'  function = '0x0' />
     < /disk >
     <disk  type = 'file'  device= 'cdrom' >
       <driver name= 'qemu'  type = 'raw' />
       < source  file = '/images/iso/CentOS-6.5-x86_64-minimal.iso' />
       <target dev= 'hdc'  bus= 'ide' />
       < readonly />
       < alias  name= 'ide0-1-0' />
       <address  type = 'drive'  controller= '0'  bus= '1'  target= '0'  unit= '0' />
     < /disk >
     <controller  type = 'usb'  index= '0'  model= 'ich9-ehci1' >
       < alias  name= 'usb0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x7' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci1' >
       < alias  name= 'usb0' />
       <master startport= '0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x0'  multifunction= 'on' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci2' >
       < alias  name= 'usb0' />
       <master startport= '2' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x1' />
     < /controller >
     <controller  type = 'usb'  index= '0'  model= 'ich9-uhci3' >
       < alias  name= 'usb0' />
       <master startport= '4' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x04'  function = '0x2' />
     < /controller >
     <controller  type = 'ide'  index= '0' >
       < alias  name= 'ide0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x01'  function = '0x1' />
     < /controller >
     <interface  type = 'network' >
       <mac address= '52:54:00:87:5b:c0' />
       < source  network= 'default' />
       <target dev= 'vnet3' />
       < alias  name= 'net0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x03'  function = '0x0' />
     < /interface >
     <serial  type = 'pty' >
       < source  path= '/dev/pts/8' />
       <target port= '0' />
       < alias  name= 'serial0' />
     < /serial >
     <console  type = 'pty'  tty = '/dev/pts/8' >
       < source  path= '/dev/pts/8' />
       <target  type = 'serial'  port= '0' />
       < alias  name= 'serial0' />
     < /console >
     <input  type = 'mouse'  bus= 'ps2' />
     <graphics  type = 'vnc'  port= '5913'  autoport= 'no'  listen= '127.0.0.1' >
       <listen  type = 'address'  address= '127.0.0.1' />
     < /graphics >
     <video>
       <model  type = 'cirrus'  vram= '9216'  heads= '1' />
       < alias  name= 'video0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x02'  function = '0x0' />
     < /video >
     <memballoon model= 'virtio' >
       < alias  name= 'balloon0' />
       <address  type = 'pci'  domain= '0x0000'  bus= '0x00'  slot= '0x06'  function = '0x0' />
     < /memballoon >
   < /devices >
< /domain >

然后按照提示安装步骤一步步来安装,操作系统的安装省略。

也可以通过VNC使用virt-manager远程进行安装管理

[参数说明]

--name   虚拟机名称

--hvm     使用全虚拟化(与para-irtualization向对),不支持xen hypervisor

--ram      虚拟机内存大小

--vcpus   虚拟机虚拟CPU个数

--disk      虚拟机使用的磁盘(文件)的路径,本例中文件放置在/images/test目录下

--network 网络设置,使用默认设置即可

--vnc     设置连接桌面环境的vnc端口,本例是5911

--cdrom   设置光驱获取虚拟光驱文件的路径 -d 指示从光驱启动( -c 指示从硬盘启动)我们这里是/images/iso

安装时建议一个来安装,否则会出现报错信息



本文转自 lqbyz 51CTO博客,原文链接:http://blog.51cto.com/liqingbiao/1740672


相关文章
|
2月前
|
运维 监控 中间件
Linux运维笔记 - 如何使用WGCLOUD监控交换机的流量
WGCLOUD是一款开源免费的通用主机监控工具,安装使用都非常简单,它可以监控主机、服务器的cpu、内存、磁盘、流量等数据,也可以监控数据库、中间件、网络设备
|
4月前
|
编解码 Linux 虚拟化
在Hyper-V虚拟化的图形处理中,怎么调整虚拟机的屏幕分辨率?
在Hyper-V虚拟化中,调整虚拟机屏幕分辨率对提升用户体验和确保应用程序兼容性至关重要。高分辨率可提供清晰图像、提高工作效率,并避免显示异常。调整方法包括通过增强会话模式、虚拟机内部设置或手动编辑配置文件。注意事项包括正确安装显卡驱动、避免过高分辨率及及时保存设置。
|
5月前
|
存储 运维 数据挖掘
虚拟化数据恢复—误还原快照导致虚拟机上数据库丢失的数据恢复案例
虚拟化数据恢复环境&故障: vmfs文件系统,存储的数据是SqlServer数据库及其他办公文件。 工作人员误将快照还原,导致了SqlServer数据库数据的丢失,需要恢复原来的SqlServer数据库文件。
137 22
|
8月前
|
存储 SQL 数据库
虚拟化数据恢复—Vmware虚拟机误还原快照的数据恢复案例
虚拟化数据恢复环境: 一台虚拟机从物理机迁移到ESXI虚拟化平台,迁移完成后做了一个快照。虚拟机上运行了一个SQL Server数据库,记录了数年的数据。 ESXI虚拟化平台上有数十台虚拟机,EXSI虚拟化平台连接了一台EVA存储,所有的虚拟机都存放在EVA存储上。 虚拟化故障: 工组人员误操作将数年前迁移完成后做的快照还原了,也就意味着虚拟机状态还原到数年前,近几年数据都被删除了。 还原快照相当于删除数据,意味着部分存储空间会被释放。为了不让这部分释放的空间被重用,需要将连接到这台存储的所有虚拟机都关掉,需要将不能长时间宕机的虚拟机迁移到别的EXSI虚拟化平台上。
240 50
|
7月前
|
存储 数据挖掘 数据库
虚拟化数据恢复—VMFS简介&误删除虚拟机的数据恢复案例
物理区:物理上连续的磁盘空间,即通常意义上的分区。 本地区:VMFS管理的物理区分为保留区和本地区,前面一部分是保留区,后面部分是本地区。本地区又分为元文件区和数据区。 元文件:与NTFS的元文件类似,属于FS的管理用数据。VMFS有6个元文件:.VH.SF/.FBB.SF/.FDC.SF/.SBC.SF/.PBC.SF/.PB2.SF。 元文件区:6个元文件占用的所有空间,在本地区的前面部分。 数据区:用于存放文件数据。 datastore:在ESX服务器上看到的VMFS存储空间。 LV:logical volume,所指的范围其实和本地区一样,即虚拟化卷。 LVM逻辑卷组:用来管理跨dis
|
8月前
|
存储 持续交付 虚拟化
|
9月前
|
存储 运维 虚拟化
虚拟化数据恢复——Hyper-V虚拟化故障导致虚拟机文件丢失的数据恢复案例
在Windows Server上部署的Hyper-V虚拟化环境中,因存储中虚拟机数据文件丢失导致服务瘫痪。北亚企安数据恢复工程师通过物理检测、操作系统及文件系统检测,确定为人为格式化造成,并通过镜像硬盘、重组RAID、分析并恢复文件索引项等步骤,成功恢复数据,最终在新Hyper-V环境中验证并迁移所有虚拟机,确保用户业务恢复正常运行。
|
8月前
|
存储 安全 虚拟化
虚拟化技术:实现资源高效利用和灵活管理的利器
虚拟化技术作为实现资源高效利用和灵活管理的重要手段,在数字化时代背景下,正逐步改变传统IT架构模式。本文概述了虚拟化技术的概念、原理及其在数据中心管理、云计算平台、企业信息化建设、科研教育及医疗行业的应用,并探讨了其面临的挑战与未来发展趋势。
507 3
|
4月前
|
存储 虚拟化 Docker
|
4月前
|
开发工具 虚拟化 git
自学软硬件第755 docker容器虚拟化技术youtube视频下载工具
docker容器虚拟化技术有什么用?怎么使用?TubeTube 项目使用youtube视频下载工具