Docker Swarm and Service Mode to create Couchbase Cluster explained how to create a Couchbase Cluster using Docker. It used the concept of a “master” and a “worker” service to simplify and automate the creation of cluster. The homogenous cluster was then created as shown in the architecture diagram below:

Complete details and background are in the Couchbase Cluster using Docker blog.
Docker 1.13 was released last week. A new feature in that release allows to deploy multi-container application defined using Docker Compose to multi-host enabled using Swarm mode. Ideally, we’d like to have a single Docker Compose definition that allows to start “master” service and start/scale “worker” service. But the “master” service, more importantly the container within the service, needs to be fully up before the “worker” service can be started. This is because the containers in the “worker” service register with the container in the “master” service to create the cluster. This typically require a bit of handcrafting as defined at Controlling Startup Order in Compose. So we’ll come back to that version later.
This blog will provide a quick refresh of the steps from the original using Docker 1.13. Read this blog for a quick how and the original blog for more details on why.
Create network:
|
1 2 3 |
Docker network crear –d overlay Couchbase |
Check the created network using docker network ls command:
|
1 2 3 4 5 6 7 |
NETWORK ID NAME DRIVER SCOPE 20a28d56f140 bridge bridge local 5maq7fyqdemx Couchbase overlay enjambre cd14345ec130 docker_gwbridge bridge local 46a19cdead82 host host local p1kbq62oxmn9 ingress overlay enjambre 1b64333f45ec none nulo local |
Create Couchbase “master” service:
|
1 2 3 4 5 6 7 |
Docker service crear —nombre Couchbase–maestro —replicas 1 –p 8091:8091 —network Couchbase –e TYPE=MASTER arungupta/Couchbase |
Check the created service using docker service ls command:
|
1 2 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 Couchbase–maestro replicated 1/1 arungupta/Couchbase:latest |
Create Couchbase “worker” service:
|
1 2 3 4 5 6 7 8 |
Docker service crear —nombre Couchbase–worker —replicas 1 —network Couchbase –e TYPE=WORKER –e COUCHBASE_MASTER=Couchbase–maestro.Couchbase –e AUTO_REBALANCE=falso arungupta/Couchbase |
Check the created service again using docker service ls command:
|
1 2 3 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 Couchbase–maestro replicated 1/1 arungupta/Couchbase:latest zqqqk76cu1jw Couchbase–worker replicated 1/1 arungupta/Couchbase:latest |
Check the worker service logs using newly introduced command docker service logs couchbase-worker command. This command, newly introduced in Docker 1.13, pulls logs from all containers in the service and streams them to your console. There is no need to track down which containers are running on which hosts.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
Couchbase–worker.1.3x52hro26166@moby | ++ establecer –m Couchbase–worker.1.3x52hro26166@moby | ++ sleep 15 Couchbase–worker.1.3x52hro26166@moby | ++ /entrypoint.sh Couchbase–server Couchbase–worker.1.3x52hro26166@moby | Starting Couchbase Servidor — Web Interfaz de usuario available at https://:8091 and logs available in /opt/couchbase/var/lib/couchbase/logs Couchbase–worker.1.3x52hro26166@moby | ++ curl –v –X POST https://127.0.0.1:8091/pools/default -d memoryQuota=300 -d indexMemoryQuota=300 Couchbase–worker.1.3x52hro26166@moby | Nota: Unnecessary use of –X o —request, POST is already inferred. Couchbase–worker.1.3x52hro26166@moby | * Trying 127.0.0.1… Couchbase–worker.1.3x52hro26166@moby | % Total % Received % Xferd Average Speed Time Time Time Current Couchbase–worker.1.3x52hro26166@moby | Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 —:—:— —:—:— —:—:— 0* Connected a 127.0.0.1 (127.0.0.1) port 8091 (#0) Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: POST /pools/default HTTP/1.1 Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Host: 127.0.0.1:8091 Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: User–Agente: curl/7.49.1–DEV Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Accept: */* couchbase-worker.1.3x52hro26166@moby | > Content-Length: 36 couchbase-worker.1.3x52hro26166@moby | > Content-Type: application/x-www-form-urlencoded couchbase-worker.1.3x52hro26166@moby | > couchbase-worker.1.3x52hro26166@moby | } [36 bytes data] couchbase-worker.1.3x52hro26166@moby | * upload completely sent off: 36 out of 36 bytes couchbase-worker.1.3x52hro26166@moby | < HTTP/1.1 200 OK couchbase-worker.1.3x52hro26166@moby | < Server: Couchbase Server couchbase-worker.1.3x52hro26166@moby | < Pragma: no-cache couchbase-worker.1.3x52hro26166@moby | < Date: Sun, 22 Jan 2017 22:01:15 GMT couchbase-worker.1.3x52hro26166@moby | < Content-Length: 0 couchbase-worker.1.3x52hro26166@moby | < Cache-Control: no-cache couchbase-worker.1.3x52hro26166@moby | < 100 36 0 0 100 36 0 13057 –:–:– –:–:– –:–:– 18000 couchbase-worker.1.3x52hro26166@moby | * Connection #0 to host 127.0.0.1 left intact couchbase-worker.1.3x52hro26166@moby | ++ curl -v https://127.0.0.1:8091/node/controller/setupServices -d services=kv%2Cn1ql%2Cindex couchbase-worker.1.3x52hro26166@moby | * Trying 127.0.0.1… couchbase-worker.1.3x52hro26166@moby | % Total % Received % Xferd Average Speed Time Time Time Current couchbase-worker.1.3x52hro26166@moby | Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0) couchbase-worker.1.3x52hro26166@moby | > POST /node/controller/setupServices HTTP/1.1 couchbase-worker.1.3x52hro26166@moby | > Host: 127.0.0.1:8091 couchbase-worker.1.3x52hro26166@moby | > User-Agent: curl/7.49.1-DEV couchbase-worker.1.3x52hro26166@moby | > Accept: */* Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Content–Length: 26 Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Content–Escribir: aplicación/x–www–form–urlencoded Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Couchbase–worker.1.3x52hro26166@moby | } [26 bytes datos] Couchbase–worker.1.3x52hro26166@moby | * upload completely sent off: 26 out of 26 bytes Couchbase–worker.1.3x52hro26166@moby | < HTTP/1.1 200 OK Couchbase–worker.1.3x52hro26166@moby | < Servidor: Couchbase Servidor Couchbase–worker.1.3x52hro26166@moby | < Pragma: no–cache Couchbase–worker.1.3x52hro26166@moby | < Date: Sun, 22 Jan 2017 22:01:15 GMT Couchbase–worker.1.3x52hro26166@moby | < Content–Length: 0 Couchbase–worker.1.3x52hro26166@moby | < Caché–Control: no–cache Couchbase–worker.1.3x52hro26166@moby | < 100 26 0 0 100 26 0 13171 —:—:— —:—:— —:—:— 26000 Couchbase–worker.1.3x52hro26166@moby | * Connection #0 to host 127.0.0.1 left intact couchbase-worker.1.3x52hro26166@moby | ++ curl -v https://127.0.0.1:8091/settings/web -d port=8091 -d username=Administrator -d password=password couchbase-worker.1.3x52hro26166@moby | * Trying 127.0.0.1… couchbase-worker.1.3x52hro26166@moby | % Total % Received % Xferd Average Speed Time Time Time Current couchbase-worker.1.3x52hro26166@moby | Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0) couchbase-worker.1.3x52hro26166@moby | > POST /settings/web HTTP/1.1 Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Host: 127.0.0.1:8091 Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: User–Agente: curl/7.49.1–DEV Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Accept: */* Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Content–Length: 50 Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Content–Escribir: aplicación/x–www–form–urlencoded Couchbase–worker.1.3x52hro26166@moby | El resultado de tu pregunta se muestra a continuación: Couchbase–worker.1.3x52hro26166@moby | } [50 bytes datos] Couchbase–worker.1.3x52hro26166@moby | * upload completely sent off: 50 out of 50 bytes Couchbase–worker.1.3x52hro26166@moby | < HTTP/1.1 200 OK Couchbase–worker.1.3x52hro26166@moby | < Servidor: Couchbase Servidor Couchbase–worker.1.3x52hro26166@moby | < Pragma: no–cache Couchbase–worker.1.3x52hro26166@moby | < Date: Sun, 22 Jan 2017 22:01:15 GMT Couchbase–worker.1.3x52hro26166@moby | < Content–Escribir: aplicación/json Couchbase–worker.1.3x52hro26166@moby | < Content–Length: 39 Couchbase–worker.1.3x52hro26166@moby | < Caché–Control: no–cache Couchbase–worker.1.3x52hro26166@moby | < Couchbase–worker.1.3x52hro26166@moby | { [39 bytes datos] 100 89 100 39 100 50 3423 4389 —:—:— —:—:— —:—:— 4545 Couchbase–worker.1.3x52hro26166@moby | * Connection #0 to host 127.0.0.1 left intact Couchbase–worker.1.3x52hro26166@moby | ++ curl –i –u Administrador:contraseña –X POST https://127.0.0.1:8091/settings/indexes -d storageMode=memory_optimized Couchbase–worker.1.3x52hro26166@moby | % Total % Received % Xferd Average Speed Time Time Time Current Couchbase–worker.1.3x52hro26166@moby | Dload Upload Total Spent Left Speed 100 180 100 152 100 28 13264 2443 —:—:— —:—:— —:—:— 13818 Couchbase–worker.1.3x52hro26166@moby | {“newBaseUri”:“https://127.0.0.1:8091/”}HTTP/1.1 200 OK Couchbase–worker.1.3x52hro26166@moby | Servidor: Couchbase Servidor Couchbase–worker.1.3x52hro26166@moby | Pragma: no–cache Couchbase–worker.1.3x52hro26166@moby | Date: Sun, 22 Jan 2017 22:01:15 GMT Couchbase–worker.1.3x52hro26166@moby | Content–Escribir: aplicación/json Couchbase–worker.1.3x52hro26166@moby | Content–Length: 152 Couchbase–worker.1.3x52hro26166@moby | Caché–Control: no–cache Couchbase–worker.1.3x52hro26166@moby | Couchbase–worker.1.3x52hro26166@moby | ++ echo ‘Type: WORKER’ Couchbase–worker.1.3x52hro26166@moby | ++ ‘[‘ WORKER = WORKER ‘]’ Couchbase–worker.1.3x52hro26166@moby | ++ echo ‘Sleeping …’ Couchbase–worker.1.3x52hro26166@moby | ++ sleep 15 Couchbase–worker.1.3x52hro26166@moby | {“storageMode”:“memory_optimized”,“indexerThreads”:0,“memorySnapshotInterval”:200,“stableSnapshotInterval”:5000,“maxRollbackPoints”:5,“logLevel”:“info”}Escribir: WORKER Couchbase–worker.1.3x52hro26166@moby | Sleeping ... Couchbase–worker.1.3x52hro26166@moby | +++ hostname –I Couchbase–worker.1.3x52hro26166@moby | +++ cut –d ‘ ‘ –f1 Couchbase–worker.1.3x52hro26166@moby | ++ IP=10.0.0.5 Couchbase–worker.1.3x52hro26166@moby | ++ echo ‘IP: ‘ 10.0.0.5 Couchbase–worker.1.3x52hro26166@moby | ++ echo ‘Auto Rebalance: false’ Couchbase–worker.1.3x52hro26166@moby | IP: 10.0.0.5 Couchbase–worker.1.3x52hro26166@moby | ++ ‘[‘ falso = verdadero ‘]’ Couchbase–worker.1.3x52hro26166@moby | ++ Couchbase–CLI server–añadir —clúster=Couchbase–maestro.Couchbase:8091 —usuario=Administrador —contraseña=contraseña —server–añadir=10.0.0.5 —server–añadir–nombre de usuario=Administrador —server–añadir–contraseña=contraseña Couchbase–worker.1.3x52hro26166@moby | Auto Rebalance: falso Couchbase–worker.1.3x52hro26166@moby | Warning: Adding server desde group–administrar is deprecated Couchbase–worker.1.3x52hro26166@moby | Servidor 10.0.0.5:8091 added Couchbase–worker.1.3x52hro26166@moby | ++ fg 1 Couchbase–worker.1.3x52hro26166@moby | /entrypoint.sh Couchbase–server |
Complete logs show how the “worker” service was created and joined the cluster originally created by “master”.
Scale the cluster by scaling the Docker service:
|
1 |
Docker service scale Couchbase–worker=2 |
Check the service again using docker service ls command:
|
1 2 3 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 Couchbase–maestro replicated 1/1 arungupta/Couchbase:latest zqqqk76cu1jw Couchbase–worker replicated 2/2 arungupta/Couchbase:latest |
Now you’ve a three node Couchbase cluster. Before rebalancing the cluster, let’s quickly check what does Consola web de Couchbase shows.
Couchbase Web Console is accessible at https://localhost:8091 and shows a single Couchbase node with data, index and query service. This node was created using “master” service. Two additional nodes created using “worker” service are shown in Pending Rebalance tab:

Click on Rebalance to rebalancear the cluster and see the fully rebalanced cluster:

Want to get started with Couchbase? Look at Couchbase Starter Kits.
Want to learn more about running Couchbase in containers?
Autor
Una respuesta
-
[…] may also consider running Couchbase Cluster using Docker or read more about Deploying Docker Services to […]

Deja un comentario
Lo siento, debes estar conectado para publicar un comentario.