Archive

Archive for the ‘Amazon EC2’ Category

How to Install a Puppet Master and Client Server on Centos 5.2

February 21st, 2009 No comments

Puppet is an open-source next-generation server automation tool. It is composed of a declarative language for expressing system configuration, a client and server for distributing it, and a library for realizing the configuration.

Setup the EPEL repos for Centos – choose the correct package depending on  your installation.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

Install puppet-server

yum install puppet-server

The 1.8.5 branch of Ruby shipped will RHEL5 can exhibit memory leaks. So install ruby 1.8.6++ (I did not on this server as it was  test not a production server).

Install the help docs

yum install ruby-rdoc

Create a manifest file at /etc/puppet/manifests/default.pp

vi /etc/puppet/manifests/default.pp

put this in it

# Create “/tmp/testfile” if it doesn’t exist.

class test_class {

    file { “/tmp/testfile”:

       ensure => present,

       mode   => 644,

       owner  => root,

       group  => root

    }

}

# tell puppet on which client to run the class

node pclient {

    include test_class

}

Start the puppet server

service puppetmaster start

Enable start on boot

chkconfig puppetmaster on

Now to install the Puppet Client on another server

Setup the EPEL repos for Centos – choose the correct package depending on  your installation.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

Install puppet

yum install puppet

Setup puppet client to generate its own certificate request to the server

/etc/init.d/puppet once -v

Sign the certificate request on the puppet master server.  Use puppetca –list to see if any are available to sign.

puppetca –sign puppet01

Puppet01 must be the fully qualified domain name (FQDN) of you client server.

Run this on the client server again to retrieve the certificate

/etc/init.d/puppet once -v

Make the puppet start with the system

chkconfig puppet on

Make sure it is working on the client server.

puppet –test

You should see a dialog that creates the file /tmp/testfile

AttributeError: CHECKSUM_VALUE Error with Rightscale Centos AMI Creation Script

February 19th, 2009 No comments

Rightscale created a great script to build an AMI from scratch – see http://blog.rightscale.com/2007/09/26/rightimages-changelog/

I got this error when trying to build the image from YUM.

AttributeError: CHECKSUM_VALUE rightscale

This worked for me;

rpm -qa | grep yum-metadata-parser
rpm -ev –nodeps yum-metadata-parser-VERSIONFROMABOVECMD

cd /tmp
wget ftp://ftp.univie.ac.at/systems/linux…8.fc6.i386.rpm
rpm -iv ./yum-metadata-parser-1.0-8.fc6.i386.rpm 
yum check-update

See - http://www.linuxforums.org/forum/redhat-fedora-linux-help/122580-solved-yum-update-fails-attributeerror-checksum_value.html

Categories: Amazon EC2 Tags: ,

How To Create a Centos 5.2 EC2 Amazon Machine Image – AMI

February 13th, 2009 2 comments
Create the disk image
dd if=/dev/zero of=my-image.fs bs=1M count=1024
Create root file system inside file
mke2fs -F -j my-image.fs
Mount it
mkdir /mnt/ec2-fs
mount -o loop my-image.fs /mnt/ec2-fs
Create /dev
mkdir /mnt/ec2-fs/dev
Populate /dev with a minimal set of devices
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x console
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x null
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x zero
Create /etc
mkdir /mnt/ec2-fs/etc
Create yum-xen.conf in the local file system, not the mounted system.  Put the following in yum-xen.conf
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
exclude=*-debuginfo
gpgcheck=0
obsoletes=1
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
reposdir=/dev/null
metadata_expire=1800
[base]
name=CentOS-5.2 – Base
baseurl=http://mirror.centos.org/centos/5.2/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5.2
priority=1
protect=1
#released updates
[update]
name=CentOS-5.2 – Updates
baseurl=http://mirror.centos.org/centos/5.2/updates/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5.2
priority=1
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-5.2 – Addons
baseurl=http://mirror.centos.org/centos/5.2/addons/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5.2
priority=1
[extras]
name=CentOS 5.2 Extras $releasever – $basearch
baseurl=http://mirror.centos.org/centos/5.2/extras/i386/
enabled=1
Mount proc
mkdir /mnt/ec2-fs/proc
mount -t proc none /mnt/ec2-fs/proc
Install the Operating System
yum -c yum-xen.conf –installroot=/mnt/ec2-fs -y groupinstall Core
 Create the network settings
vi /mnt/ec2-fs/etc/sysconfig/network-scripts/ifcfg-eth0
Enter
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
Turn on networking
vi /mnt/ec2-fs/etc/sysconfig/network
Enter
NETWORKING=yes
Set up the hard drives
vi /mnt/ec2-fs/etc/fstab
Enter 
/dev/sda2  /mnt      ext3    defaults        1 2
/dev/sda3  swap      swap    defaults        0 0
Start some services on start
chroot /mnt/ec2-fs /bin/sh
chkconfig –level 345 sshd on
exit
Unmount the image
umount /mnt/ec2-fs/proc
umount -d /mnt/ec2-fs 
Now bundle the AMI
Install ruby
yum install ruby
Download the EC2 AMI Tools 
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
Install the EC2 AMI Tools
rpm -Uvh ec2-ami-tools.noarch.rpm
Put both your private key and cert in the same folder as my-image.fs
Use the AMI tools to bundle the your image
ec2-bundle-image -i my-image.fs -c my-cert.pem -k my-private-key.pem -u 12345678(amazon account id)  
nb. Selinux should be disabled while this is done.
This create the bundles the image to an AMI and puts it in /tmp
Now upload the  ec2-bundle to S3
ec2-upload-bundle -b my-bucket -m image.manifest -a my-aws-access-key-id -s my-secret-key-id 
This is a good resource on how to script the whole thing – http://www.centos.org/modules/newbb/viewtopic.php?topic_id=11788&forum=27&post_id=38389

Two Great Firefox Extensions for Amazon EC2 and S3

February 13th, 2009 No comments

These are great tools to get started on Amazon’s EC2 and S3 products.

Elasticfox - http://developer.amazonwebservices.com/connect/entry.jspa?externalID=609

S3fox - https://addons.mozilla.org/en-US/firefox/addons/policy/0/3247/41288

Anyone know of any better/alternative tools, let me know.

How To Install EC2 Automatic Scaling App Scalr on Centos 5.2

February 12th, 2009 No comments

Scalr is a fully redundant, self-curing and self-scaling hosting environment utilizing Amazon’s EC2.

It allows you to create server farms through a web-based interface using prebuilt AMI’s for load balancers (pound or nginx), app servers (apache, others), databases (mysql master-slave, others), and a generic AMI to build on top of. (see http://code.google.com/p/scalr/)

Install the necessary packages

You will need utterramblings repo’s to install PHP 5.2.6, see - http://www.how-to-linux.com/2008/12/how-to-upgrade-to-php-526-on-centos-52/

yum install httpd mysql-server gcc mysql-server php-devel php-cli php-mysql php-mcrypt php-mhash php-snmp php-pear php-soap php-xml

You will need to install ssh2 php support, currently it is still in beta use;

libssh2 from yum does not work so build the one scalr needs from source

wget http://downloads.sourceforge.net/libssh2/libssh2-1.0.tar.gz?modtime=1230332100&big_mirror=0

./configure

make

make install

Then

pecl install ssh2-beta

Now you need to update your php.ini file by adding

extension=ssh2.so

Restart your webserver

service httpd restart

See install instructions – http://th.php.net/manual/en/ssh2.installation.php

Use the scalr’s checkenvironment.php script to check everything is ok.

wget http://scalr.googlecode.com/files/checkenvironment.php

chmod 777 checkenvironment.php

Run it on the command line

php checkenvironment.php

Download the scalr tar package 

wget http://scalr.googlecode.com/files/scalr-1.0RC3.tar.gz

untar

tar xvfz scalr-1.0RC3.tar.gz

mv the contents of the app folder to /var/www/html/

mv scalr/app/* /var/www/html/

Set permissions on the following folders (and subfolders) and files to 777 (world-writable):

cache

cron/cron.pid

etc/.passwd

Create a mysql database and import data

mysql -u root

create database scalr;

quit

mysql -u root -h localhost scalr < sql/database.sql

Edit the database config settings in etc/config.ini file.

Set Cron jobs

For system to work properly, it needs to run a few tasks periodicaly. Scalr has a single cron/cron.php file that must be executed with various command-line switches. The following tasks must be sheduled:

* * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –Poller

1 1 * * * /path/to/php -q /scalr_home_dir/cron/cron.php –RotateLogs

*/15 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –MySQLMaintenance

*/6 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –DNSMaintenance

*/3 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –DNSZoneListUpdate

*/2 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –DBQueueEvent

*/11 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –Cleaner

*/2 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –EBSQueue

Scalr needs your keys..

Sclar needs to have AWS access.

  1. Put your EC2 access certificate into /scalr_home_dir/etc/cert-XXXXXXXXXXXX.pem
  2. Put your EC2 private key into /scalr_home_dir/etc/pk-XXXXXXXXXXXX.pem

Now goto http://localhost/

username and password is admin/admin

I had a 403 error when trying to access scalr, this was because I had SElinux enabled, disable this if its a test machine.

After the install I found this, anothe useful resource if you have problems - http://groups.google.com/group/scalr-discuss/web/scalr-on-centos-5-install-notes

Categories: Amazon EC2, Centos 5.2 Tags: , ,

How to Setup Amazon EC2 AMI Tools on Vista

February 11th, 2009 No comments

Download the zip package – http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip

Unzip it and put it in C:\ec2

Set your environment variables, there are 2 ways to do this. 

1. Control Panel – System – Advanced System Settings – Environment Variables – User Variables

2. In the cmd application

This are the cmd.exe commands to set variables.

Set Java and EC2 Home variables.

set EC2_HOME=C:\ec2

set JAVA_HOME=<PATH> (find it in program files)

Set Identity variables

C:\> set EC2_PRIVATE_KEY=c:\ec2\pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem 

C:\> set EC2_CERT=c:\ec2\cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem  

Categories: Amazon EC2 Tags: , ,