Saturday, December 10, 2011

Ubuntu on the Cloud


It has been a long time since the last post but I hope that this interesting post will compensate the wait.

Today we are going to talk about something that has become very trendy in the last years 'The cloud'. The first question is quite obvious... What is the Cloud? Based on Wikipedia's definition: 'Cloud computing is the delivery of computing as a service rather than a product, whereby shared resources, software, and information are provided to computers and other devices as a utility (like the electricity grid) over a network (typically the Internet).'

Do not feel silly if after reading this definition you are still wondering what is the Cloud... Actually the cloud can potentially means a lot of things. If you ask an Ipod user what is the Cloud he will probably relate it with remote storage, the ability of playing his music from several devices and some other Mac related services that are not very interesting for us at this moment.

The cloud I am going to explain on this post is mostly related with the 'Infrastructure as a Service' cloud approach. Yes ok, but... What that's means?? That means in its most basic meaning an Ubuntu running somewhere.

Somewhere is usually a Data-center, like the ones constructed and used by Facebook to provide services to an enormous amount of people, and it is basically a set of thousands servers running (and consuming) continuously.


Fig.1 Amazon Date-Center in Oregon


Fig.2 A typical Data-Center from the inside

And here is where the business comes. Companies like Amazon with hundred of Data-centers all around the world hosting their own web applications (Does Amazon.com tell you something?) decided to step forward and offer a piece of this Data-center cake to anybody willing at pay the price they established. And guess what, the technology used to provide remotes operative system is based on virtualization techniques.

I bet you are wondering right now how much does it cost having a full accessible Ubuntu running on the cloud 7x24... The answer is nothing (During the first year)!! Amazon offers you a free-tier that consists on a limited usage (750 hours of Amazon EC2 Linux Micro Instance usage [613 MB of memory and 32-bit and 64-bit platform support] ).

If you make your calculations a 31 days month has 744 hours, so basically you can run this micro instance for free during a whole year. Actually there are more limitations, like in the amount of data that you transmit to your remote Ubuntu and the number of http transactions (100.000). In any case this is more than enough for a little web server hosting a database and serving our dynamic web applications. Actually you have to take into account that each time that you start an stop your instance (Your remote Ubuntu) it count as an extra-hour. Here 'http://aws.amazon.com/free/' you can find all the conditions of the free-tier usage.

Here  you can find a calculator that allows you make an idea about how much you will pay based on your usage and the type of Operative System that you are hosting (You can host a Windows Server instead than an Ubuntu).

A. Creating a remote Instance

So let's go!! All you need is an Amazon account (you probably have one already) and sign on the Amazon Web Services (from now on AWS) account http://aws.amazon.com/

Once you have created your AWS account you can log on the AWS Management console and create your instances (An instance == An operative system running on the cloud).

Fig.3 Dashboard page


From the dashboard select your region on the left and if it does not exists create a 'Default' security group (Under Networking & Security) add the rules to allow accessing to ssh, web, mysql, web https, and all that you potentially could need (You can take the following screen-shot as reference).

Fig.4 Security group

Back to the Dashboard, click on launch instance, select Launch Classic Wizard and under the tab “Community AMIs” search for the Ubuntu instance that fits with your needs. Here http://cloud-images.ubuntu.com/releases/10.04/release/ you can find a list of Ubuntu releases with its associated amids. Remember that only the micro instances are for free!!
Fig.5 AMID Selection


In our case, for Europe Region we have two choices:

eu-west-1 64-bit ebs ami-cc0e3cb8 ec2-run-instances ami-cc0e3cb8 --instance-type t1.micro --region eu-west-1 --key ${EC2_KEYPAIR_EU_WEST_1}

eu-west-1 32-bit ebs ami-c00e3cb4 ec2-run-instances ami-c00e3cb4 --instance-type t1.micro --region eu-west-1 --key ${EC2_KEYPAIR_EU_WEST_1}

In my case I will choose the 32 bits instance.

Select no preferences on the Availability zone screen, and leave all the data as appear by default on the Advance Instance Option screen.

Include a tag to identify your instance (this is normally used when you have to manage a big amount of instances) and

Create a new 'Key Pair' in the next screen. This will allow you to connect from your local computer by doing an ssh. If you loose this file you will need to create a new pair and associate your instance with the new one, so save it carfully.

Fig.6 Keys Creation and download


Choose the security group that you created in the previous step and click on Continue.
Fig.7 Security group selection


A final recap like the shown below will be displayed. Just click on launch and you will have your remote Instance running!

Fig.8 Instance recap


You can see your instance under the tab Instances.

Fig.9 Instances list

B. Connecting to the Remote Instance

If you want to connect to your remote instance (I bet you want) right click on your instance and select connect. This will generate a ssh command like: 

ssh -i UbuntuServer32.pem ubuntu@ec2-46-137-60-179.eu-west-1.compute.amazonaws.com


You just have to open a local Terminal, go to the folder where you downloaded your private key (on the step where your instance) and type the ssh command. If everything is ok and you configured the security rules as indicated, you should get a welcome screen like the following one:


Fig.10 Remote connection


Resources

No comments:

Post a Comment