<?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>Alex Bisignano</title>
	<atom:link href="http://alx.bz/feed/" rel="self" type="application/rss+xml" />
	<link>http://alx.bz</link>
	<description></description>
	<lastBuildDate>Thu, 27 Oct 2011 21:19:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby on Rails 3.1 on Heroku on Amazon RDS &#8211; Set Up Guide for Mac OSX</title>
		<link>http://alx.bz/2011/10/27/ruby-on-rails-3-1-on-heroku-on-amazon-rds-set-up-guide-for-mac-osx/</link>
		<comments>http://alx.bz/2011/10/27/ruby-on-rails-3-1-on-heroku-on-amazon-rds-set-up-guide-for-mac-osx/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 21:19:10 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Amazon AWS]]></category>
		<category><![CDATA[Amazon RDS]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Rails 3.1]]></category>

		<guid isPermaLink="false">http://alx.bz/?p=382</guid>
		<description><![CDATA[<p><img width="300" height="225" src="http://alx.bz/wp-content/uploads/2011/10/thenetworkmedium1600x1200-300x225.jpg" class="attachment-medium wp-post-image" alt="Big Data" title="Big Data" /></p>A walkthrough of setting up Amazon RDS to work on Rails 3.1 deployed on Heroku via a Mac OSX machine.]]></description>
			<content:encoded><![CDATA[<p><img width="300" height="225" src="http://alx.bz/wp-content/uploads/2011/10/thenetworkmedium1600x1200-300x225.jpg" class="attachment-medium wp-post-image" alt="Big Data" title="Big Data" /></p><p>In the past month or so, I&#8217;ve had a great experience learning about the limits of loading data into my relational databases for <a title="The Geno.me" href="http://thegeno.me" target="_blank" onclick="pageTracker._trackPageview('/outgoing/thegeno.me?referer=');">The Geno.me</a>. I started with rake tasks using ActiveRecord inserts. Slow. Then I tried SQL inserts. Slow. Then I tried bulk SQL inserts. Better. Then I realized that loading from large flat files wouldn&#8217;t be super realistic in deployment (the way I was set up). Sqlite3 in development and PG in production on Heroku just wouldn&#8217;t cut it. I&#8217;d ultimately have ~250 GB of genetic data loaded <em>before I even launch</em> the application. What to do?</p>
<p>Amazon RDS. Scalable, simple (ish), and pay for what you use. Perfect. Getting set up&#8230;a bit more involved.</p>
<h3>How to Use Amazon RDS (MySQL) with Your Rails 3.1 App on Heroku</h3>
<p><strong>1. Register for your Amazon Web Services account</strong><br />
This is a pretty easy task. Go <a style="font-size: 13px; font-weight: normal;" title="Amazon Web Services (RDS)" href="http://aws.amazon.com/rds/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/aws.amazon.com/rds/?referer=');">here</a>. Follow directions.</h3>
<p><strong>2. Download and Configure the RDS Command Line Toolkit</strong><br />
The command line toolkit can be found <a style="font-size: 13px; font-weight: normal;" title="Amazon RDS Command Line Toolkit" href="http://aws.amazon.com/developertools/2928" target="_blank" onclick="pageTracker._trackPageview('/outgoing/aws.amazon.com/developertools/2928?referer=');">here</a>. Download and put into a directory that you can easily find. Open the readme.txt and let&#8217;s work through those directions.<br />
1. Make sure Java is installed.<br />
2. Set up environment variables as follows:<br />
AWS_RDS_HOME = Directory where the RDS files were saved.<br />
JAVA_HOME = Java installation directory<br />
AWS_CREDENTIAL_FILE = ${AWS_RDS_HOME}/credential-file-path.template</p>
<p>First road bump for me. I&#8217;m new to Macs. How to set an Environment Variable? This <a title="Mac OSX Set Environment Variable" href="http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x" target="_blank" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/135688/setting-environment-variables-in-os-x?referer=');">StackOverflow post</a> directed me nicely. </p>
<p>Open launchd.conf:</p>
<p><code>$ mate /etc/launchd.conf</code></p>
<p>Here is what I added to my <code>launchd.conf</code> file:</p>
<p>
<code><br />
setenv AWS_RDS_HOME /Developer/RDSCli-1.4.007<br />
setenv JAVA_HOME /Library/Java/Home<br />
setenv AWS_CREDENTIAL_FILE /Developer/RDSCli-1.4.007/credential-file-path.template<br />
</code>
</p>
<p>3. Add your security credentials to the AWS_CREDENTIAL_FILE.</p>
<p><code>$ mate ${AWS_RDS_HOME}/credential-file-path.template</code></p>
<p>Find your security credentials by logging into your AWS account, and click on your name in the upper right corner, and they are listed under &#8216;security credentials.&#8217; Add them to the file, and we are almost there.</p>
<p>4. Add ${AWS_RDS_HOME}/bin to your path.</p>
<p>Again, I&#8217;m new to Macs. How to do this? They actually tell you in the Amazon RDS user-guide, but I can&#8217;t find that pdf right now, so here&#8217;s the command for other newbies like myself:</p>
<p><code>$ export PATH=$PATH:$AWS_RDS_HOME/bin</code></p>
<p>Now all should be working! Test by typing <code>rds --help</code>. If a list of rds commands appeared, then all is good in the hood!</p>
<p><strong>3. Configure the RDS Add-on With Heroku</strong></p>
<p>If you hadn&#8217;t before this step, by now you should have initialized a DB instance on Amazon, otherwise you will have no endpoint/credentials to provide Heroku!</p>
<p>Heroku provides very clear directions for this <a href="http://devcenter.heroku.com/articles/amazon_rds" target="_blank" onclick="pageTracker._trackPageview('/outgoing/devcenter.heroku.com/articles/amazon_rds?referer=');">here</a>. </p>
<p>One note: When adding security group permissions, the command they list tripped me up a bit.</p>
<p><code><br />
rds-authorize-db-security-group-ingress default \<br />
&nbsp;&nbsp;&nbsp;    --ec2-security-group-name default \<br />
&nbsp;&nbsp;&nbsp;    --ec2-security-group-owner-id 098166147350<br />
</code></p>
<p>I didn&#8217;t realize this was meant to be one line and that the backslashes should be ignored. Could have been me being stupid, but I spent over 10 minutes on this. Yep, me being stupid.</p>
<p><strong>4. Update your Gemfile to Include &#8216;mysql2&#8242; in Production</strong></p>
<p>I still like Sqlite3 in development on my local machine, and I was actually having some major issues getting mysql2 to work locally. So, I placed &#8216;mysql2&#8242; into the :production group and called it a day. Of course, &#8216;sqlite3&#8242; should be in the development group. This took a while before Heroku stopped yelling at me, though I can&#8217;t remember why.</p>
<p><strong>5. The Database URL That worked for Heroku&#8217;s Configuration</strong></p>
<p>For some reason, it took me a while to reason out the proper database URL to give to Heroku. They tell you to use:</p>
<p><code>url=mysql://user:pass@rdshostname.amazonaws.com/databasename</code></p>
<p>However, this didn&#8217;t seem to work for me. Some <i>really fancy</i> googling led me to place the following:</p>
<p><code>url=mysql<strong>2</strong>://user:pass@rdshostname.amazonaws.com/databasename</code></p>
<p>I guess there&#8217;s something about the gems that were different? IDK. It works now.</p>
<p>So far I&#8217;m VERY happy with Amazon RDS. More importantly, they allow you to import flat files (CSV) of data as an easy way to fill the database (which is the whole reason I did this). Getting their import to work turned out to be another adventure. But that&#8230;is for another time. Thanks for reading, and hope this helps any other beginners like myself!</p>
]]></content:encoded>
			<wfw:commentRss>http://alx.bz/2011/10/27/ruby-on-rails-3-1-on-heroku-on-amazon-rds-set-up-guide-for-mac-osx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

