Запускаем полусинхронну репликацию
parent
c2e002a768
commit
9ca375b7f6
12
Makefile
12
Makefile
|
@ -1,20 +1,18 @@
|
|||
cdir = $(shell pwd)
|
||||
|
||||
app-up:
|
||||
docker-compose -f ./cicd/dc_app.yml up -d --build ; \
|
||||
docker-compose -f ./cicd/dc_app.yml up -d --build
|
||||
|
||||
app-down:
|
||||
docker-compose -f ./cicd/dc_app.yml down ; \
|
||||
docker-compose -f ./cicd/dc_app.yml down
|
||||
|
||||
app-reload:
|
||||
docker-compose -f ./cicd/dc_app.yml down ; \
|
||||
docker-compose -f ./cicd/dc_app.yml up -d
|
||||
app-reload: app-down app-up
|
||||
|
||||
db-up:
|
||||
rm -rf /opt/mysql_slave1/* ; \
|
||||
rm -rf /opt/mysql_slave2/* ; \
|
||||
docker-compose -f ./cicd/dc_db.yml up -d --build ; \
|
||||
./cicd/init.sh ; \
|
||||
./cicd/init.sh
|
||||
|
||||
db-down:
|
||||
docker-compose -f ./cicd/dc_db.yml down
|
||||
|
@ -23,7 +21,7 @@ prom-up:
|
|||
docker-compose -f ./test/monitor/docker-compose.yml up -d --build
|
||||
|
||||
prom-down:
|
||||
docker-compose -f ./test/monitor/docker-compose.yml down ; \
|
||||
docker-compose -f ./test/monitor/docker-compose.yml down
|
||||
|
||||
up: db-up app-up prom-up
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ do
|
|||
sleep 4
|
||||
done
|
||||
|
||||
priv_stmt='CREATE DATABASE IF NOT EXISTS app CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL ON app.* TO "app"@"%" IDENTIFIED BY "app"; GRANT REPLICATION SLAVE ON *.* TO "mydb_slave_user"@"%" IDENTIFIED BY "mydb_slave_pwd"; FLUSH PRIVILEGES;'
|
||||
priv_stmt='INSTALL PLUGIN rpl_semi_sync_master SONAME "semisync_master.so"; CREATE DATABASE IF NOT EXISTS app CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL ON app.* TO "app"@"%" IDENTIFIED BY "app"; GRANT REPLICATION SLAVE ON *.* TO "mydb_slave_user"@"%" IDENTIFIED BY "mydb_slave_pwd"; FLUSH PRIVILEGES;'
|
||||
docker exec mysql_master sh -c "export MYSQL_PWD=root; mysql -u root -e '$priv_stmt'"
|
||||
|
||||
until docker exec mysql_slave1 sh -c 'export MYSQL_PWD=root; mysql -u root -e ";"'
|
||||
|
@ -21,7 +21,7 @@ do
|
|||
sleep 4
|
||||
done
|
||||
|
||||
priv_stmt='CREATE DATABASE IF NOT EXISTS app CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL ON app.* TO "app"@"%" IDENTIFIED BY "app"; FLUSH PRIVILEGES;'
|
||||
priv_stmt='INSTALL PLUGIN rpl_semi_sync_slave SONAME "semisync_slave.so"; CREATE DATABASE IF NOT EXISTS app CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL ON app.* TO "app"@"%" IDENTIFIED BY "app"; FLUSH PRIVILEGES;'
|
||||
docker exec mysql_slave1 sh -c "export MYSQL_PWD=root; mysql -u root -e '$priv_stmt'"
|
||||
docker exec mysql_slave2 sh -c "export MYSQL_PWD=root; mysql -u root -e '$priv_stmt'"
|
||||
|
||||
|
|
|
@ -5,5 +5,13 @@ skip-name-resolve
|
|||
|
||||
server-id = 1
|
||||
log_bin = /var/log/mysql/mysql-bin.log
|
||||
# binlog_format = ROW
|
||||
binlog_do_db = app
|
||||
binlog_do_db = app
|
||||
|
||||
binlog_format=ROW
|
||||
binlog-checksum=crc32
|
||||
|
||||
gtid-mode=on
|
||||
enforce-gtid-consistency=true
|
||||
|
||||
rpl_semi_sync_master_enabled=1
|
||||
rpl_semi_sync_master_timeout=1000
|
||||
|
|
|
@ -6,4 +6,13 @@ skip-name-resolve
|
|||
server-id = 2
|
||||
log_bin = /var/log/mysql/mysql-bin.log
|
||||
relay-log = /var/log/mysql/mysql-relay-bin.log
|
||||
binlog_do_db = app
|
||||
binlog_do_db = app
|
||||
|
||||
binlog_format=ROW
|
||||
binlog-checksum=crc32
|
||||
|
||||
gtid-mode=on
|
||||
enforce-gtid-consistency=true
|
||||
binlog-rows-query-log_events=1
|
||||
|
||||
rpl_semi_sync_slave_enabled=1
|
|
@ -6,4 +6,13 @@ skip-name-resolve
|
|||
server-id = 3
|
||||
log_bin = /var/log/mysql/mysql-bin.log
|
||||
relay-log = /var/log/mysql/mysql-relay-bin.log
|
||||
binlog_do_db = app
|
||||
binlog_do_db = app
|
||||
|
||||
binlog_format=ROW
|
||||
binlog-checksum=crc32
|
||||
|
||||
gtid-mode=on
|
||||
enforce-gtid-consistency=true
|
||||
binlog-rows-query-log_events=1
|
||||
|
||||
rpl_semi_sync_slave_enabled=1
|
|
@ -130,35 +130,17 @@ binlog_do_db = app
|
|||
### 5. Настроить 2 слейва и 1 мастер.
|
||||
Пропускаю этот пункт, т.к. все уже было сделано в п.1
|
||||
### 6. Включить row-based репликацию.
|
||||
- #### Добавляем в my.cnf мастера строки:
|
||||
- #### Добавляем в my.cnf мастера и обоих слейвов, строки:
|
||||
```
|
||||
binlog_format=ROW
|
||||
binlog-checksum=crc32
|
||||
```
|
||||
- #### Добавляем в my.cnf обоих слейвов строки:
|
||||
```
|
||||
binlog_format=ROW
|
||||
binlog-checksum=crc32
|
||||
```
|
||||
- #### Запускаем кластер и приложение:
|
||||
```
|
||||
sudo make app-up
|
||||
```
|
||||
### 7. Включить GTID.
|
||||
- #### Добавляем в my.cnf мастера строки:
|
||||
- #### Добавляем в my.cnf мастера и обоих слейвов, строки:
|
||||
```
|
||||
gtid-mode=on
|
||||
enforce-gtid-consistency=true
|
||||
```
|
||||
- #### Добавляем в my.cnf обоих слейвов строки:
|
||||
```
|
||||
gtid-mode=on
|
||||
enforce-gtid-consistency=true
|
||||
```
|
||||
- #### Запускаем кластер и приложение:
|
||||
```
|
||||
sudo make app-up
|
||||
```
|
||||
### 8. Настроить полусинхронную репликацию.
|
||||
- #### Включаем динамическую загрузку модулей и полусинхронную репликацию с таймаутом 1с в my.cnf на мастере:
|
||||
```
|
||||
|
@ -173,11 +155,11 @@ binlog_do_db = app
|
|||
```
|
||||
- #### Устанавливаем semisync плагин на мастере:
|
||||
```
|
||||
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
|
||||
INSTALL PLUGIN rpl_semi_sync_master SONAME "semisync_master.so";
|
||||
```
|
||||
- #### Устанавливаем semisync плагин на обоих слейвах:
|
||||
```
|
||||
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
|
||||
INSTALL PLUGIN rpl_semi_sync_slave SONAME "semisync_slave.so";
|
||||
```
|
||||
- #### Проверяем на всех хостах, установлен ли плагин:
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue