croome.org

  • blogs
  • photos
  • contact
Home › Blogs › simon's blog

Running our first Centos 5 virtual machine with Amazon EC2 and a base AMI

simon — Sun, 23/12/2007 - 7:44am

These are my notes on creating an EC2 image for Drupal 5.5 running on Centos 5 and the latest versions of MySQL, Apache and PHP. The intention is to get the base stack running, customise for EC2's characteristics, then publish as a public AMI.

Rather than create yet another base OS image, I'll re-use the Centos 5 image from RightSight. Details at http://developer.amazonwebservices.com/connect/entry.jspa?externalID=821.... At least this image is a known quantity with it's build process automated and available at http://s3.amazonaws.com/rightscale_scripts/Cent5V1.10Install.sh

I'll control EC2 from my local linux box where I've installed the command line tools from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351.... I've also created an Amazon AWS account and copied my public and private key to my linux box. Following the instructions in http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/, I've set up my environment as follows:

echo 'PATH=$PATH:/data/ec2/bin; export PATH' >> ~/.bash_profile
echo 'EC2_HOME=/data/ec2; export EC2_HOME' >> ~/.bash_profile
echo 'JAVA_HOME=/usr/java/jre1.5.0_07; export JAVA_HOME' >> ~/.bash_profile
echo 'EC2_PRIVATE_KEY=/data/ec2/croomes-prv.pem; export EC2_PRIVATE_KEY' >> ~/.bash_profile
echo 'EC2_CERT=/data/ec2/croomes-pub.pem; export EC2_CERT' >> ~/.bash_profile

First, I need to get the AMI ID of the image. This is listed on the AMI detail page or I could find it using ec2-describe-images. The one I want is ami-08f41161.

Before we create the instance we need to generate a public/private keypair for logging into the instance. One half of this keypair will be embedded in the instance, allowing you to login securely without a password using the other half of the keypair.

ec2-add-keypair drupal
KEYPAIR drupal 61:37:ec:5e:3c:64:d8:94:ab:77:0c:a9:63:a1:88:c9:24:49:c2:2d
-----BEGIN RSA PRIVATE KEY-----
... key removed ...
-----END RSA PRIVATE KEY-----
Save the private key (including BEGIN and END lines) into a file for later, and make it only readable by you:

chmod go-rwx drupal.pem; ls -l drupal.pem
-rw------- 1 root root 1676 Dec 23 03:02 drupal.pem

Next, create a new instance of the image:

ec2-run-instances ami-5bae4b32 -k drupal
RESERVATION r-a00ee6c9 665251303620 default
INSTANCE i-a7f405ce ami-5bae4b32 pending drupal 0 m1.small 2007-12-23T07:21:58+0000

ec2-describe-instances
RESERVATION r-850ee6ec 665251303620 default
INSTANCE i-98f405f1 ami-9a9e7bf3 ec2-67-202-24-134.compute-1.amazonaws.com domU-12-31-38-00-29-12.compute-1.internal running drupal 0 m1.small 2007-12-23T07:41:29+0000

For some reason this image doesn't need you to add firewall rules to allow you to SSH to it?


ssh -i drupal.pem ec2-67-202-24-134.compute-1.amazonaws.com
The authenticity of host 'ec2-67-202-24-134.compute-1.amazonaws.com (67.202.24.134)' can't be established.
RSA key fingerprint is 95:c6:24:a7:e2:11:a9:f8:25:1b:fe:2f:29:10:7b:73.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-67-202-24-134.compute-1.amazonaws.com,67.202.24.134' (RSA) to the list of known hosts.
___ _ __ __ ____ __
/ _ \ (_)___ _ / / / /_ / __/____ ___ _ / /___
/ , _// // _ `// _ \/ __/_\ \ / __// _ `// // -_)
/_/|_|/_/ \_, //_//_/\__//___/ \__/ \_,_//_/ \__/
/___/

Welcome to a public Amazon EC2 image brought to you by RightScale!

********************************************************************
********************************************************************
*** WARNING: this server is still being configured by RightScale ***
*** Please wait for configuration to complete ***
*** Status is Available in /var/log/install ***
********************************************************************
********************************************************************
[root@domU-12-31-38-00-29-12:~]
Broadcast message from root (console) (Sun Dec 23 02:48:00 2007):

EC2 instance is now operational. Please review /var/log/install

Next, we'll start customising our image.

  • EC2
  • Linux
  • simon's blog
  • Login or register to post comments

Do you think having a PMP

Harwipas — Thu, 03/03/2011 - 1:10pm

Do you think having a PMP certification is worth it? I know many project managers who say it is

  • Login or register to post comments

Cool!

traveller — Thu, 08/04/2010 - 2:29pm

Хороший сайт :) заглядывайте и ко мне - Скачать фильмы музыку игры :))

  • Login or register to post comments

Navigation

  • Blogs
  • Photos
  • Recent posts
  • blogs
  • photos
  • contact