Difference between revisions of "UEC: Manajemen Image"
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
Line 59: | Line 59: | ||
After finishing the installation, relaunch the VM by executing the following command. | After finishing the installation, relaunch the VM by executing the following command. | ||
− | + | ||
− | |||
1 uecadmin@client1:~$ sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c \ | 1 uecadmin@client1:~$ sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c \ | ||
2 -net nic -net user -nographic -vnc :0 | 2 -net nic -net user -nographic -vnc :0 | ||
At this point you can add all the packages you want to have installed, update the installation, add users and any settings that need to be present in your new UEC instances. | At this point you can add all the packages you want to have installed, update the installation, add users and any settings that need to be present in your new UEC instances. | ||
− | + | ||
− | |||
1 $ sudo apt-get update | 1 $ sudo apt-get update | ||
2 $ sudo apt-get upgrade | 2 $ sudo apt-get upgrade | ||
Line 78: | Line 76: | ||
Install curl on the VM. | Install curl on the VM. | ||
− | + | ||
− | |||
1 $ sudo apt-get install curl | 1 $ sudo apt-get install curl | ||
Line 103: | Line 100: | ||
Also remove the network persistent rules from /etc/udev/rules.d, so that the instance always comes up with eth0 as the interface name as expected by eucalyptus. | Also remove the network persistent rules from /etc/udev/rules.d, so that the instance always comes up with eth0 as the interface name as expected by eucalyptus. | ||
− | + | ||
− | |||
1 $ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules | 1 $ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules | ||
Line 121: | Line 117: | ||
Execute the following commands to bundle and register the kernel image (vmlinuz-2.6.28-11-server) | Execute the following commands to bundle and register the kernel image (vmlinuz-2.6.28-11-server) | ||
− | + | ||
− | |||
1 uecadmin@client1:~$ euca-bundle-image -i vmlinuz-2.6.28-11-server --kernel true | 1 uecadmin@client1:~$ euca-bundle-image -i vmlinuz-2.6.28-11-server --kernel true | ||
2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.28-11-server.manifest.xml | 2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.28-11-server.manifest.xml | ||
Line 131: | Line 126: | ||
Execute the following commands to bundle and register the ramdisk image (initrd.img-2.6.28-11-server) | Execute the following commands to bundle and register the ramdisk image (initrd.img-2.6.28-11-server) | ||
− | + | ||
− | |||
1 uecadmin@client1:~$ euca-bundle-image -i initrd.img-2.6.28-11-server | 1 uecadmin@client1:~$ euca-bundle-image -i initrd.img-2.6.28-11-server | ||
2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.28-11-server.manifest.xml | 2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.28-11-server.manifest.xml | ||
Line 141: | Line 135: | ||
Execute the following commands to bundle and register the ramdisk image (image.img) | Execute the following commands to bundle and register the ramdisk image (image.img) | ||
− | + | ||
− | |||
1 uecadmin@client1:~$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX | 1 uecadmin@client1:~$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX | ||
2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml | 2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml | ||
Line 165: | Line 158: | ||
This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need. Since we are building a kvm image, we can use a qcow2 format for disk images. Qcow2 is an expandable image format, so it will only occupy as much storage space as is actually filled by the data within the image. | This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need. Since we are building a kvm image, we can use a qcow2 format for disk images. Qcow2 is an expandable image format, so it will only occupy as much storage space as is actually filled by the data within the image. | ||
− | + | ||
− | |||
1 uecadmin@client1:~$ kvm-img create -f qcow2 win-2k3.img 20G | 1 uecadmin@client1:~$ kvm-img create -f qcow2 win-2k3.img 20G | ||
OS Installation | OS Installation | ||
Line 176: | Line 168: | ||
After finishing the installation and in case you need to install from the 2nd CD as well, reboot the VM and launch the VM by the following command. | After finishing the installation and in case you need to install from the 2nd CD as well, reboot the VM and launch the VM by the following command. | ||
− | + | ||
− | |||
1 uecadmin@client1:~$ sudo kvm -m 1024 -boot c -cdrom Win2003ServerR2x86_cd2.iso -drive file=win-2k3.img,if=scsi,boot=on -nographic -vnc :0 | 1 uecadmin@client1:~$ sudo kvm -m 1024 -boot c -cdrom Win2003ServerR2x86_cd2.iso -drive file=win-2k3.img,if=scsi,boot=on -nographic -vnc :0 | ||
Line 198: | Line 189: | ||
4. Start the instance by attaching the second disk as SCSI disk. | 4. Start the instance by attaching the second disk as SCSI disk. | ||
− | + | ||
− | |||
1 $ sudo kvm -m 1024 -drive file=winxp.img,boot=on -drive file=newdisk.img,if=scsi -nographic -vnc :0 | 1 $ sudo kvm -m 1024 -drive file=winxp.img,boot=on -drive file=newdisk.img,if=scsi -nographic -vnc :0 | ||
Revision as of 10:24, 19 December 2010
Eucalyptus Machine Image(EMI)
Eucalpyptus Machine Image(EMI) adalah kombinasi dari virtual disk image, kernel dan ramdisk images juga sebuah file xml yang berisi meta data tentang image tersebut. Image ini berada di WS3 dan digunakan sebagai template untuk membuat instance di UEC. Setiap Linux EMI adalah kombinasi dari hal berikut
- Sebuah file XML dengan nama seperti “jaunty.img.manifest.xml” dengan informasi tentang satu atau lebih harddisk image, sebuah kernel image dan sebuah ram disk image (id – emi-65440E7E)
- Sebuah file XML dengan nama seperti “vmlinuz-2.6.28-11-server.manifest.xml” akan membawa informasi tentang with information about the corresponding kernel image(id – eki-39FC1244)
- Sebuah file XML dengan nama seperti “initrd.img-2.6.28-11-server.manifest.xml” akan membawa informasi tentang ramdisk image(id – eri-71ED1322)
Setiap image akan mempunyai ID sendiri yang digunakan saat menjalankan instances.
Dari interface web Eucalyptus, kita dapat melihat daftar dari EMI yang ada di tab “Store” di web. Daftar ini adalah EMI yang ada di Canonical atau partner. Kita dapat memilih untuk mendownload dan menginstall image ini langsung dari Canonical site.
Kebanyakan pengguna Eucalyptus baik enterprise / individual biasanya membutuhkan untuk
Since most enterprise/individual users of Eucalyptus have a need for bringing up instances based on custom images, image management plays a key role in Eucalyptus administration. Such images could be based on a preferred version/variant of a preferred OS distribution with a set of required applications pre-installed.
Membuat EMI akan melalui banyak langkah berikut:
- membuat virtual disk image
- install OS
- install aplikasi yang diperlukan
- membuat OS siap untuk di jalankan di UEC
- mendaftarkan image dengan UEC
- test image dll.
Proses pembuatan image berbeda antara Linux dan Windows.
Membuat Linux Image
Kita akan menggunakan Client1 untuk pembuatan image. Untuk itu, kita perlu menginstalasi KVM di Client1.
Membuat Image disk
This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need. Since we are building a kvm image, we can use a qcow2 format for disk images. Qcow2 is an expandable image format, so it will only occupy as much storage space as is actually filled by the data within the image. view source print?
uecadmin@client1:~$ kvm-img create -f qcow2 image.img 5G
Instalasi OS
Download iso file dari distribusi linux yang ingin kita install image-nya. Contoh berikut memperlihatkan caranya.
uecadmin@client1:~$ wget http://releases.ubuntu.com/karmic/ubuntu-9.04-server-amd64.iso uecadmin@client1:~$ scp user@mesin:/path/ubuntu-10.10-server-i386.iso .
Setelah itu lakukan proses instalasi:
uecadmin@client1:~$ sudo kvm -m 256 -cdrom ubuntu-10.10-server-i386.iso -drive file=image.img,if=scsi,index=0 -boot d \ -net nic -net user -nographic -vnc :0
If your installation process requires more than 256MB of RAM change the -m option, and if you need more processors available, you can use the ‘-c’ option. The command above will boot a new KVM instance, with the disk image you’ve created as the primary HDD and the iso as the first bootable device. Also the ‘-nographic’ option will not display any graphical output. You can connect to the instance through VNC (use display number :0) and finish the installation. view source print? 1 For Ex: vncviewer A.B.C.D :0, where A.B.C.D is the IP address of Client1.
After finishing the installation, relaunch the VM by executing the following command.
1 uecadmin@client1:~$ sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c \ 2 -net nic -net user -nographic -vnc :0
At this point you can add all the packages you want to have installed, update the installation, add users and any settings that need to be present in your new UEC instances.
1 $ sudo apt-get update 2 $ sudo apt-get upgrade 3 $ sudo apt-get install mediawiki
Integrating with Eucalyptus
An instance running under Eucalyptus needs to know what IP it has and also, it needs to have the public key of the user allowed to do a passwordless access through SSH. This is accomplished by using a restful interface provided by the cloud. The interface is available under this URL: http://169.254.169.254/latest/meta-data and accessible from within the Instance.
Eucalyptus node controller is set up to prevent automatic key injection if the system is in MANAGED or MANAGED-NOVLAN mode. Instead, it is assumed that the instance will use the above meta-data service to retrieve the public keys when running in these modes. You will need to facilitate this by installing curl and adding a script that will run on each boot.
Install curl on the VM.
1 $ sudo apt-get install curl
Now add the following lines to /etc/rc.local of the image. view source print? 01 depmod -a 02 modprobe acpiphp 03 04 # simple attempt to get the user ssh key using the meta-data service 05 # assuming “user” is the username of an account that has been created 06 07 mkdir -p /home/user/.ssh 08 echo >> /home/user/.ssh/authorized_keys 09 curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> \ 10 /home/user/.ssh/authorized_keys 11 echo "AUTHORIZED_KEYS:" 12 echo "************************" 13 cat /home/user/.ssh/authorized_keys 14 echo "************************"
Add the above lines before the “exit 0” in /etc/rc.local
Also remove the network persistent rules from /etc/udev/rules.d, so that the instance always comes up with eth0 as the interface name as expected by eucalyptus.
1 $ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
This completes the process of customizing the OS installed as a reference image. Registering with Eucalyptus
The last step would be to upload the images to Eucalyptus. The files that need to be uploaded for the above sample setup are: vmlinuz-2.6.28-11-server, initrd.img-2.6.28-11-server, image.img.
Copy the kernel and the initrd image from the VM image to some place outside. These will be used later for creating and uploading a complete virtual image to Eucalyptus.
1 $ scp /boot/initrd.img-2.6.28-11-server user@A.B.C.D: 2 $ scp /boot/vmlinuz-2.6.28-11-server user@A.B.C.D:
Before starting the upload process shut down the VM. Registering kernel image
Execute the following commands to bundle and register the kernel image (vmlinuz-2.6.28-11-server)
1 uecadmin@client1:~$ euca-bundle-image -i vmlinuz-2.6.28-11-server --kernel true 2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.28-11-server.manifest.xml 3 uecadmin@client1:~$ euca-register mybucket/vmlinuz-2.6.28-11-server.manifest.xml
Save the output produced by the last command above (eki-XXXXXXXX), which will be needed while registering the disk image. Registering ramdisk image
Execute the following commands to bundle and register the ramdisk image (initrd.img-2.6.28-11-server)
1 uecadmin@client1:~$ euca-bundle-image -i initrd.img-2.6.28-11-server 2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.28-11-server.manifest.xml 3 uecadmin@client1:~$ euca-register mybucket/initrd.img-2.6.28-11-server.manifest.xml
Save the output produced by the last command above (eri-XXXXXXXX), which will be needed while registering the disk image. Registering disk image
Execute the following commands to bundle and register the ramdisk image (image.img)
1 uecadmin@client1:~$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX 2 uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml 3 uecadmin@client1:~$ euca-register mybucket/image.img.manifest.xml
Replace eki-XXXXXXXX and eri-XXXXXXXX with the exact values you have saved earlier. Image Listing
The new images that have been uploaded can be seen by using euca-describe-images command.
For Ex: view source print? 1 uecadmin@client1:~$ euca-describe-images 2 IMAGE emi-70B70EC0 mybucket/image.img.manifest.xml admin available public x86_64 machine 3 IMAGE eri-A2BE13EC mybucket/initrd.img-2.6.28-11-server.manifest.xml admin available public x86_64 ramdisk 4 IMAGE eki-685F1306 mybucket/vmlinuz-2.6.28-11-server.manifest.xml admin available public x86_64 kernel
More details on managing the instances in later chapters. Bundling Windows Image Creating new disk image
This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need. Since we are building a kvm image, we can use a qcow2 format for disk images. Qcow2 is an expandable image format, so it will only occupy as much storage space as is actually filled by the data within the image.
1 uecadmin@client1:~$ kvm-img create -f qcow2 win-2k3.img 20G OS Installation
Create an ISO image of the relevant Windows installation CD. And start the installation process. view source print? 1 uecadmin@client1:~$ sudo kvm -m 1024 -cdrom Win2003ServerR2x86_cd1.iso -drive file=win-2k3.img,if=scsi,boot=on -nographic -vnc :0
After finishing the installation and in case you need to install from the 2nd CD as well, reboot the VM and launch the VM by the following command.
1 uecadmin@client1:~$ sudo kvm -m 1024 -boot c -cdrom Win2003ServerR2x86_cd2.iso -drive file=win-2k3.img,if=scsi,boot=on -nographic -vnc :0
Once installation is complete, we need to create the boot disk needed for Windows 2003 server For Windows XP bundling
While bundling Windows XP, the OS doesn’t recognize SCSI driver during installation process.
The following workaround is suggested: 1. Attach the disk as IDE disk. view source print? 1 $ sudo kvm -m 1024 -cdrom winxpcd.iso -drive file=winxp.img,boot=on -nographic -vnc :0
2. Finish the installation of Windows XP. 3. Now create another disk image using kemu-img view source print? 1 $ kvm-img create -f qcow2 newdisk.img 5G
4. Start the instance by attaching the second disk as SCSI disk.
1 $ sudo kvm -m 1024 -drive file=winxp.img,boot=on -drive file=newdisk.img,if=scsi -nographic -vnc :0
5. After Windows XP boots, it detects and installs the driver for the SCSI disk (sys_hi.sys)
The remaining procedure is same as that of bundling Windows 2003 Server. Copying the boot files
Re-launch the VM using the following command, so that we can access the first CD, in order to copy some files from it. view source print? 1 uecadmin@client1:~$ sudo kvm -m 1024 -boot c -cdrom Win2003ServerR2x86_cd1.iso -drive file=win-2k3.img,if=scsi,boot=on -nographic -vnc :0
Copy the following files to a specific location to create the boot disk, say C:\bootfiles
* ntldr * ntdetect.com * sym_hi.sys
Rename sym_hi.sys to Ntbootdd.sys (SCSI driver needed to boot the hard disk).
In case, sym_hi.sys is not present in the CD, copy it from the following location of the installation view source print? 1 C:\WINDOWS\system32\drivers
Write the following lines to a new file and save it as Boot.ini in the same location, i.e, C:\bootfiles view source print? 1 [boot loader] 2 timeout=30 3 Default= multi(0)disk(0)rdisk(0)partition(1)\Windows 4 5 [operating systems] 6 multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003"
Shut down the VM and proceed for the boot disk creation Boot disk creation
Execute the following command to create the boot disk. view source print? 1 uecadmin@client1:~$ dd bs=512 count=2880 if=/dev/zero of=win-boot.img
Now attach this disk as a floppy disk and start the Windows VM. view source print? 1 uecadmin@client1:~$ sudo kvm -m 1024 -boot c -drive file=win-2k3.img,if=scsi,boot=on,index=1 -fda win-boot.img -nographic -vnc :0
On the Windows VM, format the floppy disk and copy all the files from C:\bootfiles to the floppy. Shutdown the VM and test the boot disk created with the following command view source print? 1 uecadmin@client1:~$ sudo kvm -m 1024 -boot a -drive file=win-2k3.img,if=scsi,boot=on,index=1 -fda win-boot.img -nographic -vnc :0
This should boot you into windows, if you have rightly created the boot floppy. Network Configuration
Now you need to download the e1000 drivers, since e1000 is the default interface that is supported by Eucalyptus. You can download the drivers from the following location:
http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldId=8659&lang=ENG view source print? 1 For 32-bit VM, download PRO2KXP.exe 2 For 64-bit Vm, download PROEM64T .exe
Once the download is finished, shutdown the VM and restart the VM with the following command. view source print? 1 uecadmin@client1:~$ sudo kvm -m 1024 -boot a -drive file=win-2k3.img,if=scsi,boot=on,index=1 -fda win-boot.img \ 2 -net nic,model=e1000 -net tap -nographic -vnc :0
The above command tell the VM to make use of e1000 model as its NIC. After executing the above command, you will get this warning. view source print? 1 Warning: vlan 0 is not connected to host network
You can safely ignore this warning message.
After the VM boots, install the network drivers.
Enable remote desktop for all users on the VM. This is very important. As this is the only way, without installing a third party tool, you allow get access to a Windows instance running on UEC. You can enable remote desktop by navigating to Start → Settings → Control Panel → System → Remote and selecting Remote Desktop option for all users. This completes the Windows disk setup. Shut down the VM. Memdisk
The kernel memdisk is needed to load Windows. The default syslinux memdisk could be used for this purpose. If you cannot locate memdisk on CC, you need to install syslinux. view source print? 1 uecadmin@client1:~$ sudo apt-get install syslinux
After installing, memdisk will be found in /usr/lib/syslinux view source print? 1 uecadmin@client1:~$ cd /usr/lib/syslinux 2 uecadmin@client1:/usr/lib/syslinux$ ls -l memdisk 3 -rw-r--r-- 1 root root 20068 2008-07-15 20:25 memdisk
Copy it to the location where you have all windows files. Registering with Eucalyptus
The last step would be to upload the images to UEC. The files that need to be uploaded are:
* memdisk * win-boot.img * win-2k3.img
Registering memdisk
Execute the following commands to bundle and register the memdisk. view source print? 1 uecadmin@client1:~$ euca-bundle-image -i memdisk --kernel true 2 uecadmin@client1:~$ euca-upload-bundle -b win2k3_bucket -m /tmp/memdisk.manifest.xml 3 uecadmin@client1:~$ euca-register win2k3_bucket/memdisk.manifest.xml
Save the output produced by the last command above (eki-XXXXXXXX), which will be needed while registering the disk image. Registering boot disk
Execute the following commands to bundle and register the boot disk (win-boot.img). view source print? 1 uecadmin@client1:~$ euca-bundle-image -i win-boot.img --ramdisk true 2 uecadmin@client1:~$ euca-upload-bundle -b win2k3_bucket -m /tmp/win-boot.img.manifest.xml 3 uecadmin@client1:~$ euca-register win2k3_bucket/win-boot.img.manifest.xml
Save the output produced by the last command above (eri-XXXXXXXX), which will be needed while registering the disk image. Registering disk image
Execute the following commands to bundle and register the disk image (win-2k3.img) view source print? 1 uecadmin@client1:~$ euca-bundle-image -i win-2k3.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX 2 uecadmin@client1:~$ euca-upload-bundle -b win2k3_bucket -m /tmp/win-2k3.img.manifest.xml 3 uecadmin@client1:~$ euca-register win2k3_bucket/win-2k3.img.manifest.xml
Replace eki-XXXXXXXX and eri-XXXXXXXX with the exact values as noted down earlier. Image Listing
The new images that have been uploaded can be seen by using euca-describe-images command. For Ex: view source print? 1 uecadmin@client1:~$ euca-describe-images 2 IMAGE emi-55470DE2 win-2k3/win-2k3.img.manifest.xml admin available public x86_64 machine 3 IMAGE eki-2BC30D1B win-2k3/memdisk.manifest.xml admin available public x86_64 kernel 4 IMAGE eri-76C20ED5 win-2k3/win-boot.img.manifest.xml admin available public x86_64 ramdisk Running instance of custom image
To launch a new instance of the custom image, execute euca-run-instances command. view source print? 1 uecadmin@client1:~$ cd .euca 2 uecadmin@client1:~/.euca$ euca-run-instances emi-55470DE2 -k mykey -t c1.xlarge
Since this is a windows instance the VM type is specified as c1.xlarge, which has 20GB of hard disk space.
The above procedure for bundling Windows images worked on Ubuntu 9.10 (Karmic Koala). But it fails on Ubuntu 10.04(Lucid Lynx). Please refer to Chapter 11 for a hack to get Windows images running on Lucid Lynx.