Skip to content

Commit 41d322a

Browse files
author
Vishal Raj
committed
Updated README.md
1 parent 64283bc commit 41d322a

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

README.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,65 @@
1+
# Introduction
2+
13
This is a sample work to learn about docker, containers, running MySQL in docker and setting up MySQL
24
replication using docker containers.
35

6+
# Directory structure explained
47
Here is the directory structure and its explanation
58

69
MySQLReplDocker
710
|
811
+--- conf/
9-
| |
1012
| +--- master1.cnf
1113
| +--- master2.cnf
1214
| +--- slave1.cnf
1315
| +--- slave2.cnf
14-
|
1516
+--- data/
16-
| |
1717
| +--- master1/
1818
| +--- master2/
1919
| +--- slave1/
2020
| +--- slave2/
21-
|
2221
+--- docker/
23-
| |
2422
| +--- master-2-slave.yml
2523
| +--- master-2-master.yml
2624
| +--- slave-2-master-2-master-2-slave.yml
27-
|
2825
+--- scripts/
29-
| |
3026
| +--- common-functions.sh
3127
| +--- master-2-slave.sh
3228
| +--- master-2-master.sh
3329
| +--- slave-2-master-2-master-2-slave.sh
34-
|
3530
+--- start.sh
3631
+--- stop.sh
3732
+--- check_params.sh
3833

3934

40-
The folder "conf" contains the MySQL configuration for master and slave nodes.
41-
42-
The folder "data" contains folders to hold data for master and slave nodes.
43-
44-
The folder "docker" contains the docker container configuation files
45-
46-
The folder "scripts" contains bash script which does the real job of setup of replication between the nodes
47-
48-
49-
35+
* The folder "___conf___" contains the MySQL configuration for master and slave nodes.
36+
* The folder "___data___" contains folders to hold data for master and slave nodes.
37+
* The folder "___docker___" contains the docker container configuation files
38+
* The folder "___scripts___" contains bash script which does the real job of setup of replication between the nodes
5039

40+
# How to get MySQL containers up and running
5141
To run a MySQL master-slave container replication execute the command
52-
53-
```bash start.sh master-slave```
54-
42+
```sh
43+
bash start.sh master-slave
44+
```
5545
To run a MySQL master-master container replication execute the command
56-
57-
```bash start.sh master-master```
58-
46+
```sh
47+
bash start.sh master-master
48+
```
5949
To run a MySQL slave-master-master-slave replication execute the command
60-
61-
```bash start.sh slave-master-master-slave```
50+
```sh
51+
bash start.sh slave-master-master-slave
52+
```
53+
54+
# Seeing replication in action
55+
In order to see if the replication is actually working, you need to enable our nerd mode. Lets kick in. Execute the following command to see the docker containers which are currently running
56+
```sh
57+
bash info.sh master-slave
58+
```
59+
This will list down the containers, where you can clearly identity the MySQL master(s) and slave(s) nodes. In order to connect to any of the container, you can execute
60+
```sh
61+
docker container exec -it <name-of-container> mysql -u root -p <mysql-password>
62+
```
63+
> NOTE: Find the passwords in .env file
64+
65+
You can repeat the command for all the MySQL containers and then play around and see the replication action coming live.

info.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/bash
2+
3+
set -x
4+
5+
source check_params.sh
6+
7+
check_docker_config
8+
9+
docker-compose -f $file ps

0 commit comments

Comments
 (0)