Skip to content

Instantly share code, notes, and snippets.

@adamcrown
Forked from SinanGabel/Cluster setup hints
Created October 29, 2016 09:50
Show Gist options
  • Save adamcrown/48d60719470ac5371cd33b176b3caf33 to your computer and use it in GitHub Desktop.
Save adamcrown/48d60719470ac5371cd33b176b3caf33 to your computer and use it in GitHub Desktop.
CouchDB 1.7.0 (1.x.x) / 2.0 (release-candidate) on Ubuntu 16.04
# Tried on Ubuntu 16.04 Desktop
# Refer to: http://couchdb.apache.org/release-candidate/2.0/
# (1) Install npm and nodejs
# Run this command and if it says “install” in the right column - “node” is on your system:
pkg --get-selections | grep node
# To remove eventual old node package, run:
apt-get remove --purge node
apt-get update
apt-get install nodejs
apt-get install npm
# (possibly) Create a symbolic link for “node” as many Node.js tools use this name to execute
ln -s /usr/bin/nodejs /usr/bin/node
# Check versions of node and npm
node -v
npm -v
# (2) Installing the same as in (see below) couchdb_1.7.0_install.sh file down to fetching the couchdb files i.e.:
apt-get update
# -y flag: assume Yes to all queries and do not prompt
apt-get install -y build-essential
apt-get install -y erlang-dev erlang-manpages erlang-base-hipe erlang-eunit erlang-nox erlang-xmerl erlang-inets erlang-reltool
apt-get install -y libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool
apt-get install -y pkg-config rebar
apt-get install -y automake autoconf autoconf-archive
apt-get install -y help2man python-sphinx texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texinfo gnupg
# flag -p: create intermediate directories as required.
mkdir -p /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb /var/lib/couchdb
cd /usr/local/src
# --- Then continue with 2.0 specifics ---
npm install -g grunt-cli
# Remove old files (assumed in /usr/local/src), if any
cd /usr/local/src
rm -fR couchdb
git clone https://github.com/apache/couchdb.git
cd couchdb
# For all configuration options.
./configure --help
$ ./configure
# configure ends with a "build succeeded"
# Now make
$ make
# To view startup options
$ ./dev/run --help
# To start a running instance. When done, use Ctrl-C to quit the instance
$ ./dev/run
# ./dev/run => returns a URL web link with a (temporary) admin username and password
# To get a list of all the nodes in your cluster.
$ curl http://127.0.0.1:5984/_membership
## --- Warning: no "make install" for 2.0 yet! ---
# Have not tried the following yet!
# Preliminary fix: To install couchdb on system do
$ cd /usr/local/src/couchdb
$ cp -r rel/couchdb /usr/local/lib
#!/bin/bash
# (a) Refer to: https://github.com/apache/couchdb/blob/1.x.x/DEVELOPERS
# (b) Optional: Possibly install npm and nodejs if Fauxton is wanted
# (c) Assumed that you work as user "root" else place "sudo" in front of all commands
#
# (d) Place this file (couchdb_install.sh) in e.g. /usr/local/src/ then do the following:
# $ cd /usr/local/src/
# $ nano couchdb_1.7.0_install.sh
# $ chmod 755 couchdb_1.7.0_install.sh
# $ ./couchdb_1.7.0_install.sh
# See (e) below
apt-get update
# -y flag: assume Yes to all queries and do not prompt
apt-get install -y build-essential
apt-get install -y erlang-dev erlang-manpages erlang-base-hipe erlang-eunit erlang-nox erlang-xmerl erlang-inets erlang-reltool
apt-get install -y libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool
apt-get install -y pkg-config rebar
apt-get install -y automake autoconf autoconf-archive
apt-get install -y help2man python-sphinx texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texinfo gnupg
# flag -p: create intermediate directories as required.
mkdir -p /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb /var/lib/couchdb
cd /usr/local/src
wget https://github.com/apache/couchdb/archive/1.x.x.zip
unzip 1.x.x.zip
cd couchdb-1.x.x/
./bootstrap
# if you want docs, then remove the flag --disable-docs i.e. just call: ./configure
./configure --disable-docs
touch THANKS
make && make install
adduser --disabled-login --disabled-password --no-create-home --gecos "" couchdb
chown -R couchdb:root /usr/local/var/log/couchdb /usr/local/var/lib/couchdb /usr/local/var/run/couchdb /usr/local/etc/couchdb
chmod 770 /usr/local/var/lib/couchdb/ /usr/local/var/log/couchdb/ /usr/local/var/run/couchdb/ /usr/local/etc/couchdb
chmod 664 /usr/local/etc/couchdb/*.ini
chmod 775 /usr/local/etc/couchdb/*.d
rm /etc/logrotate.d/couchdb /etc/init.d/couchdb
ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/couchdb
ln -s /usr/local/etc/init.d/couchdb /etc/init.d
update-rc.d couchdb defaults
cp /usr/local/etc/couchdb/local.ini /usr/local/etc/couchdb/local.ini.orig
cp /usr/local/etc/couchdb/default.ini /usr/local/etc/couchdb/default.ini.orig
service couchdb start
# (e) Now test couchdb
# $ curl localhost:5984
; This has been tried with couchdb "1.7.0"
; (a) Update the file: /usr/local/etc/couchdb/local.ini
; (b) Remember to restart couchdb after changing the configuration file:
; $ service couchdb stop
; $ service couchdb start
; (c) This configuration is good for e.g. going through nginx
; See (d) and (e) below
; Now test couchdb
; $ curl http://your_admin_username:your_admin_password@localhost:5984
[couchdb]
max_dbs_open = 1024
delayed_commits = false
[httpd]
WWW-Authenticate = Basic realm="administrator"
enable_cors = true
x_forwarded_host = X-Forwarded-Host
x_forwarded_proto = X-Forwarded-Proto
x_forwarded_ssl = X-Forwarded-Ssl
;Specifies default timeout value for Changes Feed: 3 minutes = 3 * 60 * 1000
changes_feed = 180000
;max_connections = 4096
; IMPORTANT: bind_address settings see: http://docs.couchdb.org/en/latest/config/http.html
port = 5984
bind_address = 0.0.0.0
server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
[couch_httpd_auth]
require_valid_user = true
allow_persistent_cookies = true
timeout = 1209600
auth_cache_size = 1000
[log]
level = warning
; (e) You can add more admin accounts with more 'username = password' lines. Don't forget to restart CouchDB after changing this.
[admins]
your_admin_username = your_admin_password
[cors]
; See also https://github.com/pouchdb/add-cors-to-couchdb
origins = *
headers = accept, authorization, content-type, origin, cookie, referer, x-csrf-token
methods = GET, OPTIONS, HEAD, PUT, POST, DELETE, TRACE
credentials = true
[compactions]
_default = [{db_fragmentation,"70%"},{view_fragmentation,"60%"},{from,"00:00"},{to,"06:00"}]
[replicator]
; 3 minutes = 3 * 60 * 1000 = 180000
connection_timeout = 180000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment