Skip to content

Commit 9ceb075

Browse files
committed
Initial commit
0 parents  commit 9ceb075

14 files changed

+871
-0
lines changed

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
node_modules
2+
HELP.md
3+
target/
4+
!.mvn/wrapper/maven-wrapper.jar
5+
!**/src/main/**/target/
6+
!**/src/test/**/target/
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
17+
### IntelliJ IDEA ###
18+
.idea
19+
*.iws
20+
*.iml
21+
*.ipr
22+
23+
### NetBeans ###
24+
/nbproject/private/
25+
/nbbuild/
26+
/dist/
27+
/nbdist/
28+
/.nb-gradle/
29+
build/
30+
!**/src/main/**/build/
31+
!**/src/test/**/build/
32+
33+
### VS Code ###
34+
.vscode/

.mvn/wrapper/maven-wrapper.jar

57.4 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Spring Boot Data JPA + MariaDB MaxScale demo
2+
3+
This example shows how to use MariaDB MaxScale as a database proxy to load balance writes to
4+
primary servers and reads to replicas.
5+
6+
## Set up the database using Docker
7+
8+
Clone the following repository which contains Docker images to set up replication and MaxScale:
9+
10+
```
11+
git clone https://github.com/alejandro-du/mariadb-docker-deployments.git
12+
```
13+
14+
Build the images:
15+
16+
´´´
17+
cd mariadb-docker-deployments
18+
docker build --file single-node/Dockerfile --tag alejandrodu/mariadb-single-node .
19+
docker build --file primary/Dockerfile --tag alejandrodu/mariadb-primary .
20+
docker build --file replica/Dockerfile --tag alejandrodu/mariadb-replica .
21+
docker build --file maxscale/Dockerfile --tag alejandrodu/mariadb-maxscale .
22+
´´´
23+
24+
Alternatively, you can use the **build.sh** script if you are on Linux.
25+
26+
Run the containers:
27+
28+
´´´
29+
docker compose up -d
30+
´´´
31+
32+
## Run the web application
33+
34+
Build the Java web application using Maven:
35+
36+
´´´
37+
mvn package
38+
´´´
39+
40+
Run it:
41+
42+
´´´
43+
java -jar target/webapp.jar
44+
´´´
45+
46+
Access the application in your browser at http://localhost:8080.
47+

docker-compose.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: "3.9"
2+
services:
3+
node01:
4+
image: alejandrodu/mariadb-primary
5+
ports:
6+
- 3306:3306
7+
networks:
8+
network:
9+
ipv4_address: 192.0.0.10
10+
node02:
11+
image: alejandrodu/mariadb-replica
12+
command: --server_id 2
13+
environment:
14+
MARIADB_PRIMARY_HOST: 192.0.0.10
15+
ports:
16+
- 3307:3306
17+
networks:
18+
network:
19+
ipv4_address: 192.0.0.11
20+
node03:
21+
image: alejandrodu/mariadb-replica
22+
command: --server_id 3
23+
environment:
24+
MARIADB_PRIMARY_HOST: 192.0.0.10
25+
ports:
26+
- 3308:3306
27+
networks:
28+
network:
29+
ipv4_address: 192.0.0.12
30+
maxscale:
31+
image: alejandrodu/mariadb-maxscale
32+
depends_on:
33+
- node01
34+
- node02
35+
- node03
36+
environment:
37+
MARIADB_HOST_1: 192.0.0.10
38+
MARIADB_HOST_2: 192.0.0.11
39+
MARIADB_HOST_3: 192.0.0.12
40+
ports:
41+
- 4000:4000
42+
networks:
43+
network:
44+
ipv4_address: 192.0.0.200
45+
networks:
46+
network:
47+
ipam:
48+
driver: default
49+
config:
50+
- subnet: 192.0.0.0/24

0 commit comments

Comments
 (0)