diff --git a/Makefile b/Makefile index edb38eb..b887f3e 100644 --- a/Makefile +++ b/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 diff --git a/cicd/init.sh b/cicd/init.sh index baa8fce..7eafe14 100755 --- a/cicd/init.sh +++ b/cicd/init.sh @@ -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'" diff --git a/cicd/mysql/mysql_master.conf b/cicd/mysql/mysql_master.conf index 59beac8..c0acfa6 100644 --- a/cicd/mysql/mysql_master.conf +++ b/cicd/mysql/mysql_master.conf @@ -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 \ No newline at end of file +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 diff --git a/cicd/mysql/mysql_slave1.conf b/cicd/mysql/mysql_slave1.conf index e85c7d4..9039664 100644 --- a/cicd/mysql/mysql_slave1.conf +++ b/cicd/mysql/mysql_slave1.conf @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/cicd/mysql/mysql_slave2.conf b/cicd/mysql/mysql_slave2.conf index ea55657..5d6f470 100644 --- a/cicd/mysql/mysql_slave2.conf +++ b/cicd/mysql/mysql_slave2.conf @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/test/dz003/REPORT.md b/test/dz003/REPORT.md index ab53f16..1dd7c8e 100644 --- a/test/dz003/REPORT.md +++ b/test/dz003/REPORT.md @@ -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"; ``` - #### Проверяем на всех хостах, установлен ли плагин: ```