I've been using AWS for a while, mostly to store a ton of personal junk in S3 and Glacier, so the obvious choice is to launch an EC2 instance. I'm quite fond of micro-sized instances based on ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1 (ami-ce7b6fba): 1 core, 600 MB of RAM, 8 GB of disk... and free :) Perfect for experimentation!
If you need to setup your own account, here's where to start. It's a straightforward process, no need to cover it in detail. Just some quick advice:
- Once you've created and downloaded the key pair associated to the instance, don't forget to chmod it to 400 (or 'ssh' will complain that it's not safe, bla bla bla)
- DO NOT LOSE THE KEYPAIR FILE, you won't be able to download it again.
- When the instance is running, make sure you note its public name (e.g. ec2-54-217-8-54.eu-west-1.compute.amazonaws.com), that's the one you'll use from the outside world.
- The 'ssh' port (22) is not open by default. "Security Groups" is where you need to look, just add a rule opening 22/TCP.
$ ssh -i keypair.pem ubuntu@ec2-54-217-8-54.eu-west-1.compute.amazonaws.com
ubuntu@ip-10-48-247-163:~$
Congratulations, you're on AWS. Now, let's add some more software to this instance:
ubuntu@ip-10-48-247-163:~$ sudo apt-get updateCongratulations, you're on AWS. Now, let's add some more software to this instance:
ubuntu@ip-10-48-247-163:~$ sudo apt-get install mongodb-clients
Can't wait to connect to your db? All right, let's give it a try with the 'mongo' client:
ubuntu@ip-10-48-247-163:~$ mongo -u USERNAME -p PASSWORD ds051067.mongolab.com:51067/mongolab-test
MongoDB shell version: 2.0.4
connecting to: ds051067.mongolab.com:51067/mongolab-test
> show collections
collection1
objectlabs-system
objectlabs-system.admin.collections
system.indexes
system.users
This MongoDB instance is hosted by MongoLab in AWS, so we didn't travel too far. A nice mix of PaaS and IaaS, all based on the same infrastructure :)
Now let's add our Python tools:
ubuntu@ip-10-48-247-163:~$ sudo apt-get install build-essential python-devNow let's add our Python tools:
ubuntu@ip-10-48-247-163:~$ sudo apt-get install python-pip
ubuntu@ip-10-48-247-163:~$ sudo pip install pymongoLet's copy our Python program to our EC2 instance:
$ scp -i keypair.pem mongo.py ubuntu@ec2-54-217-8-54.eu-west-1.compute.amazonaws.com:~
mongo.py
And now:
ubuntu@ip-10-48-247-163:~$ python mongo.py
{u'x': 1.0, u'_id': ObjectId('51e3ce08915082db3df32bf0')}
{u'x': 2.0, u'_id': ObjectId('51e3ce08915082db3df32bf1')}
{u'x': 3.0, u'_id': ObjectId('51e3ce08915082db3df32bf2')}
output removed from brevity
{u'x': 25.0, u'_id': ObjectId('51e3ce08915082db3df32c08')}
- the insane amount of software technology available to anyone willing to read a few books or wikis
- how easy it is to get started and build fun stuff. You need nothing else on your own machine than 'ssh'!
- it's all free (or very very unexpensive)
None of this was possible 10 years ago. Back in the day.... well, who cares. You kids sure have it too easy, so stop wasting your time on Facebook or on reality TV (absolute scum, will it ever stop?), learn some proper engineering skills, get smart and start solving some problems, ok? There ain't no shortage of them!
Old man over and out.
No comments:
Post a Comment