<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jon&#039;s Blog &#187; AWS</title>
	<atom:link href="http://bombdiggity.net/blog/tag/aws/feed/" rel="self" type="application/rss+xml" />
	<link>http://bombdiggity.net/blog</link>
	<description>Ramblings of a php coder</description>
	<lastBuildDate>Fri, 14 May 2010 17:36:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zend Framework Ec2 API</title>
		<link>http://bombdiggity.net/blog/2009/03/27/zend-framework-ec2-api/</link>
		<comments>http://bombdiggity.net/blog/2009/03/27/zend-framework-ec2-api/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 04:33:57 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Amazon AWS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[EC2]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=133</guid>
		<description><![CDATA[So about two weeks ago Wil Sinclair from Zend pinged me about creating an Zend Framework API interface for Amazon Ec2. I was coming off of playing around with Ec2 for work and figured I would give it a shot. With the proposal filed I began the task of coding it out. After two weeks [...]]]></description>
			<content:encoded><![CDATA[<p>So about two weeks ago Wil Sinclair from Zend pinged me about creating an<a href="http://framework.zend.com/"> Zend Framework</a> API interface for Amazon Ec2. I was coming off of playing around with Ec2 for work and figured I would give it a shot. With the <a title="Zend_Service_Amazon_Ec2 Proposal" href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Service_Amazon_Ec2+-+Jon+Whitcraft">proposal filed</a> I began the task of coding it out. After two weeks of writing code I had a working interface for the Query API from Amazon.</p>
<p>I do have to say I learned a lot while doing the inital work and I&#8217;m happy that Wil pinged me to do it. If you want to check out the code currently it lives on <a href="http://github.com/sidhighwind/zend_service_amazon_ec2/tree/master">github</a> but it is on track to make the 1.8 release of Zend Framework.</p>
<p>Please leave a commet here or on the proposal for anything that I may have over looked or if you have any ideas on how I could make it better.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2009/03/27/zend-framework-ec2-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Splitting Tar Archives&#8230;</title>
		<link>http://bombdiggity.net/blog/2009/03/06/splitting-tar-archives/</link>
		<comments>http://bombdiggity.net/blog/2009/03/06/splitting-tar-archives/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 14:32:34 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Amazon AWS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=117</guid>
		<description><![CDATA[With working on deploying sites on Amazon EC2 we wanted to cut down on the time that it took to sync the sites from our seed servers to the new server. Our logical way to do this was to put a snapshot of the sites are Amazon S3 as a tgz file. Our sites are [...]]]></description>
			<content:encoded><![CDATA[<p>With working on deploying sites on Amazon EC2 we wanted to cut down on the time that it took to sync the sites from our seed servers to the new server.  Our logical way to do this was to put a snapshot of the sites are Amazon S3 as a tgz file.  Our sites are around 2gb each and while that is no problem to S3 as it max file size is 5gb but in interest of taking less time to upload each site and save on the chance of the file be corrupted on upload we decided to split the files.</p>
<h3><span id="more-117"></span>Splitting The Archive In To Pieces.</h3>
<pre class="brush: bash">
tar czPf - /dir_to_tar/ | split -b 200m -d - test_backup.tgz.
</pre>
<p>The code is very simple.  First well tell <a title="Gnu Tar man page" href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=3&amp;url=http%3A%2F%2Fwww.gnu.org%2Fsoftware%2Ftar%2Fmanual%2Ftar.html&amp;ei=ZTSxSd6YOIKyNM_l7cYE&amp;usg=AFQjCNEzGYgb_p-YLD-0JPJw5Lawxxdj9Q&amp;sig2=H5dSlNqZ1NKfNUKBGI1miw">tar</a> to create (c), gzip (g), absolute names (P) and force (f) and the path that we want in the archive.  It then gets piped to the <a title="Split man page" href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Funixhelp.ed.ac.uk%2FCGI%2Fman-cgi%3Fsplit&amp;ei=kjSxSdK7KI6-M8fQqMUE&amp;usg=AFQjCNFXY1GH8Ze_F4t8PDhjiObJFdcOTA&amp;sig2=k4MMPmg59miHMyjqaF7Ybw">split</a> command where split is told to make no larger than 200mb files (b) and to put numeric suffixes on the files (d).  Since we don&#8217;t have an input file the &#8211; represents the stream in from the tar command and we want it to output to test_backup.tgz. as the 00, 01, 02&#8230;. will be added to the end of that file.</p>
<p>After that is done running we just put the files on s3 using the <a title="s3Sync" href="http://s3sync.net/wiki">s3Sync</a> utility.</p>
<h3>Combining The Pieces In To One Archive:</h3>
<p>What happens when you want to extract the archive that you split.  You can just extract each file like you normally do.  This is how I do it but I&#8217;m always open for better ideas.</p>
<pre class="brush: bash">
cat test_backup.tgz.* &gt; test_backup.tgz
</pre>
<p>I must state that I&#8217;ve never had a split archive over 09 so i&#8217;m not sure how it will act when when you get more than that but like I said before if you have any better methods I&#8217;m open to new and better ways.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2009/03/06/splitting-tar-archives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What fun Amazon EC2 is &#8211; Part 1: Instance Management</title>
		<link>http://bombdiggity.net/blog/2009/03/04/what-fun-amazon-ec2-is-part-1/</link>
		<comments>http://bombdiggity.net/blog/2009/03/04/what-fun-amazon-ec2-is-part-1/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 02:51:42 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Amazon AWS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[EC2]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=92</guid>
		<description><![CDATA[So as of late I have been doing a lot of programming to have a some what automated way to scale out indycar.com and indy500.com when the time calls for us to scale out. To scale out we are using Amazon EC2 with a great deal of success. Last year we successfully made it through [...]]]></description>
			<content:encoded><![CDATA[<p>So as of late I have been doing a lot of programming to have a some what automated way to scale out <a title="IndyCar Series" href="http://www.indycar.com">indycar.com</a> and <a title="Indianapolis 500" href="http://www.indy500.com">indy500.com</a> when the time calls for us to scale out. To scale out we are using <a title="Amazon EC2" href="http://aws.amazon.com/ec2/">Amazon EC2 </a>with a great deal of success. Last year we successfully made it through a season with using EC2. The biggest problem we ran into was the time it took to scale out.</p>
<p><span id="more-92"></span></p>
<p>Scaling out the old way took almost an hour to do and was mostly a non-automated process. Now if you know me at all I automate any thing and everything that I can.</p>
<p>To have an efficent way to automate the instance management I setup a instance admin and support init.d script to help maintain the state of all the running instances.</p>
<p>To create the site I started with Zend Framework as the base for the site as it has everything that I need rolled in to one nice neat package. I created a module to handle the starting, stopping and listing of the instances. To make the start and stop work properly I had to have a bash script that would run on startup and shutdown to notify the instance admin the an instance was started or stopped.</p>
<pre class="brush: bash">
#!/bin/sh
#
# chkconfig: 2345 99 00
# description: register the config with the ims home base servers

. /etc/rc.d/init.d/functions

# Source in our AWS Credentials
. /root/instance/bin/aws_credentials

# check for mysql to be installed
if [ ! -e /usr/bin/mysql ]; then
yum install -y mysql
fi

# Define some Variables

hostname=`hostname`
internal_ip=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
get_address=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
ip_convert=${get_address//./-}

my_meta=(
&quot;instance-id&quot;
&quot;ami-id&quot;
&quot;local-hostname&quot;
&quot;local-ipv4&quot;
&quot;public-hostname&quot;
&quot;public-ipv4&quot;
&quot;instance-type&quot;
&quot;public-keys&quot;
&quot;placement/availability-zone&quot;
)

for p in ${my_meta[*]}
do
data=( `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/$p/` )
if [[ $data == *=* ]]; then
data=`echo $data | awk -F &quot;=&quot; &#039;{print $2}&#039;`
fi
sql_arg=( &quot;${sql_arg[@]}&quot; &quot;$data&quot; )
done

sql_conn=&quot;-u MYSQLUSER -pMYSQLPASS -h MYSQLSERVER&quot;
assigned_ip=`mysql $sql_conn -B -N -e &quot;select ext_address from cloud.instance where ext_host=&#039;$hostname&#039;;&quot;`
eip_state=`mysql $sql_conn -B -N -e &quot;select eip_state from cloud.instance where ext_host=&#039;$hostname&#039;;&quot;`

start() {

if [ &quot;$eip_state&quot; != &quot;1&quot; ]; then

# we have an elastic ip so assign it
if [[ -n $assigned_ip &amp;amp;&amp;amp; &quot;$get_address&quot; != &quot;$assigned_ip&quot; ]]; then
#we have an elastic ip
/root/instance/ec2/bin/ec2-associate-address --private-key $EC2_PRIVATE_KEY --cert $EC2_CERT $assigned_ip -i ${sql_arg[0]}
get_address=$assigned_ip;
fi

# send the data off to the instanceadmin to have it finish the process
URL_POST=&quot;inst=${sql_arg[0]}&amp;amp;image=${sql_arg[1]}&amp;amp;int_host=${sql_arg[2]}&amp;amp;keypair=${sql_arg[7]}&amp;amp;type=${sql_arg[6]}&amp;amp;zone=${sql_arg[8]}&amp;amp;ext_host=$hostname&amp;amp;ext_address=$get_address&amp;amp;int_address=$internal_ip&quot;

curl -s -d $URL_POST http://INSTANCEADMIN/instance/start

touch /var/lock/subsys/ims_instance
exit 0
else
echo $hostname &quot; has already been registred with home base&quot;
exit 1
fi
}

stop() {
if [ &quot;$eip_state&quot; != &quot;0&quot; ]; then

# send the data off to the instanceadmin to have it finish the process
URL_POST=&quot;inst=&amp;amp;image=&amp;amp;int_host=&amp;amp;keypair=&amp;amp;type=&amp;amp;launched=&amp;amp;zone=&amp;amp;ext_host=$hostname&amp;amp;ext_address=$get_address&amp;amp;int_address=&quot;

curl -s -d $URL_POST http://INSTANCEADMIN/instance/stop

rm -f /var/lock/subsys/ims_instance
exit 0
else
echo $hostname &quot; is already unregistred with home base&quot;
exit 1
fi
}

restart() {
stop
start
}

case &quot;$1&quot; in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo &quot;Usage $0 { start | stop | restart }&quot;
exit 1
;;
esac
exit 0
</pre>
<p>As you can see from the code it&#8217;s your basic init.d script that.  Not this is meant to run on CentOS or RedHat EC2 instances.  When the start is called is sends all the information about the instance to the instance admin where it stores it in the database and sends out an email.  Stop does the same thing except it clears out the database (with exception of the hostname and the external ip, if it&#8217;s an elastic ip).  Doing this makes it easier to see which instances are running because you can actually see a domain associated with an instance-id instead of just an instance-id.</p>
<p>That&#8217;s it for part 1. In Part 2, I will outline the processed I used to have an instance build it self.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2009/03/04/what-fun-amazon-ec2-is-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
