How to create a worker image for the Cloud - - System used for this tutorial: Ubuntu 10.10 or Debian 6.0 Must be root Create the base image ===================== - Create an empty disk image (4GB) dd if=/dev/zero of=fs-spequloscw.img bs=1M count=4096 - Make the filesystem: /sbin/mkfs.ext3 -F -j fs-spequloscw.img - Mount the image: mkdir fs-spequloscw mount -o loop fs-spequloscw.img fs-spequloscw/ - Debootstrap a Debian system: debootstrap --arch amd64 lenny fs-spequloscw/ - Mount proc mount -t proc proc fs-spequloscw/proc - Chroot into the new filesystem: chroot fs-spequloscw/ - Make the /dev devices: cd /dev /sbin/MAKEDEV generic - Configure the network by editing /etc/network/interfaces : auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp - Edit /etc/apt/sources.list : deb http://ftp2.us.debian.org/debian lenny main contrib non-free - Update packages: apt-get update apt-get upgrade - Install an SSH server: apt-get install openssh-server - Configure SSH connection: mkdir /root/.ssh cat > /root/.ssh/authorized_keys - Change hostname : - Edit /etc/hostname : spequloscw - Edit /etc/hosts 127.0.0.1 localhost 127.0.1.1 spequloscw - Prepare the image for SpeQuloS: - Create the spequlos directory: mkdir /root/spequlos - To install the XWHEP worker: - Install needed packages: apt-get install sun-java6-jre zip uuid-runtime - Install the XWHEP worker package: wget cd /opt tar xfvz xwhep.worker.tgz - Be sure that XW worker autostart is disabled: update-rc.d -f xtremweb.worker remove - Check the worker config files, eg: cat /opt/xwhep-worker-7.1.0/conf/xtremweb.worker.conf - Copy the scripts used by SpeQuloS to start the worker: You can find an exemple of those scripts inside the DG-plugin/XWHEP/startup_script/ subdirectory of the SpeQuloS package. For SpeQuloS to start the appropriate script, it is mandatory that the script is named .sh, where DG_name is the name of the desktop grid registered to SpeQuloS during the installation (see "Registering a desktop grid" in the SpeQuloS installation documentation). cp /root/spequlos/ chmod +x /root/spequlos/*.sh - To install the BOINC worker: - Install needed package: apt-get install subversion emacs less make m4 pkg-config autoconf libtool libssl-dev g++ - Download BOINC source code svn co http://boinc.berkeley.edu/svn/trunk/boinc - Install libcurl wget http://curl.haxx.se/download/curl-7.21.3.tar.gz tar xfvz curl-7.21.3.tar.gz cd curl-7.21.3 make make install cd .. - Compile the BOINC client cd boinc ./_autosetup ./configure --disable-server --enable-static ln -s /usr/local/lib/libcurl.so.4 /usr/lib/libcurl.so.4 make - Install the BOINC client mkdir /opt/BOINC_CLIENT cp client/boinc_client client/boinccmd /opt/BOINC_CLIENT cd .. - Remove unused files rm -r boinc curl-7.21.3 curl-7.21.3.tar.gz - Create the configuration file echo " 1 1 " > /opt/BOINC_CLIENT/cc_config.xml - Copy the scripts used by SpeQuloS to start the worker: You can find an exemple of those scripts inside the DG-plugin/BOINC/startup_script/ subdirectory of the SpeQuloS package. For SpeQuloS to start the appropriate script, it is mandatory that the script is named .sh, where DG_name is the name of the desktop grid registered to SpeQuloS during the installation (see "Registering a desktop grid" in the SpeQuloS installation documentation). You must also be sure that the value of the variable BOINC_ACCOUNT used in the script is the account number of the BOINC client dedicated to Cloudworkers (its user_id is "1"). cp /root/spequlos/ chmod +x /root/spequlos/*.sh - Cleaning: apt-get clean - Exit chroot: exit - Umount the image: umount fs-spequloscw/proc umount -l fs-spequloscw Creating an image for Eucalyptus ================================ - Install Eucalyptus command line tools: apt-get install euca2ools - Create a dedicated disk image: cp fs-spequloscw.img emi-spequloscw.img - Mount the image: mkdir emi-spequloscw mount -o loop emi-spequloscw.img emi-spequloscw/ - Edit the emi-spequlos/etc/fstab file: /dev/sda1 / ext2 defaults 1 1 /dev/sda2 /mnt ext3 defaults 0 0 /dev/sda3 swap swap defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 - Umount the image: umount emi-spequloscw/ - Bundle the image file for Eucaplyptus: euca-bundle-image -i emi-spequloscw.img -d . -k -c -u - Upload the image to Eucaplyptus: euca-upload-bundle -b -m emi-spequloscw.img.manifest.xml -a -s - Register the image in Eucaplyptus: euca-register /emi-spequloscw.img.manifest.xml -n spequlos-test-1 -K -C It returns the EMI identifier. - Be sure that the security group used with the image (probably the default security group) allows the SSH connexion on port 22 - Test the image: euca-run-instances -K -C It returns the instance identifier. euca-describe-instances -K -C It returns the machine address. ssh -i root@
... exit To stop the instance: euca-terminate-instances -K -C Creating an image for Amazon EC2 ================================ - Install EC2 command line tools (Ubuntu multiverse repository must be enabled): apt-get install ec2-ami-tools ec2-api-tools - Create a dedicated disk image: cp fs-spequloscw.img ami-spequloscw.img - Mount the image: mkdir ami-spequloscw mount -o loop ami-spequloscw.img ami-spequloscw/ - Edit the ami-spequlos/etc/fstab file: /dev/sda1 / ext2 defaults 1 1 /dev/sda2 /mnt ext3 defaults 0 0 /dev/sda3 swap swap defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 - Umount the image: umount ami-spequloscw/ - Bundle the image file for EC2: ec2-bundle-image -i ami-spequloscw.img -d . -k -c -u - Upload the image to EC2: ec2-upload-bundle -b -m ami-spequloscw.img.manifest.xml -a -s - Register the image in EC2: ec2-register /ami-spequloscw.img.manifest.xml -n spequlos-test-1 -K -C It returns the AMI identifier. - Be sure that the security group used with the image (probably the default security group) allows the SSH connexion on port 22 - Test the image: ec2-run-instances -K -C It returns the instance identifier. ec2-describe-instances -K -C It returns the machine address. ssh -i root@
... exit To stop the instance: ec2-terminate-instances -K -C Creating an image for a KVM hypervisor (e.g. used in OpenNebula) ================================================================ - Create a new disk image, including space for MBR and CloudWorker partition. dd if=/dev/zero of=mbr bs=8225280 count=1 cat mbr fs-spequloscw.img mbr | cp --sparse=always /dev/stdin kvm-spequloscw.img echo '1' | sfdisk kvm-spequloscw.img - Mount the image and chroot to the filesystem mkdir kvm-spequloscw mount -o loop,offset=8225280 kvm-spequloscw.img kvm-spequloscw mount -t proc proc kvm-spequloscw/proc chroot kvm-spequloscw - Install kernel and GRUB into the image echo "do_initrd=1" > /etc/kernel-img.conf aptitude update aptitude install -y linux-image-2.6-amd64 grub - Configure GRUB: mkdir -p /boot/grub cp /usr/lib/grub/x86_64-pc/* /boot/grub/ echo "timeout 1 title Debian GNU/Linux, kernel 2.6 root (hd0,0) kernel /vmlinuz root=/dev/hda1 initrd /initrd.img" > /boot/grub/menu.lst - Exit the chroot: exit - Write GRUB booting on image's MBR: echo " device (hd0) kvm-spequloscw.img root (hd0,0) setup (hd0) quit" | kvm-spequloscw/usr/sbin/grub --device-map=/dev/null - Clean: umount kvm-spequloscw/proc umount -l kvm-spequloscw rm mbr The file kvm-spequloscw.img is ready to be used by any Cloud that uses KVM, such as OpenNebula (using oneimage or econe-upload commands for instance)