Command Line Tools
Everybody (or nearly everybody) loves GUI.
AWS Command Line Tools
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
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-toolsec2-api-tools-
1.3-53907
is the current versions downloaded in August, 2010 for
these tools.
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
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
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
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 [email protected]
Output:
RESERVATION r-ab5899ef 324978822037 default INSTANCE i-b90bdefd ami-accb9ae9 pending
[email protected] 0 m1.large2010-08-19T20:35:47+0000 us-west-1a aki-c397c686
monitoring-disabled ebs
You can see your instance using ec2din or see them on our beloved WEB console!
Stopping instance
ec2-terminate-instances i-b90bdefd
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 [email protected] -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
Ephemeral and Persistent Storage
• ec2-create-volume --size 10 -z us-west-1a• VOLUME vol-bd8c41d6 10 us-west-1a creating 2010-08-20T18:23:19+0000 Create an EBS volume:
• 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 Attach volume to running instance:
• sudo fdisk -l /dev/sdd
• Disk /dev/sdd: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track Drive is available:
• sudo mkfs.ext3 /dev/sdd • sudo mkdir /mydata
• sudo mount /dev/sdd /mydata
• sudo chown ubuntu:ubuntu /mydata Make file system:
• sudo umount /mydata Detach volume:
• ec2-detach-volume vol-bd8c41d6 -i i-87b064c3
• ATTACHMENT vol-bd8c41d6 i-87b064c3 /dev/sdd detaching 2010-08-20T18:25:41+0000 on your local machine
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