You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/11/18 06:00:21 UTC
[GitHub] [couchdb] vijeth-ag commented on issue #2317: CouchDB Clustering
vijeth-ag commented on issue #2317: CouchDB Clustering
URL: https://github.com/apache/couchdb/issues/2317#issuecomment-554865647
> I'm trying to create couchdb cluster in 2 AWS EC2 instances: using the following [official doc](http://docs.couchdb.org/en/stable/setup/cluster.html)
>
> First I'mm creating 2 couchdb docker containers using the below Dockerfile
>
> ```
> FROM couchdb:2.3.1
>
> ENV NODENAME=XX.XXX.XX.XXX
> ENV COUCHDB_USER=admin
> ENV COUCHDB_PASSWORD=admin
>
> COPY my.cookie /opt/couchdb/.erlang.cookie
> RUN chmod 600 /opt/couchdb/.erlang.cookie
> ```
>
> Next, I'm creating _global_changes, _replicator, and _users DB's in each of the couchdb instances like so
>
> ```
> curl -X PUT http://admin:admin@XX.XXX.XX.XXX:5984/_global_changes
> curl -X PUT http://admin:admin@XX.XXX.XX.XXX:5984/_replicator
> curl -X PUT http://admin:admin@XX.XXX.XX.XXX:5984/_users
> ```
>
> Then, running clustering commands
>
> ```
> curl -X POST -H "Content-Type: application/json" http://admin:admin@XX.XXX.XX.XXX:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "2", "remote_node": "XX.XXX.XX.XXX", "remote_current_user": "admin", "remote_current_password": "admin" }'
>
> curl -X POST -H "Content-Type: application/json" http://admin:admin@XX.XXX.XX.XXX:5984/_cluster_setup -d '{"action": "add_node", "host":"XX.XXX.XX.XXX", "port": 5984, "username": "admin", "password":"admin"}'
>
> curl -X POST -H "Content-Type: application/json" http://admin:admin@XX.XXX.XX.XXX:5984/_cluster_setup -d '{"action": "finish_cluster"}'
>
> curl http://admin:admin@XX.XXX.XX.XXX:5984/_cluster_setup
>
> curl http://admin:admin@XX.XXX.XX.XXX:5984/_membership
> ```
>
> This is vm.args file
>
> ```
> # Ensure that the Erlang VM listens on a known port
> -kernel inet_dist_listen_min 9100
> -kernel inet_dist_listen_max 9100
>
> # Tell kernel and SASL not to log anything
> -kernel error_logger silent
> -sasl sasl_error_logger false
>
> # Use kernel poll functionality if supported by emulator
> +K true
>
> # Start a pool of asynchronous IO threads
> +A 16
>
> # Comment this line out to enable the interactive Erlang shell on startup
> +Bd -noinput
> -name couchdb@serevr1.test.com
> -setcookie "secret"
> ```
>
> When I run _membership command the cluster_nodes has both nodes as [couchdb@XX.XXX.XX.XXX](mailto:couchdb@XX.XXX.XX.XXX), but the all_nodes has only one node, itself.
>
> I have made sure the erlang epmd port 4369 is accessible to outside.
>
> I've being trying for a while now. Am I missing anything?
>
> Update:
> Getting this errors(from docker logs):
>
> ```
> [info] 2019-11-17T07:21:43.652477Z couchdb@XX.XXX.XX.XXX <0.9.0> -------- Application snappy started on node 'couchdb@XX.XXX.XX.XXX'
> [error] 2019-11-17T07:21:48.552666Z couchdb@XX.XXX.XX.XXX emulator -------- Error in process <0.490.0> on node 'couchdb@XX.XXX.XX.XXX' with exit value:
> {database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,395}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},{line,370}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,399}]},{mem3_shards,for_docid,3,[{file,"src/mem3_shards.erl"},{line,86}]},{fabric_doc_open,go,3,[{file,"src/fabric_doc_open.erl"},{line,39}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,"src/chttpd_auth_cache.erl"},{line,195}]},{chttpd_auth_cache,listen_for_changes,1,[{file,"src/chttpd_auth_cache.erl"},{line,142}]}]}
> ```
I've got it working. Dockerfile and set of commands below for reference:
Dockerfile:
```
FROM couchdb:latest
ENV NODENAME=<this.machine.ip.address>
ENV COUCHDB_USER=admin
ENV COUCHDB_PASSWORD=admin
ENV COUCHDB_SECRET=admin
COPY my.cookie /opt/couchdb/.erlang.cookie
RUN chmod 600 /opt/couchdb/.erlang.cookie
```
Prepare docker image and run, port mapping (4369, 9100) is important for clustering mode
```
docker build .
docker run -d -p 5984:5984 -p 4369:4369 -p 9100:9100 <container-id>
```
Ran these curl commands to be run in one of the machines locally, (1st curl cmd all machines)
```
curl -X POST -H "Content-Type: application/json" http://admin:admin@127.0.0.1:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "node_count":"2"}'
curl -X POST -H "Content-Type: application/json" http://admin:admin@127.0.0.1:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "2", "remote_node": "<remote.machine.ip.address>", "remote_current_user": "admin", "remote_current_password": "admin" }'
curl -X POST -H "Content-Type: application/json" http://admin:admin@127.0.0.1:5984/_cluster_setup -d '{"action": "add_node", "host":"<remote.machine.ip.address>", "port": 5984, "username": "admin", "password":"admin"}'
curl http://admin:admin@127.0.0.1:5984/_cluster_setup
```
Now check the clusters and nodes states using membership api.
```
curl http://admin:admin@127.0.0.1:5984/_membership
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services