-
Notifications
You must be signed in to change notification settings - Fork 0
/
contextualisation-recipe.xml
415 lines (399 loc) · 16.7 KB
/
contextualisation-recipe.xml
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % sharedents SYSTEM "shared-entities.xml" >
%sharedents;
]>
<chapter id="contextualisation-recipe">
<info>
<author>
<firstname>Sebastien</firstname>
<surname>Goasguen</surname>
</author>
</info>
<title>contextualisation-recipe</title>
<para>Certainly it does not represent all possible solutions to the problem but
shows an end to end mechanism for a &vm; produced at INFN to start at CERN.</para>
<para>We can add the VMIC checks to bridge the two properly.</para>
<section id="contextualisation-recipe-in-parts">
<title>contextualisation recipe in 2 parts</title>
<section id="contextualisation-recipe-part1">
<title>Download image from Andrea</title>
<section id="contextualisation-recipe-part1_1">
<title>Part 1</title>
<para>Download image from Andrea</para>
<programlisting>&prompt-root;wget http://www.cnaf.infn.it/~chierici/repo/test-seba.img.bz2
--2010-07-06 15:54:46-- http://www.cnaf.infn.it/~chierici/repo/test-seba.img.bz2
Resolving www.cnaf.infn.it... 131.154.3.61
Connecting to www.cnaf.infn.it|131.154.3.61|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 531888187 (507M) [application/x-bzip2]
Saving to: `test-seba.img.bz2'
100%[===========================================================================================>] 531,888,187 5.19M/s in 86s
2010-07-06 15:56:12 (5.91 MB/s) - `test-seba.img.bz2' saved [531888187/531888187]
</programlisting>
</section>
<section id="contextualisation-recipe-part1_2">
<title>Handling the Image</title>
<programlisting>&prompt-root; <userinput>ls -l</userinput>
total 519956
drwx------ 2 root root 16384 Apr 1 17:22 lost+found
-rw-r--r-- 1 root root 531888187 Jul 6 15:19 test-seba.img.bz2
</programlisting>
<para>Bunzip it</para>
<programlisting>
&prompt-root;bunzip2 test-seba.img.bz2
&prompt-root;ls -l
total 10250036
drwx------ 2 root root 16384 Apr 1 17:22 lost+found
-rw-r--r-- 1 root root 10485760000 Jul 6 15:19 test-seba.img
</programlisting>
</section>
<section id="contextualisation-recipe-part1_3">
<title>Inspection</title>
<section id="contextualisation-recipe-part1_3_1">
<title>Partitions</title>
<para>Start Inspection steps</para>
<programlisting>
&prompt-root;kpartx -a test-seba.img
&prompt-root;ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 62 May 6 15:26 control
brw-r----- 1 root disk 253, 26 Jul 6 16:12 loop0p1
brw-r----- 1 root disk 253, 27 Jul 6 16:12 loop0p2
brw-r----- 1 root disk 253, 28 Jul 6 16:12 loop0p3
</programlisting>
</section>
<section id="contextualisation-recipe-part1_3_2">
<title>Check partition 1</title>
<para>Check first partition....See the kernels</para>
<programlisting>
&prompt-root;mount /dev/mapper/loop0p1 /mnt
&prompt-root;cd /mnt
&prompt-root;ls
config-2.6.18-164.2.1.el5 initrd-2.6.18-194.8.1.el5xen.img symvers-2.6.18-164.2.1.el5.gz vmlinuz-2.6.18-164.2.1.el5
config-2.6.18-194.8.1.el5xen initrd-paravirt.img symvers-2.6.18-194.8.1.el5xen.gz vmlinuz-2.6.18-194.8.1.el5xen
grub initrd-xen-para.img System.map-2.6.18-164.2.1.el5 xen.gz-2.6.18-194.8.1.el5
initrd-2.6.18-164.2.1.el5.img lost+found System.map-2.6.18-194.8.1.el5xen xen-syms-2.6.18-194.8.1.el5
</programlisting>
</section>
<section id="contextualisation-recipe-part1_3_3">
<title>Check Grub Config</title>
<para>Checking the Grub config has One kernel for &kvm;, one kernel for paravirtualized &xen;</para>
<programlisting>&prompt-root;cd grub
&prompt-root;cat grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda3
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Scientific Linux (2.6.18-164.2.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.2.1.el5 ro root=LABEL=/
initrd /initrd-paravirt.img
title Scientific Linux SL (2.6.18-194.8.1.el5xen)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.8.1.el5xen ro root=LABEL=/
initrd /initrd-xen-para.img
</programlisting>
</section>
<section id="contextualisation-recipe-part1_3_4">
<title>Check Other Partitions</title>
<programlisting>&prompt-root;umount /mnt
&prompt-root;mount /dev/mapper/loop0p2 /mnt
/dev/mapper/loop0p2 looks like swapspace - not mounted
mount: you must specify the filesystem type
&prompt-root;mount /dev/mapper/loop0p3 /mnt
&prompt-root;cd mnt
&prompt-root;ls
bin dev home lib64 media mnt poweroff root selinux sys usr
boot etc lib lost+found misc opt proc sbin srv tmp var
&prompt-root;
</programlisting>
</section>
<section id="contextualisation-recipe-part1_3_5">
<title>Unmounting Partitions</title>
<para>umount and delete device map</para>
<programlisting>&prompt-root;umount /mnt
&prompt-root;kpartx -d test-seba.img</programlisting>
</section>
</section>
<section id="contextualisation-recipe-part1_4">
<title>Prepare volume for disk image</title>
<para>Could use the file directly if you wanted to</para>
<programlisting>&prompt-root;lvcreate -L25G -n andrea xen_vg
Logical volume "andrea" created
&prompt-root;dd if=/stagein/test-seba.img of=/dev/xen_vg/andrea bs=4M
2500+0 records in
2500+0 records out
10485760000 bytes (10 GB) copied, 142.881 seconds, 73.4 MB/s</programlisting>
</section>
<section id="contextualisation-recipe-part1_5">
<title>Handling the Image</title>
<para>Create &xen; config file....or libvirt xml description</para>
<programlisting>&prompt-root;more /etc/xen/andrea
name = "andrea"
bootloader = "/usr/bin/pygrub"
bootargs="--entry=1"
memory = 1024
vcpus = 1
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
disk = ["phy:/dev/mapper/xen_vg-andrea,xvda,w"]
vif = ["mac=<PUT SOMETHING VALID AT YOUR SITE HERE>,bridge=xenbr0,script=vif-bridge"]
</programlisting>
</section>
<section id="contextualisation-recipe-part1_6">
<title>Handling the Image</title>
<para>Start &vm;</para>
<programlisting>&prompt-root;xm create andrea
Using config file "/etc/xen/andrea".
Started domain andrea
&prompt-root;xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 2048 8 r----- 105172.5
andrea 29 1023 1 -b---- 10.7
&prompt-root;xm console andrea
<snip>...
Starting auditd: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
Starting irqbalance: [ OK ]
Starting portmap: [ OK ]
Starting NFS statd: [ OK ]
Starting RPC idmapd: [ OK ]
Starting system message bus: [ OK ]
Mounting other filesystems: [ OK ]
Starting HAL daemon: [ OK ]
Starting hidd: [ OK ]
Starting autofs: Loading autofs4: [ OK ]
Starting automount: [ OK ]
[ OK ]
Starting sshd: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
Starting crond: [ OK ]
Starting anacron: [ OK ]
Starting atd: [ OK ]
Starting Avahi daemon... [ OK ]
Starting smartd: [ OK ]
Scientific Linux SL release 5.4 (Boron)
Kernel 2.6.18-194.8.1.el5xen on an x86_64
localhost.localdomain login:
</programlisting>
</section>
<section id="contextualisation-recipe-part1_7">
<title>Handling the Image</title>
<para>In CERN's case we would then make an &opennebula; template for this &vm;</para>
<para>Something like the following</para>
<note>this particular template has not been tested yet</note>
<programlisting>&prompt-one;more andrea.template
NAME = ANDREA
CPU = 0.1
MEMORY = 512
</programlisting>
<para>kernel and boot device</para>
<programlisting>
OS = [ bootloader = "/usr/bin/pygrub", bootargs = "--entry=1" ]
</programlisting>
<para>1 disk assumes volume is present on Hypervisors</para>
<programlisting>
DISK = [
type = "block",
source = "/dev/xen_vg/andrea",
target = "xvda",
readonly = "no" ]
</programlisting>
<para>Use Leasing of Public Network MAC/IPs</para>
<programlisting>
NIC = [ NETWORK="LXCLOUDIPs" ]
</programlisting>
<para>Context disk</para>
<programlisting>
CONTEXT = [
vmid = "$VMID",
TTL = "48",
files = "/opt/vmimage/vmcontext.prologue, /opt/vmimage/vmcontext.prologue",
target = "xvdb"
]
</programlisting>
<para>Scheduling</para>
<programlisting>
REQUIREMENTS = "MACS=\"*$NIC[MAC, NETWORK=\"LXCLOUDIPs\"]*\""
RANK = FREEMEM
</programlisting>
</section>
</section>
<section id="contextualisation-recipe-part2">
<title>Part 2</title>
<para>I got Andrea's &vm; to start in both &xen; paravirt and &kvm;. For the &kvm; one I even used &opennebula;.</para>
<para>I attach a terse transcript of the commands and configuration files used.</para>
<para>Missing component is a recipe for the contextualization as well as recipe to
get the &vm; via proper VMIC mechanism.</para>
<programlisting>
&prompt-root;more andrea
name = "andrea"
bootloader = "/usr/bin/pygrub"
bootargs="--entry=1"
memory = 1024
vcpus = 1
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
disk = ["phy:/dev/mapper/xen_vg-andrea,xvda,w"]
vif = ["mac=00:16:3E:00:03:49,bridge=xenbr0,script=vif-bridge"]
</programlisting>
<section id="contextualisation-recipe-part2-xen">
<title>Let's start it with &xen;</title>
<programlisting>&prompt-root;xm create andrea
Using config file "./andrea".
Started domain andrea
</programlisting>
<para>Using virsh you can get a libvirt xml description file</para>
</section>
<section id="contextualisation-recipe-part2-xen-cfg">
<title>basic &xen; cfg file</title>
<para>It is Probably easier to start with a basic &xen; cfg file</para>
<programlisting>&prompt-root;virsh dumpxml andrea
<domain type='xen' id='41'>
<name>andrea</name>
<uuid>64034478-9051-3010-be8d-1469c44021a3</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<bootloader_args>--entry=1</bootloader_args>
<os>
<type>linux</type>
<kernel>/var/lib/xen/boot_kernel.URfEIv</kernel>
<initrd>/var/lib/xen/boot_ramdisk.gqW2y2</initrd>
<cmdline>ro root=LABEL=/</cmdline>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/mapper/xen_vg-andrea'/>
<target dev='xvda' bus='xen'/>
</disk>
<interface type='bridge'>
<mac address='00:16:3e:00:03:49'/>
<source bridge='xenbr0'/>
<script path='vif-bridge'/>
<target dev='vif41.0'/>
</interface>
<console type='pty' tty='/dev/pts/5'>
<source path='/dev/pts/5'/>
<target port='0'/>
</console>
</devices>
</domain>
</programlisting>
</section>
<section id="contextualisation-recipe-part2-ont">
<title>&opennebula; Template</title>
<para>In &opennebula; the &vm; template for a &kvm; host is</para>
<programlisting>
&prompt-one;more andrea.test
NAME = Andrea
CPU = 0.1
MEMORY = 512
</programlisting>
<para>kernel and boot device</para>
<note>we don't use the bootargs entry</note>
<programlisting>OS = [ bootloader = "/usr/bin/pygrub" ]</programlisting>
<para>1 disk defined, disk image was dd'd in a local LVM volume</para>
<programlisting>DISK = [
type = "block",
source = "/dev/xen_vg/andrea",
target = "hda",
readonly = "no" ]</programlisting>
<para>Use Leasing of Public Network MAC/IPs</para>
<para>You might want to specify MAC directly</para>
<para>In this case we are doing a lease</para>
<programlisting>NIC = [ NETWORK="CLOUDIPs" ]</programlisting>
<para>No contextualization for now, start &vm; as is</para>
<para>Scheduling , update matchmaking for your own setup</para>
<programlisting>REQUIREMENTS = "MACS=\"*$NIC[MAC, NETWORK=\"CLOUDIPs\"]*\""
RANK = FREEMEM</programlisting>
<para>End of the &opennebula; template</para>
</section>
<section id="contextualisation-recipe-part2-opennebula">
<title>Starting the &vm; in &opennebula;</title>
<programlisting>&prompt-one;onevm create andrea.test</programlisting>
<programlisting>&prompt-one;onevm list | grep Andrea
76225 oneadmin Andrea runn 0 0 example.org 00 00:57:36
76226 oneadmin Andrea runn 0 0 example.org 00 00:52:14</programlisting>
<para>On the &kvm; host</para>
<programlisting>&prompt-root;virsh list
Id Name State
----------------------------------
3 one-76225 running
4 one-76226 running</programlisting>
<para>you might want to check the xml description generated by &opennebula;.</para>
<para>you can use it to start the &vm; with virsh without &opennebula;.</para>
<programlisting><domain type='kvm'>
<name>one-76226</name>
<memory>524288</memory>
<os>
<type>hvm</type>
<bootloader>/usr/bin/pygrub</bootloader>
<boot dev='hd'/>
</os>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='block' device='disk'>
<source dev='/opt/opennebula/76226/images/disk.0'/>
<target dev='hda'/>
</disk>
<interface type='bridge'>
<source bridge='br0'/>
<mac address='00:16:3e:00:02:d3'/>
</interface>
</devices>
<features>
<acpi/>
</features>
</domain></programlisting>
</section>
<section id="contextualisation-recipe-part2-kvm">
<title>Checking the &kvm; processes</title>
<note>You could have started these &vm;'s without virsh or &opennebula;</note>
<programlisting>
&prompt-root;ps -ef | grep kvm
root 2396 1 0 10:25 ? 00:00:27 /usr/bin/kvm -S -M rhel5.4.0 -m 512
-smp 1 -name one-76225 -uuid 1d2ce4aa-9168-b0a7-950b-91b04ab3bb51 -no-kvm-pit-reinjection
-nographic -monitor pty -pidfile /var/run/libvirt/qemu//one-76225.pid -boot c -drive
file=/opt/opennebula/76225/images/disk.0,if=ide,index=0,boot=on -net nic,macaddr=00:16:3e:00:02:d1,
vlan=0 -net tap,fd=18,script=,vlan=0,ifname=vnet1 -serial none -parallel none -usb
root 2803 1 0 10:31 ? 00:00:27 /usr/bin/kvm -S -M rhel5.4.0 -m 512
-smp 1 -name one-76226 -uuid 06a609e1-9d11-831c-1510-5efdf70622af -no-kvm-pit-reinjection
-nographic -monitor pty -pidfile /var/run/libvirt/qemu//one-76226.pid -boot c -drive
file=/opt/opennebula/76226/images/disk.0,if=ide,index=0,boot=on -net nic,macaddr=00:16:3e:00:02:d3,
vlan=0 -net tap,fd=17,script=,vlan=0,ifname=vnet0 -serial none -parallel none -usb
</programlisting>
<para>Bridge networking is used with each &vm; is attached to the bridge</para>
<programlisting>
&prompt-root;brctl show
bridge name bridge id STP enabled interfaces
br0 8000.003048d2bdf0 no vnet0
vnet1
eth0
virbr0 8000.000000000000 yes
</programlisting>
</section>
</section>
</section>
</chapter>