Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing CouchDB in AWS EC2 Free Tier

Does anyone know of a step by step installation guide for CouchDB in the free tier 32bit AWS EC2 instance?

Keep in mind that YUM is limited by default and I would need to add yum.repos to get extra stuff. I've tried all different articles and RPMs but none seem to work.

I also tried couchbase but it has extremely poor post-install instructions. The server start but then what? I couldn't find the files, configs, or install directories. And, how do I access it?

CouchDB sounds like such a great database but it really needs to break these barriers of entry. MongoDb has better docs, although I couldn't get that to work either (I spent a fraction of the time trying, though).

Thanks :)

like image 564
Andres Avatar asked May 28 '11 16:05

Andres


People also ask

Which EC2 instances are free tier?

EC2 Free Tier The Free Tier includes 750 hours of Windows, Linux, RHEL, and SLES t2. micro or t3. micro instances each month for one year. To stay within the Free Tier, use only EC2 t2.

Which AMI is free in AWS?

The Amazon Linux AMI is provided at no additional charge to Amazon EC2 users.

Is EC2 t2 micro always free?

T2 instances are available to use in the AWS Free Tier, which includes 750 hours of Linux and Windows t2. micro instances each month for one year for new AWS customers.

How many EC2 instances can I run for free?

Your free usage under the AWS Free Tier is calculated each month across all regions and automatically applied to your bill. For example, you will receive 750 Amazon EC2 Linux Micro Instance hours for free across all of the regions you use, not 750 hours per region.


2 Answers

The apache team put together this quick script that installs CouchDB (thanks @_jhs for build-couchdb!) on an Amazon Linux AMI:

https://gist.github.com/1171217

If you are using cloudinit + the EC2 command line tools, simply use ec2-run-instances with --user-data-file (you will need some mods to the script to save the password or locally generate one) and voila'. Relaxing FTW.

Worked like a charm for me!

like image 110
SantiArias Avatar answered Nov 09 '22 11:11

SantiArias


Here is a quick run down of the steps I use to install couchdb 1.5.1 on Amazon Linux 2014.03.1. See also this post on my blog http://www.everyhaironyourhead.com/installing-couchdb-1-5-1-on-amazon-linux-ami-2014-03-1/.


Core deps and dev tools.

  1. Enable the EPEL Repo by editing the file /etc/yum.repos.d/epel.repo and setting it to enabled.

  2. Next install the deps and tools.

    sudo yum install gcc gcc-c++ libtool libicu-devel openssl-devel autoconf-archive erlang python27 python-sphinx help2man
    

Get the SpiderMonkey JS Engine and build it...

wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvfz js185-1.0.0.tar.gz
cd js-1.8.5/js/src
./configure
make
sudo make install

You should see it installed under /usr/local/lib


Build CouchDB.

  1. Download the source package for CouchDB, unpack it and cd in.

  2. Point it to the required libs and configure.

    ./configure --with-erlang=/usr/lib64/erlang/usr/include --with-js-lib=/usr/local/lib/ --with-js-include=/usr/local/include/js/
    
    make
    
    sudo make install
    

Prepare the CouchDB installation.

  1. Make a couchdb user.

    sudo useradd -r -d /usr/local/var/lib/couchdb -M -s /bin/bash couchdb
    
  2. Set the file ownerships.

    sudo chown -R couchdb:couchdb /usr/local/etc/couchdb
    sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
    sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
    sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb
    sudo chmod 0775 /usr/local/etc/couchdb
    sudo chmod 0775 /usr/local/var/lib/couchdb
    sudo chmod 0775 /usr/local/var/log/couchdb
    sudo chmod 0775 /usr/local/var/run/couchdb
    

Prepare the init scripts.

  1. Link the init script and copy the log rotate script to /etc.

    sudo cp /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d
    sudo ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb
    
  2. This and most other linux distros don’t include /usr/local/lib in ld, so CouchDB will have problems finding the SpiderMonkey libs we installed there earlier. One way to solve this is to add the following line to the top of the /etc/init.d/couchdb startup script.

    export LD_LIBRARY_PATH=/usr/local/lib
    

    See man page for ldconfig for more info, and please comment with a better solution.

  3. You may want to edit /usr/local/etc/default/couchdb to turn off the auto respawn.

  4. To get it to autostart, just use the standard linux setup tools for running service scripts.

    sudo chkconfig --add couchdb
    

    It should pick up the default run levels needed from the script, but in case it doesn’t, you can do it manually like this...

    sudo chkconfig --level 3 couchdb on
    sudo chkconfig --level 4 couchdb on
    sudo chkconfig --level 5 couchdb on
    

    You can sudo chkconfig —list to confirm its there. See man chkconfig for more details.


Relax.

Finally reboot (or just start couchdb from the script) and confirm its running with curl http://127.0.0.1:5984/

Comments, corrections, improvements, and criticisms are appreciated.

like image 43
Raffi M. Avatar answered Nov 09 '22 13:11

Raffi M.