1

I am trying to setup a CouchDB cluster with some Raspberry Pi for a edge computing project. But all I did until now wasn't successful. I don't get a cluster working correctly.

This is what I did: I followed the setup guide from http://docs.couchdb.org/en/2.0.0/install/unix.html#

in combination with: https://medium.com/linagora-engineering/setting-up-a-couchdb-2-cluster-on-centos-7-8cbf32ae619f#.eopseqi4h

  1. Installing the dependencies - worked without error
  2. ./configure - worked without error
  3. make release - worked without error

  4. Following the guide: Add couchdb user:

    adduser --system --no-create-home --shell /bin/bash --group --gecos   
    "CouchDB Administrator" couchdb
    

    worked without error

  5. mv rel/couchdb /usr/local/ - worked without error

  6. chown -R couchdb:couchdb /usr/local/couchdb - didn't work in first place - no usergroup couchdb - added usergroup
  7. changed node-name in /usr/local/couchdb/etc/vm.args: -name n1.couch.local added -kernel inet_dist_listen_min 9100and -kernel inet_dist_listen_max 9200 - didn't work - changed back to couchdb@localhost

  8. staring db

    su - couchdb
    cd /usr/local/couchdb
    ./bin/couchdb
    

    -didn't work for me in first place, su pw - Authentication failed - switched user by sudo su and su - couchdb

  9. db starts - runs, but throws error (ignored error for now, because db is running):

    [error] 2017-02-17T12:34:26.672758Z couchdb@localhost emulator ------    
    -- Error in process <0.354.0> on node 'couchdb@localhost' with exit 
    value: {database_does_not_exist,
    [{mem3_shards,load_shards_from_db,"_users",
    [{file,"src/mem3_shards.erl"},{line,327}]},
    {mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},
    {line,315}]},{mem3_shards,load_shards_from_disk... 
    [notice] 2017-02-17T12:34:26.672918Z couchdb@localhost <0.353.0> ----
    ---- chttpd_auth_cache changes listener died database_does_not_exist 
    at mem3_shards:load_shards_from_db/6(line:327) <= 
    mem3_shards:load_shards_from_disk/1(line:315) <= 
    mem3_shards:load_shards_from_disk/2(line:331) <=  
    mem3_shards:for_docid/3(line:87) <= fabric_doc_open:go/3(line:38) <= 
    chttpd_auth_cache:ensure_auth_ddoc_exists/2(line:187) <= 
    chttpd_auth_cache:listen_for_changes/1(line:134)
    
  10. prepared two Raspberry Pi (2 CouchDB nodes) for cluster mode:

    curl -X PUT http://127.0.0.1:5984/_node/couchdb@localhost/
    _config/admins/admin -d '"conmonmrp"'` 
    
    • answer:

      "-pbkdf2-9ec43ace4195ee45a37773c9dfc2aba9380468cb, cddfb98dd1b2416dea2b53dc9fe9a31b,10"

    and

    `curl -X PUT http://127.0.0.1:5984/_node/couchdb@localhost/
    _config/chttpd/bind_address -d '"0.0.0.0"'` 
    
    • answer: "0.0.0.0"

    seems like commands have been accepted

  11. Went on localhost:5984/_utils/ and tried to setup cluster - entered credentials (did not change IP and port) and added another node by IP (network IP, i.e. 10.228.101.210), created cluster to finish setup - fauxton accepted that without an error.

  12. trying to get all nodes in the cluster by localhost:5984/_membership/ results in:

    {"all_nodes":["couchdb@localhost"],"cluster_nodes":     
    ["couchdb@10.228.101.210","couchdb@localhost"]}`
    
  13. trying to add a database on one node and see it on another one doesn't work

I'am really new to that CouchDB thing at all, but I need to get that cluster running. I hope, my discription helps to find the problem. Altogether I got the feeling, that I am missing or missunderstandig an important point on that.

Best regards from Hamburg, DE

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
bginnHH
  • 73
  • 2
  • 9
  • I use Bigcouch but I think it's the same. You should be setting up clustering/_membership on port 5986. That is how the nodes talk to each other. 5984 is the front end and just looks like regular couch no matter what is going on in the back end. – fred Feb 24 '17 at 15:21
  • thanks for your answer. Problem was the -name in xm.args. I didn't change it, so @localhost was the problem. After I have changed that, everything works fine now. – bginnHH Feb 28 '17 at 08:10

2 Answers2

4

After having some trouble with setting up the cluster, a friend found the problem. It is necessary to change the name of the node in the /couchdb/etc/vm.args file. As I read in another post it is illegal to name it @localhost. I changed that to the IP-address of the device.

After that, everything works fine for me now.

bginnHH
  • 73
  • 2
  • 9
  • I am on bigcouch so might be a bit different but you should not need to add `@somedomain`. Couch/Bigcouch run on Erlang and Erlang uses EPMD which automatically determines the nodes domain name and adds that. That is assuming you are using -sname (short names) mode which is all I use. If you are not using -sname erlang names then you need to add the `@somedomain`. If your local.ini specifies `-sname` then you are using short names. If it uses `-name` then it is using long names (ie. including `@somedomain`) http://erlang.org/doc/reference_manual/distributed.html – fred Jun 12 '17 at 15:09
  • Thanks a lot, this worked! I have been breaking my head over this for the last 2 of days. You deserve a lot more upvotes :). – Amal Antony Jun 23 '17 at 06:31
  • `-sname` is being discouraged https://github.com/apache/couchdb/issues/729#issuecomment-319408516 – Can Rau May 24 '22 at 19:23
1

Remember also, when setting up a cluster and finding issues when adding or restarting, etc... Make sure your "cookie" doesn't have spaces.

seigel
  • 206
  • 1
  • 5