The Apache Software Foundation has released CouchDB version 2.0.  CouchDB 2.0, is a “distributed” version of CouchDB, a mature NoSQL, document-oriented data-store that is accessable via a RESTful JSON API. Developers can take advantage of CouchDB’s offline capability and reliable data sync for web, mobile and IoT apps at (any) scale.

[NOTE: September 2017 — CouchDB 2.1 and Raspbian Stretch have been released.  Check out updated instructions in this blog post]

Current Raspbian (November 2016) can “apt-get install” version 1.4 and I have previously written about getting CouchDB 1.6 running on the R-Pi.  I have now installed version 2.0.0 on an R-Pi 3 and am sharing the process.  It is pretty straightforward to get CouchDB 2.0 running on the R-Pi. It takes a combination of the R-Pi specific 1.6 install and the “generic linux” 2.0 install to get things running.

 

First, make sure your R-Pi is running the latest Raspbian:

sudo apt-get update
sudo apt-get upgrade

On my R-Pi 3, you can see Raspbian and kernel versions:

pi@PiCam-3:~ $ uname -a
Linux PiCam-3 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux

pi@PiCam-3:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

 

You should add a CouchDB specific repository and then “apt-get” dependencies:

cd
wget http://packages.erlang-solutions.com/debian/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
sudo apt-get update
sudo apt-get install -y erlang-nox erlang-dev erlang-reltool
sudo apt-get install -y build-essential
sudo apt-get install -y libmozjs185-1.0 libmozjs185-dev
sudo apt-get install -y libcurl4-openssl-dev libicu-dev

 

Setup the couchdb user:

sudo useradd -d /home/couchdb couchdb
sudo mkdir /home/couchdb
sudo chown couchdb:couchdb /home/couchdb

Get URL to download source for couchdb.  Use a browser to navigate to: http://couchdb.apache.org/#download.  Under “Download CouchDB 2.0.x”, click on “Source” button.  Copy the suggested mirror download URL.  In my case it was: http://apache.claz.org/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz.  On the R-Pi, download and unzip source:

wget http://mirror.symnds.com/software/Apache/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz
tar zxvf apache-couchdb-2.0.0.tar.gz
cd apache-couchdb-2.0.0/
./configure
make release

 

after  a bit, you should see:

... done

    You can now copy the rel/couchdb directory anywhere on your system.
    Start CouchDB with ./bin/couchdb from within that directory.

 

For convience, I chose to copy the couchdb  directory with executables and configuration files to the couchdb home directory.  Make sure you are in the couchdb directory under the release (rel) directory.  Copy the contents of the …/rel/couchdb to the couchdb home directory.

 

cd ./rel/couchdb
pwd
/home/pi/apache-couchdb-2.0.0/rel/couchdb
sudo cp -Rp * /home/couchdb
sudo chown -R couchdb:couchdb /home/couchdb

 

I want to access CouchDB from other machines and run fauxton in a browser from my Mac.  Fauxton is a web-based interface for CouchDB. Change the local configuration file in “/home/couchdb/etc”.  Either use “vi” or “nano” or your favorite editor to edit “local.ini”

 

cd /home/couchdb/etc
sudo vi local.ini

 

Under the chttp section, change this line to enable remote access from any IP address.

from

#bind_address = 127.0.0.1

to

bind_address = 0.0.0.0

 

Save and exit the editor.

You should now be able to run CouchDB.  It needs to be run as user: couchdb.

sudo -i -u couchdb /home/couchdb/bin/couchdb

 

This will display some diagnostic messages and the CouchDB motto: “Relax” 😉

You may see some “shard errors” until you actually write to a DB.  Easiest thing to do is to setup an admin user via Fauxton utility.  Either from a remote machine – I use my Mac – or a local browser on the R-Pi, you can now launch Fauxton.  You need to know your R-Pi’s IP address if running remotely.  My particular R-Pi has the address: 10.0.0.216  In a browser you can put in the URL:

 

http://10.0.0.216:5984/_utils/

 

You should click on the “Verify” button in the left navigation panel and then click “Verify Installation” button at the top of the page.  If everything went well, you should see:

 

 

 

SaveSave