-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf($MySQL): Docker supports MySQL cluster based on binary log
[skip ci]
- Loading branch information
1 parent
6f55581
commit bab526a
Showing
23 changed files
with
209 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# How to Configure MySQL Cluster | ||
|
||
[TOC] | ||
|
||
## File Description | ||
|
||
These files below are MySQL initialization scripts: | ||
|
||
``` | ||
script | ||
mysql | ||
init_replication_user.sql | ||
muscle_and_fitness.sql | ||
``` | ||
|
||
## Useful MySQL command | ||
|
||
### On Slave MySQL Server | ||
|
||
1. Connect to MySQL | ||
|
||
```mysql | ||
mysql -u root -pjm@mysql | ||
``` | ||
|
||
2. Change master server configuration | ||
|
||
```mysql | ||
CHANGE MASTER TO | ||
MASTER_HOST='maf-mysql-server-master-development-docker', | ||
MASTER_PORT=3306, | ||
MASTER_USER='replication_user', | ||
MASTER_PASSWORD='replication_password', | ||
GET_MASTER_PUBLIC_KEY=1, | ||
MASTER_AUTO_POSITION=1; | ||
``` | ||
|
||
3. Start slave | ||
|
||
```mysql | ||
START SLAVE; | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[mysqld] | ||
|
||
# For advice on how to change settings please see | ||
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html | ||
# | ||
# Remove leading # and set to the amount of RAM for the most important data | ||
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. | ||
# innodb_buffer_pool_size = 128M | ||
# | ||
# Remove leading # to turn on a very important data integrity option: logging | ||
# changes to the binary log between backups. | ||
# log_bin | ||
# | ||
# Remove leading # to set options mainly useful for reporting servers. | ||
# The server defaults are faster for transactions and fast SELECTs. | ||
# Adjust sizes as needed, experiment to find the optimal values. | ||
# join_buffer_size = 128M | ||
# sort_buffer_size = 2M | ||
# read_rnd_buffer_size = 2M | ||
|
||
# Remove leading # to revert to previous value for default_authentication_plugin, | ||
# this will increase compatibility with older clients. For background, see: | ||
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin | ||
# default-authentication-plugin=mysql_native_password | ||
skip-host-cache | ||
skip-name-resolve | ||
datadir=/var/lib/mysql | ||
socket=/var/lib/mysql/mysql.sock | ||
secure-file-priv=/var/lib/mysql-files | ||
user=mysql | ||
|
||
pid-file=/var/run/mysqld/mysqld.pid | ||
|
||
# Database default character set, mainstream character set supports some special emoticons (4 bytes of special emotions) | ||
character-set-server=utf8mb4 | ||
|
||
# Database character set corresponds to some rules such as sorting, | ||
# pay attention to the corresponding correspondence with CHARACTER-SET-Server | ||
collation-server=utf8mb4_general_ci | ||
|
||
# Set the character set when the client is connected to MySQL, prevent garbled binlog_checksum | ||
init_connect='SET NAMES utf8mb4' | ||
|
||
# GTID mode https://chanjarster.github.io/post/mysql-master-slave-docker-example/ | ||
server_id=1 | ||
binlog_format=ROW | ||
log_bin=mysql-bin | ||
gtid_mode=ON | ||
enforce_gtid_consistency=true | ||
binlog-ignore-db=information_schema | ||
binlog-ignore-db=performance_schema | ||
binlog-ignore-db=mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[mysqld] | ||
|
||
# For advice on how to change settings please see | ||
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html | ||
# | ||
# Remove leading # and set to the amount of RAM for the most important data | ||
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. | ||
# innodb_buffer_pool_size = 128M | ||
# | ||
# Remove leading # to turn on a very important data integrity option: logging | ||
# changes to the binary log between backups. | ||
# log_bin | ||
# | ||
# Remove leading # to set options mainly useful for reporting servers. | ||
# The server defaults are faster for transactions and fast SELECTs. | ||
# Adjust sizes as needed, experiment to find the optimal values. | ||
# join_buffer_size = 128M | ||
# sort_buffer_size = 2M | ||
# read_rnd_buffer_size = 2M | ||
|
||
# Remove leading # to revert to previous value for default_authentication_plugin, | ||
# this will increase compatibility with older clients. For background, see: | ||
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin | ||
# default-authentication-plugin=mysql_native_password | ||
skip-host-cache | ||
skip-name-resolve | ||
datadir=/var/lib/mysql | ||
socket=/var/lib/mysql/mysql.sock | ||
secure-file-priv=/var/lib/mysql-files | ||
user=mysql | ||
|
||
pid-file=/var/run/mysqld/mysqld.pid | ||
|
||
# Database default character set, mainstream character set supports some special emoticons (4 bytes of special emotions) | ||
character-set-server=utf8mb4 | ||
|
||
# Database character set corresponds to some rules such as sorting, | ||
# pay attention to the corresponding correspondence with CHARACTER-SET-Server | ||
collation-server=utf8mb4_general_ci | ||
|
||
# Set the character set when the client is connected to MySQL, prevent garbled binlog_checksum | ||
init-connect='SET NAMES utf8mb4' | ||
|
||
# GTID mode https://chanjarster.github.io/post/mysql-master-slave-docker-example/ | ||
server_id=2 | ||
binlog_format=ROW | ||
gtid_mode=ON | ||
enforce_gtid_consistency=true | ||
read-only=ON | ||
skip-log-bin | ||
skip-log-slave-updates | ||
skip-slave-start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE USER 'replication_user'@'%' IDENTIFIED BY 'replication_password'; | ||
GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%'; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.