.. author:: Lukas Wolfsteiner <[email protected]>
.. tag:: self-hosting
.. tag:: database
.. tag:: Erlang
.. tag_list::
Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.
CouchDB uses multiple formats and protocols to store, transfer, and process its data, it uses JSON to store data, JavaScript as its query language using MapReduce, and HTTP for an API.
Note
For this guide you should be familiar with the basic concepts of
All relevant legal information can be found here
We're using :manual:`CouchDB <database-couchdb>` in the stable version 3:
[isabell@stardust ~]$ uberspace tools version use couchdb 3
Selected couchdb version 3
The new configuration is adapted immediately. Minor updates will be applied automatically.
[isabell@stardust ~]$
Uberspace provides the latest binaries, see :manual:`CouchDB <database-couchdb>` on how to interact with them. No extra installation required!
Next we need to create directories for our configuration and application data:
[isabell@stardust ~]$ mkdir -p ~/etc/couchdb
[isabell@stardust ~]$ mkdir -p ~/opt/couchdb
Create ~/etc/couchdb/local.ini
with the following content:
Warning
Replace <username>
with your username!
[couchdb]
single_node=true
database_dir = /home/<username>/opt/couchdb/data
view_index_dir = /home/<username>/opt/couchdb/index
[chttpd]
port = 5984
bind_address = 127.0.0.1
[admins]
admin = SecureAdminPassword
Note
Make sure to set your own super secure admin password!
Create ~/etc/services.d/couchdb.ini
with the following content:
[program:couchdb]
command=couchdb -couch_ini /opt/couchdb/etc/default.ini %(ENV_HOME)s/etc/couchdb/local.ini
autostart=yes
autorestart=yes
If it's not in state RUNNING, check your configuration.
If everything looks fine, you should now be able to query CouchDB using localhost:5984
:
[isabell@stardust ~]$ curl http://localhost:5984
{"couchdb":"Welcome","version":"3.1.1","git_sha":"CENSORED","uuid":"CENSORED","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
Let's create a test database called testdb
:
[isabell@stardust ~]$ curl -X PUT http://admin:SecureAdminPassword@localhost:5984/testdb
{"ok":true}
Change all default passwords. Especially the admin password within the config file ~/etc/couchdb/local.ini
. Don't get hacked!
Warning
This exposes CouchDB to the global internet and allows anyone to query your CouchDB database. Not recommended without authentication!
Note
couchdb is running on port 5984. Also make sure to set bind_address = 0.0.0.0
in ~/etc/couchdb/local.ini
.
Tested with CouchDB 3.3.3 and Uberspace 7.15.4.0
.. author_list::