From cd873fad23ac91819307e6fb8033aaa5ef22c2a4 Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Tue, 25 Jun 2024 12:27:41 +0200 Subject: [PATCH 1/2] Add docker-compose example --- docker-compose/HA_register.cypher | 7 +++ docker-compose/README.md | 4 ++ docker-compose/docker-compose.yml | 73 +++++++++++++++++++++++++++++++ docker-compose/license.cypher | 2 + 4 files changed, 86 insertions(+) create mode 100644 docker-compose/HA_register.cypher create mode 100644 docker-compose/README.md create mode 100644 docker-compose/docker-compose.yml create mode 100644 docker-compose/license.cypher diff --git a/docker-compose/HA_register.cypher b/docker-compose/HA_register.cypher new file mode 100644 index 0000000..7b28ac1 --- /dev/null +++ b/docker-compose/HA_register.cypher @@ -0,0 +1,7 @@ +ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "coord2:7691", "coordinator_server": "coord2:10112"}; +ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "coord3:7692", "coordinator_server": "coord3:10113"}; + +REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "instance1:7687", "management_server": "instance1:10011", "replication_server": "instance1:10001"}; +REGISTER INSTANCE instance_2 WITH CONFIG {"bolt_server": "instance2:7688", "management_server": "instance2:10012", "replication_server": "instance2:10002"}; +REGISTER INSTANCE instance_3 WITH CONFIG {"bolt_server": "instance3:7689", "management_server": "instance3:10013", "replication_server": "instance3:10003"}; +SET INSTANCE instance_3 TO MAIN; diff --git a/docker-compose/README.md b/docker-compose/README.md new file mode 100644 index 0000000..66f204d --- /dev/null +++ b/docker-compose/README.md @@ -0,0 +1,4 @@ +## Instructions + +This directory contains all necessary code needed to run your own highly-available Memgraph cluster with one command, `docker compose up`. +The only thing you need to do is add your `ORGANIZATION NAME` and `ENTERPRISE LICENSE` in license.cypher file. diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml new file mode 100644 index 0000000..0f6702e --- /dev/null +++ b/docker-compose/docker-compose.yml @@ -0,0 +1,73 @@ +networks: + memgraph_ha: + name: memgraph_ha + driver: bridge + ipam: + driver: default + config: + - subnet: "172.21.0.0/16" + +services: + coord1: + image: "memgraph/memgraph" + container_name: coord1 + volumes: + - ./license.cypher:/tmp/init/license.cypher:ro + - ./HA_register.cypher:/tmp/init/HA_register.cypher:ro + environment: + - MEMGRAPH_HA_CLUSTER_INIT_QUERIES=/tmp/init/HA_register.cypher + command: [ "--init-file=/tmp/init/license.cypher", "--log-level=TRACE", "--data-directory=/tmp/mg_data_coord1", "--log-file=/tmp/coord1.log", "--also-log-to-stderr", "--coordinator-id=1", "--coordinator-port=10111", "--coordinator-hostname=coord1", "--experimental-enabled=high-availability"] + networks: + memgraph_ha: + ipv4_address: 172.21.0.4 + + coord2: + image: "memgraph/memgraph" + container_name: coord2 + volumes: + - ./license.cypher:/tmp/init/license.cypher:ro + command: [ "--init-file=/tmp/init/license.cypher", "--log-level=TRACE", "--data-directory=/tmp/mg_data_coord2", "--log-file=/tmp/coord2.log", "--also-log-to-stderr", "--coordinator-id=2", "--coordinator-port=10112", "--coordinator-hostname=coord2", "--experimental-enabled=high-availability"] + networks: + memgraph_ha: + ipv4_address: 172.21.0.2 + + coord3: + image: "memgraph/memgraph" + container_name: coord3 + volumes: + - ./license.cypher:/tmp/init/license.cypher:ro + command: [ "--init-file=/tmp/init/license.cypher", "--log-level=TRACE", "--data-directory=/tmp/mg_data_coord3", "--log-file=/tmp/coord3.log", "--also-log-to-stderr", "--coordinator-id=3", "--coordinator-port=10113", "--coordinator-hostname=coord3", "--experimental-enabled=high-availability"] + + networks: + memgraph_ha: + ipv4_address: 172.21.0.3 + + instance1: + image: "memgraph/memgraph" + container_name: instance1 + volumes: + - ./license.cypher:/tmp/init/license.cypher:ro + command: ["--init-file=/tmp/init/license.cypher","--data-recovery-on-startup=true", "--log-level=TRACE", "--data-directory=/tmp/mg_data_instance1", "--log-file=/tmp/instance1.log", "--also-log-to-stderr", "--management-port=10011", "--experimental-enabled=high-availability"] + networks: + memgraph_ha: + ipv4_address: 172.21.0.6 + + instance2: + image: "memgraph/memgraph" + container_name: instance2 + volumes: + - ./license.cypher:/tmp/init/license.cypher:ro + command: ["--init-file=/tmp/init/license.cypher","--data-recovery-on-startup=true", "--log-level=TRACE", "--data-directory=/tmp/mg_data_instance2", "--log-file=/tmp/instance2.log", "--also-log-to-stderr", "--management-port=10012", "--experimental-enabled=high-availability"] + networks: + memgraph_ha: + ipv4_address: 172.21.0.7 + + instance3: + image: "memgraph/memgraph" + container_name: instance3 + volumes: + - ./license.cypher:/tmp/init/license.cypher:ro + command: ["--init-file=/tmp/init/license.cypher","--data-recovery-on-startup=true", "--log-level=TRACE", "--data-directory=/tmp/mg_data_instance3", "--log-file=/tmp/instance3.log", "--also-log-to-stderr", "--management-port=10013", "--experimental-enabled=high-availability"] + networks: + memgraph_ha: + ipv4_address: 172.21.0.8 diff --git a/docker-compose/license.cypher b/docker-compose/license.cypher new file mode 100644 index 0000000..71a4ae2 --- /dev/null +++ b/docker-compose/license.cypher @@ -0,0 +1,2 @@ +SET DATABASE SETTING 'organization.name' TO ''; +SET DATABASE SETTING 'enterprise.license' TO ''; From 2f8f57947594d7da659ef09fbfaf26b7cc814928 Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Mon, 1 Jul 2024 11:00:49 +0200 Subject: [PATCH 2/2] Improved README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5426d10..c6c77bc 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,11 @@ Once Memgraph cluster is up and running, you can access it using the provided se To upgrade or uninstall a deployed Memgraph release, you can use the `helm upgrade` or `helm uninstall` commands, respectively. Refer to the [Helm documentation](https://helm.sh/docs/) for more details on these commands. +## Docker Compose + +Creates HA Memgraph cluster with one command. The only thing you need to do is add your license details. Used bridged docker network for +communication. + ## Contributing Contributions are welcome! If you have any improvements, bug fixes, or new charts to add, please follow the contribution guidelines outlined in the [`CONTRIBUTING.md`](https://github.com/memgraph/helm-charts/blob/main/CONTRIBUTING.md) file. If you have questions and are unsure of how to contribute, please join our Discord server to get in touch with us.