UEC: Manajemen Image: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
No edit summary
Onnowpurbo (talk | contribs)
 
(8 intermediate revisions by the same user not shown)
Line 33: Line 33:
===Membuat Image disk===
===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.
Hal ini memrepresentasikan harddisk utama dari virtual machine, oleh karenanya kita perlu memastikan bahwa kita memberikan alokasi harddisk yang cukup. Karena kita akan membuat image kvm, kita menggunakan format qcow2 untuk image. Qcow2 adalah format image yang dapat di expand, oleh karenanya dia hanya akan menggunakan tempat penyimpanan yang berisi data aja dari image tersebut.
view source
print?
 


  uecadmin@client1:~$ kvm-img create -f qcow2 image.img 5G
  uecadmin@client1:~$ kvm-img create -f qcow2 image.img 5G


===Instalasi OS===
===Membuat Image OS===


Download iso file dari distribusi linux yang ingin kita install image-nya. Contoh berikut memperlihatkan caranya.
Download iso file dari distribusi linux yang ingin kita install image-nya. Contoh berikut memperlihatkan caranya.
Line 52: Line 49:
  -net nic -net user -nographic -vnc :0
  -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.
Jika proses instalasi membutuhkan RAM lebih dari 256MB ubah opsi -m, dan jika kita membutuhkan lebih banyak prosesor yang tersedia, kita dapat menggunakan opsi '-c'.
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.
Perintah di atas akan boot pada instance KVM yang baru, dengan disk image yang baru kita buat sebagai primary harddisk dan iso sebagai bootable device yang pertama. Perintah '-nographic'  akan menyebabkan KVM tidak menampilkan output grafik. Kita dapat connect ke instance menggunakan VNC (dengan display number:0) dan menyelesaikan proses instalasi.
view source
print?
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.
apt-get install vncviewer
view source
vncviewer 192.168.0.2:0
print?
vncviewer xx.xx.xx.xx:0
1 $ sudo apt-get update
2 $ sudo apt-get upgrade
3 $ sudo apt-get install mediawiki


Integrating with Eucalyptus
Setelah menyelesaikan proses instalasi, jalankan VM melalui perintah berikut


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.
  uecadmin@client1:~$ sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c \
 
-net nic -net user -nographic -vnc :0
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.
view source
print?
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.
view source
print?
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)
view source
print?
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)
view source
print?
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)
view source
print?
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.
view source
print?
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.
view source
print?
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:
Pada titik ini, kita dapat menambahkan berbagai paket yang ingin kita instal, update instalasi, menambahkan user dan berbagai settingan yang ada di UEC instance. Misalnya,
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.
$ sudo apt-get update
3. Now create another disk image using kemu-img
$ sudo apt-get upgrade
view source
$ sudo apt-get install mediawiki
print?
1 $ kvm-img create -f qcow2 newdisk.img 5G


4. Start the instance by attaching the second disk as SCSI disk.
==Integrasi dengan Eucalyptus==
view source
print?
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)
Sebuah Instance jalan di Eucalyptus perlu mengetahui IP yang dia miliki, dia juga membutuhkan public key dari pengguna yang di ijinkan untuk mengakses secara passwordless melalui SSH. Hal ini dapat di akses menggunakan interface yang di sediakan oleh cloud. Interface tersebut tersedia melalui URL http://169.254.169.254/latest/meta-data yang dapat di akses dari dalam instance.


The remaining procedure is same as that of bundling Windows 2003 Server.
Eucalyptus node controller di setup untuk menjaga tidak terjadinya automatic key injection jika system di operasikan menggunakan mode MANAGED atau MANAGED-NOVLAN. Akan tetapi, Eucalyptus akan berasumsi bahwa instance akan menggunakan layanan meta-data di atas untuk mengambil public key jika di jalankan pada mode di atas. Kita perlu memfasilitasi ini dengan menginstal crul dan menambahkan sedikit script setiap kali booting.
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.
Instalasi crul di VM
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
$ sudo apt-get install curl


    * ntldr
Tambahakan kalimat berikut di /etc/rc.local sebelum kata 'exit 0' dari image
    * ntdetect.com
    * sym_hi.sys


Rename sym_hi.sys to Ntbootdd.sys (SCSI driver needed to boot the hard disk).
depmod -a
modprobe acpiphp
 
# simple attempt to get the user ssh key using the meta-data service
# assuming “user” is the username of an account that has been created
 
mkdir -p /home/user/.ssh
echo >> /home/user/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> \
                          /home/user/.ssh/authorized_keys
echo "AUTHORIZED_KEYS:"
echo "************************"
cat /home/user/.ssh/authorized_keys
echo "************************"


In case, sym_hi.sys is not present in the CD, copy it from the following location of the installation
Juga buang network persistent rules dari /etc/udev/rules.d, sehingga instance selalu nyala dengan eth0 sebagai nama interface seperti yang di harapkan oleh Eucalyptus.
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
$ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
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
Selesai sudah proses customisasi OS yang akan di instalasi sebagai reference image.
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.
==Pendaftaran ke Eucalyptus==
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.
Langkah terakhir adalah mengupload image ke Eucalyptus. File yang perlu di upload untuk contoh di atas adalah vmlinuz-2.6.28-11-server, initrd.img-2.6.28-11-server, image.img.
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.
Copy kernel dan initrd image dari VM image ke sebuah lokasi di luar. Hal ini di perlukan untuk digunakan selanjutnya waktu membuat dan mengupload complete virtual image ke Eucalyptus.
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:
$ scp /boot/initrd.img-2.6.28-11-server user@A.B.C.D:
$ scp /boot/vmlinuz-2.6.28-11-server user@A.B.C.D:


http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldId=8659&lang=ENG
Sebelum menjalankan upload shutdown VM.
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.
==Mendaftarkan kernel image==
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.
Jalankan perintah berikut untuk mem-bundel dan mendaftarkan kernel image (vmlinuz-2.6.28-11-server)


After the VM boots, install the network drivers.
uecadmin@client1:~$ euca-bundle-image -i vmlinuz-2.6.28-11-server --kernel true
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.28-11-server.manifest.xml
uecadmin@client1:~$ euca-register mybucket/vmlinuz-2.6.28-11-server.manifest.xml


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.
Simpan output yang dihasilkan oleh perintah terakhir di atas (eki-XXXXXXXX), yang akan dibutuhkan untuk mendaftarkan disk image
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
==Mendaftarkan ramdisk image==
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.
Jalankan perintah berikut untuk mem-bundel dan mendaftarkan ramdisk image (initrd.img-2.6.28-11-server)
Registering with Eucalyptus


The last step would be to upload the images to UEC. The files that need to be uploaded are:
uecadmin@client1:~$ euca-bundle-image -i  initrd.img-2.6.28-11-server
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.28-11-server.manifest.xml
uecadmin@client1:~$ euca-register mybucket/initrd.img-2.6.28-11-server.manifest.xml


    * memdisk
Simpan output yagn dihasilkan oleh perintah terakhir di atas (eri-XXXXXXXX), yang akan dibutuhkan pada saat mendaftarkan disk image.
    * win-boot.img
    * win-2k3.img


Registering memdisk


Execute the following commands to bundle and register the memdisk.
==Mendaftarkan disk image==
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.
Jalankan perintah berikut untuk mem-bundel dan mendaftarkan ramdisk image (image.img)
Registering boot disk


Execute the following commands to bundle and register the boot disk (win-boot.img).
uecadmin@client1:~$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX
view source
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml
print?
uecadmin@client1:~$ euca-register mybucket/image.img.manifest.xml
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.
Ganti eki-XXXXXXXX dan eri-XXXXXXXX dengan nilai yang kita peroleh sebelumnya
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.
==Melihat daftar Image==
Image Listing


The new images that have been uploaded can be seen by using euca-describe-images command.
Image baru yang sudah di upload dapat dilihat menggunakan perintah euca-describe-images
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.
uecadmin@client1:~$ euca-describe-images
IMAGE  emi-70B70EC0    mybucket/image.img.manifest.xml                    admin  available        public  x86_64  machine
IMAGE  eri-A2BE13EC    mybucket/initrd.img-2.6.28-11-server.manifest.xml  admin    available      public  x86_64  ramdisk
IMAGE  eki-685F1306    mybucket/vmlinuz-2.6.28-11-server.manifest.xml      admin    available      public  x86_64  kernel


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.
Tentang bagaimana managing instances akan di terangkan di bagian selanjutnya.




Line 364: Line 166:
==Pranala Menarik==
==Pranala Menarik==


* [[Ubuntu Enterprise Cloud: Eucalyptus Beginner’s Guide]] '''RECOMMENDED'''
* [[Ubuntu Enterprise Cloud: Panduan Untuk Pemula]] '''RECOMMENDED'''
* [[Ubuntu Enterprise Cloud: Instalasi UEC]]
* [[Ubuntu Enterprise Cloud: Instalasi UEC]]
* [[Cloud Computing]]
* [[Cloud Computing]]

Latest revision as of 12:31, 6 January 2011

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:

  1. membuat virtual disk image
  2. install OS
  3. install aplikasi yang diperlukan
  4. membuat OS siap untuk di jalankan di UEC
  5. mendaftarkan image dengan UEC
  6. 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

Hal ini memrepresentasikan harddisk utama dari virtual machine, oleh karenanya kita perlu memastikan bahwa kita memberikan alokasi harddisk yang cukup. Karena kita akan membuat image kvm, kita menggunakan format qcow2 untuk image. Qcow2 adalah format image yang dapat di expand, oleh karenanya dia hanya akan menggunakan tempat penyimpanan yang berisi data aja dari image tersebut.

uecadmin@client1:~$ kvm-img create -f qcow2 image.img 5G

Membuat Image 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

Jika proses instalasi membutuhkan RAM lebih dari 256MB ubah opsi -m, dan jika kita membutuhkan lebih banyak prosesor yang tersedia, kita dapat menggunakan opsi '-c'.

Perintah di atas akan boot pada instance KVM yang baru, dengan disk image yang baru kita buat sebagai primary harddisk dan iso sebagai bootable device yang pertama. Perintah '-nographic' akan menyebabkan KVM tidak menampilkan output grafik. Kita dapat connect ke instance menggunakan VNC (dengan display number:0) dan menyelesaikan proses instalasi.

apt-get install vncviewer
vncviewer 192.168.0.2:0
vncviewer xx.xx.xx.xx:0

Setelah menyelesaikan proses instalasi, jalankan VM melalui perintah berikut

uecadmin@client1:~$ sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c \
-net nic -net user -nographic -vnc :0

Pada titik ini, kita dapat menambahkan berbagai paket yang ingin kita instal, update instalasi, menambahkan user dan berbagai settingan yang ada di UEC instance. Misalnya,

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install mediawiki

Integrasi dengan Eucalyptus

Sebuah Instance jalan di Eucalyptus perlu mengetahui IP yang dia miliki, dia juga membutuhkan public key dari pengguna yang di ijinkan untuk mengakses secara passwordless melalui SSH. Hal ini dapat di akses menggunakan interface yang di sediakan oleh cloud. Interface tersebut tersedia melalui URL http://169.254.169.254/latest/meta-data yang dapat di akses dari dalam instance.

Eucalyptus node controller di setup untuk menjaga tidak terjadinya automatic key injection jika system di operasikan menggunakan mode MANAGED atau MANAGED-NOVLAN. Akan tetapi, Eucalyptus akan berasumsi bahwa instance akan menggunakan layanan meta-data di atas untuk mengambil public key jika di jalankan pada mode di atas. Kita perlu memfasilitasi ini dengan menginstal crul dan menambahkan sedikit script setiap kali booting.

Instalasi crul di VM

$ sudo apt-get install curl

Tambahakan kalimat berikut di /etc/rc.local sebelum kata 'exit 0' dari image

depmod -a
modprobe acpiphp
 
# simple attempt to get the user ssh key using the meta-data service
# assuming “user” is the username of an account that has been created
 
mkdir -p /home/user/.ssh
echo >> /home/user/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> \
                         /home/user/.ssh/authorized_keys
echo "AUTHORIZED_KEYS:"
echo "************************"
cat /home/user/.ssh/authorized_keys
echo "************************"

Juga buang network persistent rules dari /etc/udev/rules.d, sehingga instance selalu nyala dengan eth0 sebagai nama interface seperti yang di harapkan oleh Eucalyptus.

$ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules

Selesai sudah proses customisasi OS yang akan di instalasi sebagai reference image.


Pendaftaran ke Eucalyptus

Langkah terakhir adalah mengupload image ke Eucalyptus. File yang perlu di upload untuk contoh di atas adalah vmlinuz-2.6.28-11-server, initrd.img-2.6.28-11-server, image.img.

Copy kernel dan initrd image dari VM image ke sebuah lokasi di luar. Hal ini di perlukan untuk digunakan selanjutnya waktu membuat dan mengupload complete virtual image ke Eucalyptus.

$ scp /boot/initrd.img-2.6.28-11-server user@A.B.C.D:
$ scp /boot/vmlinuz-2.6.28-11-server user@A.B.C.D:

Sebelum menjalankan upload shutdown VM.


Mendaftarkan kernel image

Jalankan perintah berikut untuk mem-bundel dan mendaftarkan kernel image (vmlinuz-2.6.28-11-server)

uecadmin@client1:~$ euca-bundle-image -i vmlinuz-2.6.28-11-server --kernel true
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.28-11-server.manifest.xml
uecadmin@client1:~$ euca-register mybucket/vmlinuz-2.6.28-11-server.manifest.xml

Simpan output yang dihasilkan oleh perintah terakhir di atas (eki-XXXXXXXX), yang akan dibutuhkan untuk mendaftarkan disk image


Mendaftarkan ramdisk image

Jalankan perintah berikut untuk mem-bundel dan mendaftarkan ramdisk image (initrd.img-2.6.28-11-server)

uecadmin@client1:~$ euca-bundle-image -i  initrd.img-2.6.28-11-server
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.28-11-server.manifest.xml
uecadmin@client1:~$ euca-register mybucket/initrd.img-2.6.28-11-server.manifest.xml

Simpan output yagn dihasilkan oleh perintah terakhir di atas (eri-XXXXXXXX), yang akan dibutuhkan pada saat mendaftarkan disk image.


Mendaftarkan disk image

Jalankan perintah berikut untuk mem-bundel dan mendaftarkan ramdisk image (image.img)

uecadmin@client1:~$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml
uecadmin@client1:~$ euca-register mybucket/image.img.manifest.xml

Ganti eki-XXXXXXXX dan eri-XXXXXXXX dengan nilai yang kita peroleh sebelumnya


Melihat daftar Image

Image baru yang sudah di upload dapat dilihat menggunakan perintah euca-describe-images


uecadmin@client1:~$ euca-describe-images
IMAGE   emi-70B70EC0    mybucket/image.img.manifest.xml                     admin   available        public  x86_64  machine
IMAGE   eri-A2BE13EC    mybucket/initrd.img-2.6.28-11-server.manifest.xml   admin    available       public  x86_64  ramdisk
IMAGE   eki-685F1306    mybucket/vmlinuz-2.6.28-11-server.manifest.xml      admin    available       public  x86_64  kernel

Tentang bagaimana managing instances akan di terangkan di bagian selanjutnya.


Referensi

Pranala Menarik