-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.multinode.yml
More file actions
78 lines (71 loc) · 2.36 KB
/
Copy pathdocker-compose.multinode.yml
File metadata and controls
78 lines (71 loc) · 2.36 KB
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
# Three-node CockroachDB cluster + Redis, for failover and consistency experiments.
# The single-node docker-compose.yml remains the default for day-to-day dev; this file
# is a separate topology you select explicitly with `-f docker-compose.multinode.yml`.
#
# Host ports: SQL 26257/26258/26259 Admin UI 8089/8090/8091 Redis 6379
# Image tags pinned to match docker-compose.yml for reproducible `docker compose pull`.
#
# Default replication factor for user ranges is 3, so with three nodes the cluster
# tolerates exactly one node loss (2/3 quorum). Killing two loses quorum — that is the
# expected result, not a bug, and is itself worth measuring.
name: dtq-multinode
services:
crdb1:
image: cockroachdb/cockroach:v24.3.4
command: start --insecure --join=crdb1,crdb2,crdb3 --advertise-addr=crdb1
volumes:
- crdb1-data:/cockroach/cockroach-data
ports:
- "26257:26257"
- "8089:8080"
crdb2:
image: cockroachdb/cockroach:v24.3.4
command: start --insecure --join=crdb1,crdb2,crdb3 --advertise-addr=crdb2
volumes:
- crdb2-data:/cockroach/cockroach-data
ports:
- "26258:26257"
- "8090:8080"
crdb3:
image: cockroachdb/cockroach:v24.3.4
command: start --insecure --join=crdb1,crdb2,crdb3 --advertise-addr=crdb3
volumes:
- crdb3-data:/cockroach/cockroach-data
ports:
- "26259:26257"
- "8091:8080"
# Runs `cockroach init` once, then exits. Retries because the nodes need a moment to
# start listening, and an uninitialized node cannot answer a healthcheck yet
# (the cluster is not live until init succeeds) — so this polls instead.
crdb-init:
image: cockroachdb/cockroach:v24.3.4
depends_on:
- crdb1
- crdb2
- crdb3
restart: "no"
entrypoint: ["/bin/sh", "-ec"]
command:
- |
for i in $$(seq 1 30); do
if /cockroach/cockroach init --insecure --host=crdb1:26257 2>&1 | tee /dev/stderr | grep -qE 'success|already been initialized'; then
echo "cluster initialized"
exit 0
fi
sleep 2
done
echo "init failed after 60s" >&2
exit 1
redis:
image: redis:7.4.2-alpine
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 3s
timeout: 3s
retries: 5
volumes:
crdb1-data:
crdb2-data:
crdb3-data: