My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SettingUpTwoCouchInstances  
How to setup two couch instances on one machine
Updated Feb 4, 2010 by srlind...@gmail.com

Setting up two couch instances

To really test out the clustering, we'll need two couch instances running. If you'd like to test the Lounge on multiple boxes, you can disregard this step.

Make two copies of your couch.ini

sudo cp /etc/couchdb/couch.ini /etc/couchdb/couch-1.ini
sudo cp /etc/couchdb/couch.ini /etc/couchdb/couch-2.ini

Modify the new couch.ini's

Okay, now open up those new .ini files and change the DbRootDir and LogFile entries to be unique for each couch instance. For couch-2.ini, change the Port entry to be 5985. It should look something like this:

[Couch]
ConsoleStartupMsg=Apache CouchDB is starting.
DbRootDir=/var/lib/couchdb/couch-1
Port=5984
BindAddress=127.0.0.1
DocumentRoot=/usr/share/couchdb/www
LogFile=/var/log/couchdb/0.8.0/couch-1.log
UtilDriverDir=/usr/lib/couchdb/erlang/lib/couch-0.8.0-incubating/priv/lib
LogLevel=info
[Couch Query Servers]
javascript=/usr/bin/couchjs /usr/share/couchdb/server/main.js

Do this for /etc/couchdb/couch-1.ini and /etc/couchdb/couch-2.ini.

Make sure couch-1.ini is listening on 5984 and couch-2.ini is listening on 5985.

Create/Chown the necessary files/directories

sudo mkdir -p /var/lib/couchdb/couch-1 && sudo chown couchdb:couchdb /var/lib/couchdb/couch-1
sudo mkdir -p /var/lib/couchdb/couch-2 && sudo chown couchdb:couchdb /var/lib/couchdb/couch-2

sudo touch /var/run/couchdb-1.pid && sudo chown couchdb:couchdb /var/run/couchdb-1.pid
sudo touch /var/run/couchdb-2.pid && sudo chown couchdb:couchdb /var/run/couchdb-2.pid

Start them

sudo su -c'/usr/bin/couchdb -c /etc/couchdb/couch-1.ini -b -r 5 -p /var/run/couchdb-1.pid -o /dev/null -e /dev/null' couchdb
sudo su -c'/usr/bin/couchdb -c /etc/couchdb/couch-2.ini -b -r 5 -p /var/run/couchdb-2.pid -o /dev/null -e /dev/null' couchdb

You should now have two separate couchdb's running on your system. cool.

Make sure they're running by going to http://localhost:5984 and http://localhost:5985. They should both return {"couchdb":"Welcome","version":"0.8.0-incubating"} (or whatever version of couchdb you're using).

Comment by steeve.m...@gmail.com, Mar 22, 2011

For couchdb 1.0.2 the -c option is to print the config chain, I had to do someting like,

couchdb -n -a /path/to/default.ini -a /path/to/couch-1.ini -b -r5 -p ... couchdb -n -a /path/to/default.ini -a /path/to/couch-2.ini -b -r5 -p ...

The -n option resets the config chain, whcih just ignore the defaults.

Comment by rajakaru...@gmail.com, Oct 12, 2011

this works fine after swapping -c with -a as mentioned above. However, struggling to stop the instances. the only way I seem to be able to do this is kill the actual PIDs - and this is not ideal for a database. I am trying to make a service. If I use "path/to/couchdb -d I get the message that couchdb is already stopped.


Sign in to add a comment
Powered by Google Project Hosting