You need to be added to the ContributorsGroup to edit the wiki. But don't worry! Just email any Mailing List or grab us on IRC and let us know your user name. |
Setting up Additional CouchDB Instances
While most of the time, it's sufficient to have different applications stored in separate design docs, or in separate DBs, sometimes you just need a separate instance. For example, SSL certificates and port/ip addresses are bound to the erlang instance, not the individual database.
This is the file structure you'll need to create:
lib/couchdb for the couchdb data files
{log,run}/couchdb/ are self explanatory
and a single etc/couchdb/local.ini which will over-ride the system-installed CouchDB default.ini at runtime
couchdb
├── etc
│ └── couchdb
│ └── local.ini
└── var
├── lib
│ └── couchdb
├── log
│ └── couchdb
└── run
└── couchdbAssuming you adapt OLD & NEW as appropriate, here's how to set it up:
% OLD=/usr/local
% NEW=/tmp/couchdb
% mkdir -p $NEW/etc/couchdb/
% mkdir -p $NEW/var/{lib,log,run}/couchdb/
% cp $OLD/etc/couchdb/local.ini $NEW/etc/couchdb/
% tree -l $NEW
[...tedious output omitted...]Don't forget to chown/chmod all these dirs and files so that the future CouchDB user has r/w permissions.
Finally, you then need to adapt local.ini for these new locations, and obviously include a different port/bind_address combo
[couchdb] database_dir = /tmp/couchdb/var/lib/couchdb view_index_dir = /tmp/couchdb/var/lib/couchdb uri_file = /tmp/couchdb/var/run/couchdb/couch.uri [httpd] port = 5985 bind_address = 0.0.0.0 [log] file = /tmp/couchdb/var/log/couchdb/couch.log
You can test this by running couchdb (in my case interactively using -i):
% couchdb -i -a /tmp/couchdb/etc/couchdb/local.ini
And Relax.
Caveats
The original local.ini is still included in the configuration chain. You can see this by running:
% couchdb -i -a /tmp/couchdb/etc/couchdb/local.ini -c /usr/local/etc/couchdb/default.ini /usr/local/etc/couchdb/local.ini /tmp/couchdb/etc/couchdb/local.ini
This means anything (for example server admins (in [admins] or SSL certificates in [ssl]) that are not over-ridden in your newer config file will apply. If you've got server admins created then don't forget to prune them in the duplicated local.ini if needed.