CouchDB 2.1 on Raspberry Pi (Raspbian Stretch)

4 Comments

CouchDB 2.1 on R-PiFrom the Apache CouchDB docs:

CouchDB is a database that completely embraces the web. Store your data with JSON documents. Access your documents with your web browser, via HTTP. Query, combine, and transform your documents with JavaScript. CouchDB works well with modern web and mobile apps.

CouchDB also has Fauxton, a native web-based interface built into CouchDB. It provides an interface to the majority of the CouchDB functionality, including the ability to create, update, delete and view documents and configuration parameters.

I’ve already written a blog post for installing CouchDB 2.0 under Rasbian Jessie for Raspberry Pi.  I’m updating my instructions for CouchDB 2.1 and Raspbian Stretch (in addition to Jessie). I’m presenting this “how-to” in coolbook form — i.e. just type in the commands as presented and you should end up with a functional CouchDB install.  For more background and info, check out my previous blog post.

[UPDATE: 03 April 2018] I have confirmed that my instructions work for CouchDB 2.1.1 and work under Raspbian Stretch on the new Raspberry Pi 3 Model B+.

You will need to obtain a URL for the zipped source.  You can get this from the CouchDB downloads page.  Go to this page and look for the latest source download section (currently: “Download CouchDB 2.1.0”).  Click on the red “Source” button and copy the suggested source mirror URL.  You’ll use this URL in the “wget” line below.

# update packages & OS
cd
sudo apt-get update
sudo apt-get upgrade

# You can check the OS version
cat /etc/os-release 

# add Erlang Solutions repository and public key
wget http://packages.erlang-solutions.com/debian/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
sudo apt-get update

# install all build dependencies - note mutiple lines
sudo apt-get --no-install-recommends -y install \
build-essential pkg-config erlang libicu-dev \
libmozjs185-dev libcurl4-openssl-dev

#add couchdb user and home
sudo useradd -d /home/couchdb couchdb
sudo mkdir /home/couchdb
sudo chown couchdb:couchdb /home/couchdb

# Get source - need URL for mirror (see blog instructions)
wget http://mirror.stjschools.org/public/apache/couchdb/source/2.1.0/apache-couchdb-2.1.0.tar.gz

# extract source and enter source directory
tar zxvf apache-couchdb-2.1.0.tar.gz 
cd apache-couchdb-2.1.0/

# configure build and make executable(s)
./configure
make release

#copy built release to couchdb user home directory
cd ./rel/couchdb/
sudo cp -Rp * /home/couchdb
sudo chown -R couchdb:couchdb /home/couchdb
cd /home/couchdb/etc

# need to edit IP address to allow external access
sudo vi local.ini

 

After building and installing CouchDB, you can configure it to allow connections from external IP addresses.  You need to edit “/home/couchdb/etc/local.ini”.  The “sudo vi local.ini” line above.

Change this line:
 #bind_address = 127.0.0.1
 to:
 bind_address = 0.0.0.0

You can now run couchdb as user: couchdb:

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

Connect to CouchDB’s Fauxton GUI using your favorite browser using the URL:

http://192.168.0.27:5984/_utils/

Replace my IP (192.168.0.27) with your R-Pi’s.  Make sure you follow the first-time setup instruction in the CouchDB documentation!  Most users will want/need a single node setup.  You can do this by clicking on the wrench icon in Fauxton and selecting “single node”.  You can bind to your R-Pi’s external IP if you wish to connect via a browser on other computers.  I recommend restarting your browser after initial setup to ensure everything is working properly.

Check out the CouchDB documentation to learn more!

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

4 Comments (+add yours?)

  1. Tascha
    Jan 07, 2018 @ 16:54:15

    Hello! Thanks for the guide! It was on-spot, except it didn’t mention that — at least for me — it only worked when run under root-user. Sudoer wasn’t enough. (Maybe my new-ness to Linux was the reason why I didn’t know already.)

    Reply

    • andy
      Jan 13, 2018 @ 12:13:13

      Tascha, Have you setup the couchdb user? Check out my older post for CouchDB 2.0. The “sudo” command really just invokes couchdb as user: couchdb.

      Reply

  2. Steve A
    Jan 28, 2018 @ 12:36:31

    Thanks for writing this Andy! It’s proven very helpful for getting CouchDB running on an ARM-based server at Scaleway.

    It’s probably worth noting that the current version of CouchDB is 2.1.1 – I failed to notice that there’s a handful of references to the filename the first time I ran it.

    Reply

Leave a Reply