I’ll be writing up what we’ve done here in several parts. Sign up for my RSS feed to keep updated.
Part five covers the setting up of broadcast servers using Amazon EC2.
If you’ve never worked with Amazon EC2 before, please follow my ‘Getting Started‘ guide first.
In a previous part, we covered nginx setup set-by-step, so this time we’re going to look at creating a set of cloud servers with a single line of code.
Required: ec2 command line tools
Amazon AMIs allow you to pass ‘user-data’ into the image. The alestic AMIs are configured to allow this data to be executed as soon as the machine starts. For more on this, have a look at their article “Automate EC2 Instance Setup with user-data Scripts“.
I’m going to use a script called “install-nginx-mclaren“. Save it to your working folder now, and execute the lines below from the same folder.
This script was quite hard to write, due to various complications with the way the script gets passed in. Line breaks are particularly difficult, and it’s always hard to set values deep in a configuration file using a script.
ec2-run-instances -n 1 --key mclarenkey --user-data-file install-nginx-mclaren ami-bdc0ebc9 -t c1.xlarge
'n' is the number of instances to start.
This starts a 64-bit 8-core 7GB “High-CPU Extra Large” Server running an Ubuntu 9.10 Karmic AMI, from Alestic.com
Your server is now visible in the Amazon AWS Management Console.
After around a minute, your servers should be running. You can view them by typing:
[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US RESERVATION r-66ca1711 893696797735 default INSTANCE i-ecde7c9b ami-b3c0ebc7 ec2-12-345-67-89.eu-west-1.compute.amazonaws.com ip-10-226-42-19.eu-west-1.compute.internal running mclarenkey 0 m1.small 2010-03-16T10:50:47+0000 eu-west-1a aki-b02a01c4 ari-39c2e94d monitoring-disabled 12.345.67.89 10.226.42.19 ebs BLOCKDEVICE /dev/sda1 vol-62967b0b 2010-03-16T10:50:57.000Z
You can now see the Public DNS to connect.
When using ssh, connect as user “ubuntu” (this is related to the choice of AMI)
ssh -i ~/.ssh/mclarenkey.pem firstname.lastname@example.org
It will take a few minutes for the setup script to run. You can watch it in action like so:
tail -f /var/log/syslog
Our server is now running!
View it here:
If all is well, you’ll be sent straight to mclaren.com!
More useful are the feed urls:
Remember to pop into your nginx conf file and configure your POST IPs!
In the final part in the series, I’ll cover monitoring.