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 만들다 –d overlay 카우치베이스 |
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 카우치베이스 overlay swarm cd14345ec130 docker_gwbridge bridge local 46a19cdead82 host host local p1kbq62oxmn9 ingress overlay swarm 1b64333f45ec none null local |
Create Couchbase “master” service:
|
1 2 3 4 5 6 7 |
docker service 만들다 —name 카우치베이스–master —replicas 1 –p 8091:8091 —network 카우치베이스 –e TYPE=MASTER arungupta/카우치베이스 |
Check the created service using docker service ls command:
|
1 2 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 카우치베이스–master replicated 1/1 arungupta/카우치베이스:latest |
Create Couchbase “worker” service:
|
1 2 3 4 5 6 7 8 |
docker service 만들다 —name 카우치베이스–worker —replicas 1 —network 카우치베이스 –e TYPE=WORKER –e COUCHBASE_MASTER=카우치베이스–master.카우치베이스 –e AUTO_REBALANCE=false arungupta/카우치베이스 |
Check the created service again using docker service ls command:
|
1 2 3 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 카우치베이스–master replicated 1/1 arungupta/카우치베이스:latest zqqqk76cu1jw 카우치베이스–worker replicated 1/1 arungupta/카우치베이스: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 |
카우치베이스–worker.1.3x52hro26166@moby | ++ 설정 –m 카우치베이스–worker.1.3x52hro26166@moby | ++ sleep 15 카우치베이스–worker.1.3x52hro26166@moby | ++ /entrypoint.sh 카우치베이스–server 카우치베이스–worker.1.3x52hro26166@moby | Starting 카우치베이스 서버 — Web UI available at https://:8091 and logs available in /opt/couchbase/var/lib/couchbase/logs 카우치베이스–worker.1.3x52hro26166@moby | ++ curl –v –X POST https://127.0.0.1:8091/pools/default -d memoryQuota=300 -d indexMemoryQuota=300 카우치베이스–worker.1.3x52hro26166@moby | Note: Unnecessary use of –X 또는 —요청, POST is already inferred. 카우치베이스–worker.1.3x52hro26166@moby | * Trying 127.0.0.1… 카우치베이스–worker.1.3x52hro26166@moby | % Total % Received % Xferd Average Speed Time Time Time Current 카우치베이스–worker.1.3x52hro26166@moby | Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 —:—:— —:—:— —:—:— 0* Connected -로 127.0.0.1 (127.0.0.1) port 8091 (#0) 카우치베이스–worker.1.3x52hro26166@moby | < POST /pools/기본값 HTTP/1.1 카우치베이스–worker.1.3x52hro26166@moby | < Host: 127.0.0.1:8091 카우치베이스–worker.1.3x52hro26166@moby | < User–Agent: curl/7.49.1–DEV 카우치베이스–worker.1.3x52hro26166@moby | < 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: */* 카우치베이스–worker.1.3x52hro26166@moby | < Content–Length: 26 카우치베이스–worker.1.3x52hro26166@moby | < Content–Type: application/x–www–form–urlencoded 카우치베이스–worker.1.3x52hro26166@moby | < 카우치베이스–worker.1.3x52hro26166@moby | } [26 bytes 데이터] 카우치베이스–worker.1.3x52hro26166@moby | * upload completely sent off: 26 밖으로 of 26 bytes 카우치베이스–worker.1.3x52hro26166@moby | < HTTP/1.1 200 OK 카우치베이스–worker.1.3x52hro26166@moby | < 서버: 카우치베이스 서버 카우치베이스–worker.1.3x52hro26166@moby | < Pragma: no–cache 카우치베이스–worker.1.3x52hro26166@moby | < 날짜: Sun, 22 Jan 2017 22:01:15 GMT 카우치베이스–worker.1.3x52hro26166@moby | < Content–Length: 0 카우치베이스–worker.1.3x52hro26166@moby | < 캐시–Control: no–cache 카우치베이스–worker.1.3x52hro26166@moby | < 100 26 0 0 100 26 0 13171 —:—:— —:—:— —:—:— 26000 카우치베이스–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 카우치베이스–worker.1.3x52hro26166@moby | < Host: 127.0.0.1:8091 카우치베이스–worker.1.3x52hro26166@moby | < User–Agent: curl/7.49.1–DEV 카우치베이스–worker.1.3x52hro26166@moby | < Accept: */* 카우치베이스–worker.1.3x52hro26166@moby | < Content–Length: 50 카우치베이스–worker.1.3x52hro26166@moby | < Content–Type: application/x–www–form–urlencoded 카우치베이스–worker.1.3x52hro26166@moby | < 카우치베이스–worker.1.3x52hro26166@moby | } [50 bytes 데이터] 카우치베이스–worker.1.3x52hro26166@moby | * upload completely sent off: 50 밖으로 of 50 bytes 카우치베이스–worker.1.3x52hro26166@moby | < HTTP/1.1 200 OK 카우치베이스–worker.1.3x52hro26166@moby | < 서버: 카우치베이스 서버 카우치베이스–worker.1.3x52hro26166@moby | < Pragma: no–cache 카우치베이스–worker.1.3x52hro26166@moby | < 날짜: Sun, 22 Jan 2017 22:01:15 GMT 카우치베이스–worker.1.3x52hro26166@moby | < Content–Type: application/json 카우치베이스–worker.1.3x52hro26166@moby | < Content–Length: 39 카우치베이스–worker.1.3x52hro26166@moby | < 캐시–Control: no–cache 카우치베이스–worker.1.3x52hro26166@moby | < 카우치베이스–worker.1.3x52hro26166@moby | { [39 bytes 데이터] 100 89 100 39 100 50 3423 4389 —:—:— —:—:— —:—:— 4545 카우치베이스–worker.1.3x52hro26166@moby | * Connection #0 to host 127.0.0.1 left intact 카우치베이스–worker.1.3x52hro26166@moby | ++ curl –i –u 관리자:password –X POST https://127.0.0.1:8091/settings/indexes -d storageMode=memory_optimized 카우치베이스–worker.1.3x52hro26166@moby | % Total % Received % Xferd Average Speed Time Time Time Current 카우치베이스–worker.1.3x52hro26166@moby | Dload Upload Total Spent Left Speed 100 180 100 152 100 28 13264 2443 —:—:— —:—:— —:—:— 13818 카우치베이스–worker.1.3x52hro26166@moby | {“newBaseUri”:“https://127.0.0.1:8091/”}HTTP/1.1 200 OK 카우치베이스–worker.1.3x52hro26166@moby | 서버: 카우치베이스 서버 카우치베이스–worker.1.3x52hro26166@moby | Pragma: no–cache 카우치베이스–worker.1.3x52hro26166@moby | 날짜: Sun, 22 Jan 2017 22:01:15 GMT 카우치베이스–worker.1.3x52hro26166@moby | Content–Type: application/json 카우치베이스–worker.1.3x52hro26166@moby | Content–Length: 152 카우치베이스–worker.1.3x52hro26166@moby | 캐시–Control: no–cache 카우치베이스–worker.1.3x52hro26166@moby | 카우치베이스–worker.1.3x52hro26166@moby | ++ echo ‘Type: WORKER’ 카우치베이스–worker.1.3x52hro26166@moby | ++ ‘[‘ WORKER = WORKER ‘]’ 카우치베이스–worker.1.3x52hro26166@moby | ++ echo ‘Sleeping …’ 카우치베이스–worker.1.3x52hro26166@moby | ++ sleep 15 카우치베이스–worker.1.3x52hro26166@moby | {“storageMode”:“memory_optimized”,“indexerThreads”:0,“memorySnapshotInterval”:200,“stableSnapshotInterval”:5000,“maxRollbackPoints”:5,“logLevel”:“info”}Type: WORKER 카우치베이스–worker.1.3x52hro26166@moby | Sleeping ... 카우치베이스–worker.1.3x52hro26166@moby | +++ hostname –I 카우치베이스–worker.1.3x52hro26166@moby | +++ cut –d ‘ ‘ –f1 카우치베이스–worker.1.3x52hro26166@moby | ++ IP=10.0.0.5 카우치베이스–worker.1.3x52hro26166@moby | ++ echo ‘IP: ‘ 10.0.0.5 카우치베이스–worker.1.3x52hro26166@moby | ++ echo ‘Auto Rebalance: false’ 카우치베이스–worker.1.3x52hro26166@moby | IP: 10.0.0.5 카우치베이스–worker.1.3x52hro26166@moby | ++ ‘[‘ false = true ‘]’ 카우치베이스–worker.1.3x52hro26166@moby | ++ 카우치베이스–cli server–추가 —cluster=카우치베이스–master.카우치베이스:8091 —user=관리자 —password=password —server–추가=10.0.0.5 —server–추가–username=관리자 —server–추가–password=password 카우치베이스–worker.1.3x52hro26166@moby | Auto Rebalance: false 카우치베이스–worker.1.3x52hro26166@moby | Warning: Adding server 에서 group–manage is deprecated 카우치베이스–worker.1.3x52hro26166@moby | 서버 10.0.0.5:8091 added 카우치베이스–worker.1.3x52hro26166@moby | ++ fg 1 카우치베이스–worker.1.3x52hro26166@moby | /entrypoint.sh 카우치베이스–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 카우치베이스–worker=2 |
Check the service again using docker service ls command:
|
1 2 3 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 카우치베이스–master replicated 1/1 arungupta/카우치베이스:latest zqqqk76cu1jw 카우치베이스–worker replicated 2/2 arungupta/카우치베이스:latest |
Now you’ve a three node Couchbase cluster. Before rebalancing the cluster, let’s quickly check what does 카우치베이스 웹 콘솔 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 리밸런싱 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?
작가
1개의 응답
-
[…] may also consider running Couchbase Cluster using Docker or read more about Deploying Docker Services to […]

댓글 남기기
댓글을 달기 위해서는 로그인해야합니다.