Cloud Computing Command Line Tools
AWS Command Line Tools Everybody (or nearly everybody) loves GUI. AWS web console is capable of performing many cloud computing functions, but lacks the power of advanced features. After surviving the cloud computing class till now, Your are almost a command line guru! You need AWS command line tools, ec2-api-tools, to maximize the power of AWS cloud computing. Plugging and removing additional drives to your running cloud computer. Saving or trashing drive data after terminating the instance. Modifying instance attribute while instance is running.
Installing Command Line Tools ec2-api-tools are written in Java. It can be installed everywhere where java is available, such as Windows, Linux, Mac OS X, etc. If you have a spare old x86 machine, you can easily install Ubuntu Linux 10.04 LTS: http://www.ubuntu.com/desktop/get-ubuntu/download AWS command line installation in Ubuntu: sudo apt-get install ec2-api-tools It is a similar installation procedure for Linux, Unix, and Mac.
Installing Command Line Tools Windows Installation: Install java if you have not done so yet. http://www.java.com/en/download/manual.jsp#win Download AWS command line tools from Amazon: http://developer.amazonwebservices.com/connect/entry.jspa?externalid=351 These tools is package in a zip file. Let us make a folder in Windows at C:\class\aws and extract the content of zip file to C:\class\aws Rename file C:\class\aws\ec2-api-tools-1.3-53907 to C:\class\aws\ec2-api-tools ec2-api-tools-1.3-53907 is the current versions downloaded in August, 2010 for these tools. Tool installation is done!
Configuring Command Line Tools Windows Configuration: Create a file C:\class\aws\aws_env.cmd with the following content (using notepad) REM Path should have bin\java.exe under it set JAVA_HOME="C:\Program Files\java\jre6" REM Path to Primary Key and Certificate retrieved from AWS set EC2_PRIVATE_KEY=c:\class\aws\aws-pk.pem set EC2_CERT=c:\class\aws\aws-cer.pem REM Path setup set EC2_HOME=c:\class\aws\ec2-api-tools set PATH=%PATH%;%EC2_HOME%\bin set EC2_URL=https://ec2.us-west-1.amazonaws.com Configuration is nearly done!
Configuring Command Line Tools X.509 Certificates: REM Path to Primary Key and Certificate retrieved from AWS set EC2_PRIVATE_KEY=c:\class\aws\aws-pk.pem set EC2_CERT=c:\class\aws\aws-cer.pem We need to generate these two files aws-pk.pem and aws-cer.pem from AWS web console. Go to http://aws.amazon.com/account/, and click on Security credentials Create a new Access Key Save the files as aws-pk.pem and aws-cer.pem in C:\class\aws folder Configuration is done!
Running Command Line Tools Windows: Start a cmd shell cd C:\class\aws aws_env.cmd AWS commands are all start with ec2-something-something or shorted command ec2something, ec2-describe-images or ec2dim are the same commands. All these commands have option -h or --help to get usage help. You might cut and paste some commands from this web page: http://wiki.bioinformatics.ucdavis.edu/index.php/cloud_class_-_command_line Type ec2dim to see what AMIs you have under your account and ec2-describe-instances to show your running instances
Starting/Terminating Instances Starting instance You may start instance using the following command using our own bioinformatics AMI (accb9ae9, your AMI id will be different from mine) ec2-run-instances ami-accb9ae9 --instance-type m1.large --key zwlu@ucdavis.edu Output: RESERVATION r-ab5899ef 324978822037 default INSTANCE i-b90bdefd ami-accb9ae9 pending zwlu@ucdavis.edu 0 m1.large2010-08-19t20:35:47+0000 us-west-1a aki-c397c686 monitoringdisabled ebs You can see your instance using ec2din or see them on our beloved WEB console! Stopping instance ec2-terminate-instances i-b90bdefd Note your AMI, instance ID, etc will be different from mine!
Ephemeral and Persistent Storage Ephermeral Storage: /dev/sdb ( /mnt) is a ephemeral storage and will disappear! Two 420 GB ephemeral storages for type m1.large. To use both ephemeral storages: ec2run ami-9ccd9cd9 --instance-type m1.large --key zwlu@ucdavis.edu -b '/dev/sdc=ephemeral1' These /dev/sdb and /dev/sdc are pre-formatted in the Linux ext3 file system and are ready for use sudo mkdir /mnt2 sudo mount /dev/sdc /mnt2 /dev/sdc will be mounted at /mnt2, you can even use Linux LVM to make them into a single LVM volume of 840 GB.
Ephemeral and Persistent Storage Persistent Storage: Create an EBS volume: ec2-create-volume --size 10 -z us-west-1a VOLUME vol-bd8c41d6 10 us-west-1a creating 2010-08-20T18:23:19+0000 Attach volume to running instance: ec2-attach-volume vol-bd8c41d6 -i i-87b064c3 -d /dev/sdd ATTACHMENT vol-bd8c41d6 i-87b064c3 /dev/sdd attaching 2010-08-20T18:25:41+0000 Drive is available: sudo fdisk -l /dev/sdd Disk /dev/sdd: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track Make file system: sudo mkfs.ext3 /dev/sdd sudo mkdir /mydata sudo mount /dev/sdd /mydata sudo chown ubuntu:ubuntu /mydata Detach volume: sudo umount /mydata on your local machine ec2-detach-volume vol-bd8c41d6 -i i-87b064c3 ATTACHMENT vol-bd8c41d6 i-87b064c3 /dev/sdd detaching 2010-08-20T18:25:41+0000
More Command Lines You may attach this volume to another instance, but you can not attach one volume to more than one instance at the same time, try to see what happens! There are many more tools & options in command line: Examine C:\class\aws\aws-api-tools\bin -h (or help) are your friends to unlock the secrets of these tools AWS forums: http://developer.amazonwebservices.com/connect/forumindex.jspa Helpful websites: http://alestic.com/ http://www.rightscale.com/ Mr. Google helps too!