Read the Getting Started part of Till Klampäckel’s CouchDB on Ubuntu on AWS blog post for some general information. I see no reason to repeat those things here.
Till stresses the need for a security group opening port 80, but you should also enable ssh at port 22, otherwise it will be impossible to isntall anything. The AMI I use is rightscale’s CentOS 5.2 i386 v4.2.4. If you need a 64-bit image, that should work just as well.
Make sure you have Sprinkle installed on you the system you are installing from. Put this in your spinkle file and name it something reasonable. I called it couchdb.rb. If not, gem install sprinkle. Sprinkle is written in Ruby so if you don’t have Ruby, you should start by installing that.
# Sprinkle provisioning and deployment for CouchDB on
# an Amazon EC2 CentOS server
package :spidermonkey do
source 'http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz' do
custom_dir 'js/src'
custom_install "make BUILD_OPT=1 -f Makefile.ref && cp *.{h,tbl} /usr/include/ && cd Linux_All_OPT.OBJ && cp *.h /usr/include/ && mkdir -p /usr/{bin,lib}/ && cp js /usr/bin/ && cp libjs.so /usr/lib/"
end
verify do
has_executable 'js'
has_file '/usr/include/jsapi.h'
has_file '/usr/lib/libjs.so'
end
end
package :erlang_dependencies do
yum %w( ncurses-devel openssl-devel)
end
package :erlang do
description 'Erlang, the programming language'
source 'http://erlang.org/download/otp_src_R13B01.tar.gz'
verify do
has_executable '/usr/local/bin/erl'
end
requires :erlang_dependencies
end
package :couchdb_dependencies do
yum %w( curl curl-devel icu libicu-devel )
end
# - CouchDB 0.9.1
package :couchdb, :provides => :database do
description 'CouchDB'
version '0.9.1'
source 'http://mirrorservice.nomedia.no/apache.org/couchdb/0.9.1/apache-couchdb-0.9.1.tar.gz' do
post :install, 'adduser -r -d /usr/local/var/lib/couchdb -M -s /bin/bash -c "CouchDB Administrator" couchdb'
post :install, 'touch /usr/local/var/log/couchdb/couch.log'
post :install, 'chown couchdb /usr/local/var/log/couchdb/couch.log'
post :install, 'mkdir -p /usr/local/var/lib/couchdb'
post :install, 'chown couchdb /usr/local/var/lib/couchdb'
post :install, '/usr/local/etc/rc.d/couchdb start'
post :install, 'ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb'
post :install, 'chkconfig --add couchdb'
end
verify do
has_executable '/usr/local/bin/couchdb'
end
requires :couchdb_dependencies
requires :erlang
requires :spidermonkey
end
package :rubygems do
description 'Ruby Gems Package Management System'
yum 'rubygems'
end
package :couchrest do
description 'Rest API for CouchDB'
version '0.33'
gem 'couchrest'
end
policy :db, :roles => :db do
requires :database
requires :couchrest
end
# Deployment
deployment do
delivery :capistrano do
set :user, 'root'
set :use_sudo, false
set :run_method, :run
role :db, 'ec2-x-y-z-w.eu-west-1.compute.amazonaws.com'
end
# source based package installer defaults
source do
prefix '/usr/local' # where all source packages will be configured to install
archives '/usr/local/sources' # where all source packages will be downloaded to
builds '/usr/local/build' # where all source packages will be built
end
end
Replace ec2-x-y-z-w.eu-west-1.compute.amazonaws.com with the public DNS name listed on the Amazon Web Services instance view. You don’t need rubygems and couchrest unless you are going to use Ruby, but I decided to leave them since CouchRest is a nice libarary to use when talking to CouchDB from Ruby.
Run it in a shell with sprinkle -s couchdb.rb
. Might be interesting to check the powder cloud like this first: sprinkle -cts couchdb.rb
. The expected cloud looks liek this:
--> Cloud hierarchy for policy db
Policy db requires package database
Selecting couchdb for virtual package database
Package couchdb requires couchdb_dependencies
Package couchdb requires erlang
Package erlang requires erlang_dependencies
Package couchdb requires spidermonkey
Policy db requires package couchrest
Package couchrest requires rubygems
Set up an SSH tunnel to get the remote futonI tend to use 5994 locally to avoid conflicts with the local CouchDB. ssh -L 5994:localhost:5984 root@ec2-x-y-z-w.eu-west-1.compute.amazonaws.com
where once again, ec2-x-y-z-w.eu-west-1.compute.amazonaws.com should be replaced with the public DNS name listed on the Amazon Web Services instance view. Point your browser to http://localhost:5994/_utils/ for that familiar futon view.