CouchDB
"Apache CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion using JavaScript." - CouchDB homepage
Contents
Installation
Install the couchdb package.
By default, the package depends on erlang-nox without GTK, for headless servers. You can also install the standard version, erlang, that does require GTK.
After installation Start/Enable the couchdb.service
daemon and visit: http://127.0.0.1:5984/_utils/#setup to setup the database and admin user account.
If you select single node setup you might need to create few databases manually via http api:
curl -X PUT http://127.0.0.1:5984/_users curl -X PUT http://127.0.0.1:5984/_replicator curl -X PUT http://127.0.0.1:5984/_global_changes
see Single Node Setup for more. Also, you might want to take a look at #Single node setup & Security.
Usage
Start/Enable the couchdb.service
daemon.
Test to see if the service is running by running curl http://127.0.0.1:5984/
. Ping will not work (it's not supposed to unlike on other systems where it does). Note that in order to access this instance of CouchDB from another system you'll need to configure it (see below).
Using Futon admin interface
You can now access the Futon admin interface by going to http://localhost:5984/_utils.
Configuration
Change the default port, bind address, log-level and other useful nuggets in /etc/couchdb/local.ini
.
bind_address
to 0.0.0.0
to access CouchDB from any computer other than local.If you want to run CouchDB on port 80 you will have to run the daemon as root or use an iptables rule such as:
$ iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 5984
/etc/couchdb/default.ini
as it gets overwritten whenever couchdb is updated, copy any values you would like to change and put them in /etc/couchdb/local.ini
. Also be sure to restart couchdb.service
after changes to this file.Creating a self-signed certificate
If you would like to use ssl with a self-signed certificate you can create one like this:
# cd /etc/couchdb # openssl req -new -x509 -nodes -newkey rsa:4096 -keyout server.key -out server.crt
Then uncomment httpsd and update the paths in [daemons]
and [ssl]
sections:
/etc/couchdb/local.ini
[daemons] httpsd = {couch_httpd, start_link, [https]} [ssl] cert_file = /etc/couchdb/server.crt key_file = /etc/couchdb/server.key
Futon can be accessed over SSL on port 6984 via https://localhost:6984/_utils/.
Creating administrator users
Before a server admin is configured, all clients have admin privileges. To create an admin user, click on "Fix this" link at bottom right of Futon interface.
See create a read-only database for locking down databases and further security.
Single node setup & Security
If you run CouchDB in a single node setup, you might want to increase security by not binding unnecessarily on public network interfaces. Two process are actually doing so: epmd
and beam.smp
. The first one is quite easy to work around, you can simply add the following systemd drop-in addition to couchdb.service
:
/etc/systemd/system/couchdb.service.d/10-bind-locally.conf
[Service] Environment=ERL_EPMD_ADDRESS=127.0.0.1
The second one likely requires more work and a solution is yet to be found.