Sunday, April 15, 2012

CouchDB on Amazon EC2


https://github.com/iriscouch/build-couchdb (from http://wiki.apache.org/couchdb/Installing_on_Ubuntu)

  • Setup new instance: Ubuntu 11.10
  • ssh to new box
  • run the following to build couchdb from source (packages available via "sudo aptitude install couchdb" are too old):
sudo apt-get install git
sudo apt-get install make gcc zlib1g-dev libssl-dev rake
git clone git://github.com/iriscouch/build-couchdb
cd build-couchdb
git submodule init
git submodule update
rake
couchdb 

ubuntu@ip-10-128-141-191:~/build-couchdb$ couchdb
Apache CouchDB 1.0.1 (LogLevel=info) is starting.

=CRASH REPORT==== 19-Apr-2012::11:28:09 ===
  crasher:
    initial call: couch_event_sup:init/1
    pid: <0.80.0>
    registered_name: []
    exception exit: {{badmatch,
                         {'EXIT',
                             {{badmatch,{error,eacces}},
                              [{couch_log,init,1},
                               {gen_event,server_add_handler,4},
                               {gen_event,handle_msg,5},
                               {proc_lib,init_p_do_apply,3}]}}},
                     [{couch_event_sup,init,1},
                      {gen_server,init_it,6},
                      {proc_lib,init_p_do_apply,3}]}
      in function  gen_server:init_it/6
    ancestors: [couch_primary_services,couch_server_sup,<0.32.0>]
    messages: []
    links: [<0.79.0>,<0.6.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 377
    stack_size: 24
    reductions: 116
  neighbours:

=SUPERVISOR REPORT==== 19-Apr-2012::11:28:09 ===
     Supervisor: {local,couch_primary_services}
     Context:    start_error
     Reason:     {{badmatch,{'EXIT',{{badmatch,{error,eacces}},
                                     [{couch_log,init,1},
                                      {gen_event,server_add_handler,4},
                                      {gen_event,handle_msg,5},
                                      {proc_lib,init_p_do_apply,3}]}}},
                  [{couch_event_sup,init,1},
                   {gen_server,init_it,6},
                   {proc_lib,init_p_do_apply,3}]}
     Offender:   [{pid,undefined},
                  {name,couch_log},
                  {mfargs,{couch_log,start_link,[]}},
                  {restart_type,permanent},
                  {shutdown,brutal_kill},
                  {child_type,worker}]


=SUPERVISOR REPORT==== 19-Apr-2012::11:28:09 ===
     Supervisor: {local,couch_server_sup}
     Context:    start_error
     Reason:     shutdown
     Offender:   [{pid,undefined},
                  {name,couch_primary_services},
                  {mfargs,{couch_server_sup,start_primary_services,[]}},
                  {restart_type,permanent},
                  {shutdown,infinity},
                  {child_type,supervisor}]

=CRASH REPORT==== 19-Apr-2012::11:28:09 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.31.0>
    registered_name: []
    exception exit: {bad_return,
                        {{couch_app,start,
                             [normal,
                              ["/etc/couchdb/default.ini",
                               "/etc/couchdb/local.ini"]]},
                         {'EXIT',
                             {{badmatch,{error,shutdown}},
                              [{couch_server_sup,start_server,1},
                               {application_master,start_it_old,4}]}}}}
      in function  application_master:init/4
    ancestors: [<0.30.0>]
    messages: [{'EXIT',<0.32.0>,normal}]
    links: [<0.30.0>,<0.7.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 987
    stack_size: 24
    reductions: 115
  neighbours:

=INFO REPORT==== 19-Apr-2012::11:28:09 ===
    application: couch
    exited: {bad_return,{{couch_app,start,
                                    [normal,
                                     ["/etc/couchdb/default.ini",
                                      "/etc/couchdb/local.ini"]]},
                         {'EXIT',{{badmatch,{error,shutdown}},
                                  [{couch_server_sup,start_server,1},
                                   {application_master,start_it_old,4}]}}}}
    type: temporary


Alternatives

http://wiki.apache.org/couchdb/Getting_started_with_Amazon_EC2

  • sudo apt-get update && sudo apt-get -y upgrade
  • sudo apt-get install erlang libmozjs-dev libicu-dev libcurl4-gnutls-dev make subversion automake autoconf libtool help2man
  • Fetch, build, and run CouchDB:
    • svn checkout http://svn.apache.org/repos/asf/couchdb/trunk couchdb
    • cd couchdb
    • ./bootstrap
    • ./configure
    • ./configure
    • make && sudo make install
    • sudo adduser --system --home /usr/local/var/lib/couchdb --no-create-home --shell /bin/bash --group --gecos 'CouchDB account' couchdb
    • sudo chown -R couchdb.couchdb /usr/local/var/{lib,log}/couchdb
    • (Optional) Enable direct web access. NOTE: This step makes your CouchDB instance available for everyone. See the FaQ for some (but not all) security options.
      • sudo vim /usr/local/etc/couchdb/local.ini 
      • Search for "bind_address", uncomment it, and change it to 0.0.0.0
      • Save and exit
    • (Alternative option) Set up port forwarding to access your DB, for example with SSH.
      • ssh -L 5984:localhost:5984 -l ubuntu <public DNS name>
      • Leave that session open as long as you need the proxy to work
      • Your new DB URL will be http://127.0.0.1:5984/ instead.
    • sudo -i -u couchdb couchdb 
    • Test it by going to http://<public dns name>:5984/_utils/