Skip to content

Commit 866355f

Browse files
authored
Add docker-compose example (memgraph#31)
* Add docker-compose example for running HA via compose sample.
1 parent 4592e95 commit 866355f

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ Once Memgraph cluster is up and running, you can access it using the provided se
7878

7979
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.
8080

81+
## Docker Compose
82+
83+
Creates HA Memgraph cluster with one command. The only thing you need to do is add your license details. Used bridged docker network for
84+
communication.
85+
8186

8287
## Contributing
8388
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.

docker-compose/HA_register.cypher

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "coord2:7691", "coordinator_server": "coord2:10112"};
2+
ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "coord3:7692", "coordinator_server": "coord3:10113"};
3+
4+
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "instance1:7687", "management_server": "instance1:10011", "replication_server": "instance1:10001"};
5+
REGISTER INSTANCE instance_2 WITH CONFIG {"bolt_server": "instance2:7688", "management_server": "instance2:10012", "replication_server": "instance2:10002"};
6+
REGISTER INSTANCE instance_3 WITH CONFIG {"bolt_server": "instance3:7689", "management_server": "instance3:10013", "replication_server": "instance3:10003"};
7+
SET INSTANCE instance_3 TO MAIN;

docker-compose/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Instructions
2+
3+
This directory contains all necessary code needed to run your own highly-available Memgraph cluster with one command, `docker compose up`.
4+
The only thing you need to do is add your `ORGANIZATION NAME` and `ENTERPRISE LICENSE` in license.cypher file.

docker-compose/docker-compose.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
networks:
2+
memgraph_ha:
3+
name: memgraph_ha
4+
driver: bridge
5+
ipam:
6+
driver: default
7+
config:
8+
- subnet: "172.21.0.0/16"
9+
10+
services:
11+
coord1:
12+
image: "memgraph/memgraph"
13+
container_name: coord1
14+
volumes:
15+
- ./license.cypher:/tmp/init/license.cypher:ro
16+
- ./HA_register.cypher:/tmp/init/HA_register.cypher:ro
17+
environment:
18+
- MEMGRAPH_HA_CLUSTER_INIT_QUERIES=/tmp/init/HA_register.cypher
19+
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"]
20+
networks:
21+
memgraph_ha:
22+
ipv4_address: 172.21.0.4
23+
24+
coord2:
25+
image: "memgraph/memgraph"
26+
container_name: coord2
27+
volumes:
28+
- ./license.cypher:/tmp/init/license.cypher:ro
29+
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"]
30+
networks:
31+
memgraph_ha:
32+
ipv4_address: 172.21.0.2
33+
34+
coord3:
35+
image: "memgraph/memgraph"
36+
container_name: coord3
37+
volumes:
38+
- ./license.cypher:/tmp/init/license.cypher:ro
39+
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"]
40+
41+
networks:
42+
memgraph_ha:
43+
ipv4_address: 172.21.0.3
44+
45+
instance1:
46+
image: "memgraph/memgraph"
47+
container_name: instance1
48+
volumes:
49+
- ./license.cypher:/tmp/init/license.cypher:ro
50+
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"]
51+
networks:
52+
memgraph_ha:
53+
ipv4_address: 172.21.0.6
54+
55+
instance2:
56+
image: "memgraph/memgraph"
57+
container_name: instance2
58+
volumes:
59+
- ./license.cypher:/tmp/init/license.cypher:ro
60+
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"]
61+
networks:
62+
memgraph_ha:
63+
ipv4_address: 172.21.0.7
64+
65+
instance3:
66+
image: "memgraph/memgraph"
67+
container_name: instance3
68+
volumes:
69+
- ./license.cypher:/tmp/init/license.cypher:ro
70+
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"]
71+
networks:
72+
memgraph_ha:
73+
ipv4_address: 172.21.0.8

docker-compose/license.cypher

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SET DATABASE SETTING 'organization.name' TO '<YOUR_ORGANIZATION_NAME>';
2+
SET DATABASE SETTING 'enterprise.license' TO '<YOUR_ENTERPRISE_LICENSE>';

0 commit comments

Comments
 (0)