|
SettingUpTwoCouchInstances
How to setup two couch instances on one machine
Setting up two couch instancesTo 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.inisudo 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'sOkay, 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/directoriessudo 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 themsudo 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). |
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.
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.