Knowledge Base

Run multiple Causal Clusters locally using Docker

It’s rather easy to run multiple causal clusters on the same server or machine. You need to ensure:

  • Each cluster needs to run on its own Docker network

  • Overlapping port mappings must be prevented

  • causal_clustering.initial_discovery_members needs to contain the list of machines of its cluster only

  • Advertised hostname + port for bolt needs to be set explicitly

The following example runs 2 separate clusters of 3 core instances each:

#!/bin/sh

# cluster 1
docker network create --driver=bridge cluster1

docker run --name=core1 --detach --network=cluster1 \
    --publish=7474:7474 --publish=7473:7473 --publish=7687:7687 \
    --env=NEO4J_dbms_mode=CORE \
    --env=NEO4J_causal__clustering_expected__core__cluster__size=3 \
    --env=NEO4J_causal__clustering_initial__discovery__members=core1:5000,core2:5000,core3:5000 \
    --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
    --env=NEO4J_dbms_connector_bolt_advertised__address=localhost:7687 \
    --env=NEO4J_AUTH=none \
    neo4j:3.3-enterprise

docker run --name=core2 --detach --network=cluster1 \
    --publish=8474:7474 --publish=8473:7473 --publish=8687:7687 \
    --env=NEO4J_dbms_mode=CORE \
    --env=NEO4J_causal__clustering_expected__core__cluster__size=3 \
    --env=NEO4J_causal__clustering_initial__discovery__members=core1:5000,core2:5000,core3:5000 \
    --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
    --env=NEO4J_dbms_connector_bolt_advertised__address=localhost:8687 \
    --env=NEO4J_AUTH=none \
    neo4j:3.3-enterprise

docker run --name=core3 --detach --network=cluster1 \
    --publish=9474:7474 --publish=9473:7473 --publish=9687:7687 \
    --env=NEO4J_dbms_mode=CORE \
    --env=NEO4J_causal__clustering_expected__core__cluster__size=3 \
    --env=NEO4J_causal__clustering_initial__discovery__members=core1:5000,core2:5000,core3:5000 \
    --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
    --env=NEO4J_dbms_connector_bolt_advertised__address=localhost:9687 \
    --env=NEO4J_AUTH=none \
    neo4j:3.3-enterprise

# cluster 2
docker network create --driver=bridge cluster2

docker run --name=core21 --detach --network=cluster2 \
    --publish=17474:7474 --publish=17473:7473 --publish=17687:7687 \
    --env=NEO4J_dbms_mode=CORE \
    --env=NEO4J_causal__clustering_expected__core__cluster__size=3 \
    --env=NEO4J_causal__clustering_initial__discovery__members=core21:5000,core22:5000,core23:5000 \
    --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
    --env=NEO4J_dbms_connector_bolt_advertised__address=localhost:17687 \
    --env=NEO4J_AUTH=none \
    neo4j:3.3-enterprise

docker run --name=core22 --detach --network=cluster2 \
    --publish=18474:7474 --publish=18473:7473 --publish=18687:7687 \
    --env=NEO4J_dbms_mode=CORE \
    --env=NEO4J_causal__clustering_expected__core__cluster__size=3 \
    --env=NEO4J_causal__clustering_initial__discovery__members=core21:5000,core22:5000,core23:5000 \
    --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
    --env=NEO4J_dbms_connector_bolt_advertised__address=localhost:18687 \
    --env=NEO4J_AUTH=none \
    neo4j:3.3-enterprise

docker run --name=core23 --detach --network=cluster2 \
    --publish=19474:7474 --publish=19473:7473 --publish=19687:7687 \
    --env=NEO4J_dbms_mode=CORE \
    --env=NEO4J_causal__clustering_expected__core__cluster__size=3 \
    --env=NEO4J_causal__clustering_initial__discovery__members=core21:5000,core22:5000,core23:5000 \
    --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
    --env=NEO4J_dbms_connector_bolt_advertised__address=localhost:19687 \
    --env=NEO4J_AUTH=none \
    neo4j:3.3-enterprise