Differences between revisions 2 and 3
Revision 2 as of 2012-04-19 09:53:16
Size: 2485
Editor: chello084112019176
Comment:
Revision 3 as of 2018-04-13 06:04:35
Size: 0
Editor: JoanTouzet
Comment: very outdated
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
<<Include(EditTheWiki)>>

= 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
            └── couchdb
}}}

 * Assuming 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.