This shows you the differences between two versions of the page.
— |
public:couchdb_3_dockers_cluster_-_1st_run [2018/02/20 09:22] (current) admin created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Bellow the very first skeleton to be used to create a couchDb cluster with 3 docker containers | ||
+ | * all files should be in ''couchdb_cluster'' directory - if not, NODENAME should be updated to use the FQDN based on default docker compose network. | ||
+ | * docker-compose.yml | ||
+ | <code> | ||
+ | version: "3" | ||
+ | services: | ||
+ | node1: | ||
+ | image: couchdb:2.1.1 | ||
+ | environment: | ||
+ | - NODENAME=node1.couchdbcluster_default | ||
+ | - COUCHDB_USER=admin | ||
+ | - COUCHDB_PASSWORD=admin | ||
+ | ports: | ||
+ | - "5981:5984" | ||
+ | node2: | ||
+ | image: couchdb:2.1.1 | ||
+ | environment: | ||
+ | - NODENAME=node2.couchdbcluster_default | ||
+ | - COUCHDB_USER=admin | ||
+ | - COUCHDB_PASSWORD=admin | ||
+ | ports: | ||
+ | - "5982:5984" | ||
+ | node3: | ||
+ | image: couchdb:2.1.1 | ||
+ | environment: | ||
+ | - NODENAME=node3.couchdbcluster_default | ||
+ | - COUCHDB_USER=admin | ||
+ | - COUCHDB_PASSWORD=admin | ||
+ | ports: | ||
+ | - "5983:5984" | ||
+ | </code> | ||
+ | * initCluster.sh | ||
+ | <code> | ||
+ | curl -X POST -H "Content-Type: application/json" http://admin:admin@tm171lin209.wls.ro.alcatel-lucent.com:5981/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "node_count":"3"}' | ||
+ | |||
+ | curl -X POST -H "Content-Type: application/json" http://admin:admin@tm171lin209.wls.ro.alcatel-lucent.com:5981/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "3", "remote_node": "couchdb@node2.couchdbcluster_default", "remote_current_user": "admin", "remote_current_password": "admin" }' | ||
+ | curl -X POST -H "Content-Type: application/json" http://admin:admin@tm171lin209.wls.ro.alcatel-lucent.com:5981/_cluster_setup -d '{"action": "add_node", "host":"node2.couchdbcluster_default", "port": "5984", "username": "admin", "password":"admin"}' | ||
+ | |||
+ | curl -X POST -H "Content-Type: application/json" http://admin:admin@tm171lin209.wls.ro.alcatel-lucent.com:5981/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "3", "remote_node": "couchdb@node3.couchdbcluster_default", "remote_current_user": "admin", "remote_current_password": "admin" }' | ||
+ | curl -X POST -H "Content-Type: application/json" http://admin:admin@tm171lin209.wls.ro.alcatel-lucent.com:5981/_cluster_setup -d '{"action": "add_node", "host":"node3.couchdbcluster_default", "port": "5984", "username": "admin", "password":"admin"}' | ||
+ | |||
+ | curl -X POST -H "Content-Type: application/json" http://admin:admin@tm171lin209.wls.ro.alcatel-lucent.com:5981/_cluster_setup -d '{"action": "finish_cluster"}' | ||
+ | </code> | ||
+ | * checkCluster.sh | ||
+ | <code> | ||
+ | curl -X GET "http://admin:admin@localhost:5981/_membership" | ||
+ | curl -X GET "http://admin:admin@localhost:5982/_membership" | ||
+ | curl -X GET "http://admin:admin@localhost:5983/_membership" | ||
+ | </code> | ||
+ | * example or running the cluster - commands to be executed in ''couchdb_cluster'' directory: | ||
+ | <code> | ||
+ | docker-compose up -d | ||
+ | sh initCluster.sh | ||
+ | sh checkCluster.sh | ||
+ | </code> | ||
+ | |||