도커 스웜 및 서비스 모드로 카우치베이스 클러스터 생성하기 는 Docker를 사용하여 Couchbase 클러스터를 생성하는 방법을 설명했습니다. 클러스터 생성을 단순화하고 자동화하기 위해 "마스터"와 "워커" 서비스의 개념을 사용했습니다. 그런 다음 아래 아키텍처 다이어그램과 같이 균일한 클러스터가 생성되었습니다:

자세한 내용과 배경은 Docker를 사용한 카우치베이스 클러스터 블로그.
Docker 1.13 가 지난주에 출시되었습니다. 이 릴리스의 새로운 기능으로 다음을 수행할 수 있습니다. Docker Compose를 사용하여 정의한 멀티 컨테이너 애플리케이션을 멀티 호스트에 배포하기 스웜 모드를 사용하여 활성화합니다. 이상적으로는 하나의 도커 컴포즈 정의를 통해 "마스터" 서비스를 시작하고 "워커" 서비스를 시작/확장할 수 있습니다. 그러나 "마스터" 서비스, 더 중요하게는 서비스 내의 컨테이너가 완전히 가동되어야 "워커" 서비스를 시작할 수 있습니다. 이는 "작업자" 서비스의 컨테이너가 "마스터" 서비스의 컨테이너와 함께 등록되어 클러스터를 생성하기 때문입니다. 이를 위해서는 일반적으로 다음에서 정의된 대로 약간의 수작업이 필요합니다. Compose에서 시작 순서 제어. 나중에 이 버전으로 다시 돌아오겠습니다.
이 블로그에서는 Docker 1.13을 사용하여 원래의 단계를 간략하게 다시 설명합니다. 이 블로그에서 간단한 방법과 오리지널 블로그 에서 자세한 이유를 확인하세요.
네트워크 만들기:
|
1 2 3 |
docker network create -d overlay couchbase |
다음을 사용하여 생성된 네트워크를 확인합니다. 도커 네트워크 ls 명령을 사용합니다:
|
1 2 3 4 5 6 7 |
NETWORK ID NAME DRIVER SCOPE 20a28d56f140 bridge bridge local 5maq7fyqdemx couchbase overlay swarm cd14345ec130 docker_gwbridge bridge local 46a19cdead82 host host local p1kbq62oxmn9 ingress overlay swarm 1b64333f45ec none null local |
Couchbase "마스터" 서비스를 만듭니다:
|
1 2 3 4 5 6 7 |
docker service create --name couchbase-master --replicas 1 -p 8091:8091 --network couchbase -e TYPE=MASTER arungupta/couchbase |
다음을 사용하여 생성된 서비스를 확인합니다. 도커 서비스 ls 명령을 사용합니다:
|
1 2 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 couchbase-master replicated 1/1 arungupta/couchbase:latest |
Couchbase "작업자" 서비스를 만듭니다:
|
1 2 3 4 5 6 7 8 |
docker service create --name couchbase-worker --replicas 1 --network couchbase -e TYPE=WORKER -e COUCHBASE_MASTER=couchbase-master.couchbase -e AUTO_REBALANCE=false arungupta/couchbase |
생성된 서비스를 다시 확인하려면 도커 서비스 ls 명령을 사용합니다:
|
1 2 3 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 couchbase-master replicated 1/1 arungupta/couchbase:latest zqqqk76cu1jw couchbase-worker replicated 1/1 arungupta/couchbase:latest |
새로 도입된 명령을 사용하여 워커 서비스 로그 확인 도커 서비스 로그 카우치베이스-워커 명령어를 사용하세요. Docker 1.13에 새로 도입된 이 명령은 서비스의 모든 컨테이너에서 로그를 가져와서 콘솔로 스트리밍합니다. 어떤 컨테이너가 어떤 호스트에서 실행 중인지 추적할 필요가 없습니다.
|
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 | ++ set -m couchbase-worker.1.3x52hro26166@moby | ++ sleep 15 couchbase-worker.1.3x52hro26166@moby | ++ /entrypoint.sh couchbase-server couchbase-worker.1.3x52hro26166@moby | Starting Couchbase Server -- Web UI 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 | Note: Unnecessary use of -X or --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 to 127.0.0.1 (127.0.0.1) port 8091 (#0) couchbase-worker.1.3x52hro26166@moby | > POST /pools/default 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 | > 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 | > Content-Length: 26 couchbase-worker.1.3x52hro26166@moby | > Content-Type: application/x-www-form-urlencoded couchbase-worker.1.3x52hro26166@moby | > couchbase-worker.1.3x52hro26166@moby | } [26 bytes data] 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 | < 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 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 | > 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 | > Content-Length: 50 couchbase-worker.1.3x52hro26166@moby | > Content-Type: application/x-www-form-urlencoded couchbase-worker.1.3x52hro26166@moby | > couchbase-worker.1.3x52hro26166@moby | } [50 bytes data] 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 | < 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-Type: application/json couchbase-worker.1.3x52hro26166@moby | < Content-Length: 39 couchbase-worker.1.3x52hro26166@moby | < Cache-Control: no-cache couchbase-worker.1.3x52hro26166@moby | < couchbase-worker.1.3x52hro26166@moby | { [39 bytes data] 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 Administrator:password -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 | 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-Type: application/json couchbase-worker.1.3x52hro26166@moby | Content-Length: 152 couchbase-worker.1.3x52hro26166@moby | Cache-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"}Type: 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 | ++ '[' false = true ']' couchbase-worker.1.3x52hro26166@moby | ++ couchbase-cli server-add --cluster=couchbase-master.couchbase:8091 --user=Administrator --password=password --server-add=10.0.0.5 --server-add-username=Administrator --server-add-password=password couchbase-worker.1.3x52hro26166@moby | Auto Rebalance: false couchbase-worker.1.3x52hro26166@moby | Warning: Adding server from group-manage is deprecated couchbase-worker.1.3x52hro26166@moby | Server 10.0.0.5:8091 added couchbase-worker.1.3x52hro26166@moby | ++ fg 1 couchbase-worker.1.3x52hro26166@moby | /entrypoint.sh couchbase-server |
전체 로그는 "worker" 서비스가 어떻게 생성되어 원래 "master"가 만든 클러스터에 가입했는지 보여줍니다.
Docker 서비스를 확장하여 클러스터를 확장합니다:
|
1 |
docker service scale couchbase-worker=2 |
다음을 사용하여 서비스를 다시 확인하세요. 도커 서비스 ls 명령을 사용합니다:
|
1 2 3 |
ID NAME MODE REPLICAS IMAGE v5m0owjs4qo3 couchbase-master replicated 1/1 arungupta/couchbase:latest zqqqk76cu1jw couchbase-worker replicated 2/2 arungupta/couchbase:latest |
이제 3노드 Couchbase 클러스터가 생겼습니다. 이전 클러스터 재조정의 기능을 빠르게 확인해 보겠습니다. 카우치베이스 웹 콘솔 를 표시합니다.
카우치베이스 웹 콘솔은 다음에서 액세스할 수 있습니다. https://localhost:8091 데이터, 인덱스 및 쿼리 서비스가 있는 단일 Couchbase 노드를 보여줍니다. 이 노드는 "master" 서비스를 사용하여 생성되었습니다. "worker" 서비스를 사용하여 생성된 두 개의 추가 노드가 표시되어 있습니다. 보류 중인 재조정 탭을 클릭합니다:

재조정을 클릭하여 재조정 를 클릭하고 완전히 재조정된 클러스터를 확인합니다:

Couchbase를 시작하고 싶으신가요? 다음을 살펴보세요. 카우치베이스 스타터 키트.
컨테이너에서 Couchbase를 실행하는 방법에 대해 자세히 알아보고 싶으신가요?
[...] Docker를 사용하여 카우치베이스 클러스터를 실행하거나 [...]에 Docker 서비스 배포에 대해 자세히 알아볼 수도 있습니다.