Skip to content

Updating group_replication to MySQL 8.0 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: group_replication
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions bin/docker-benchmark.bash
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#!/bin/bash
. constants

PREP_THREADS=1
RUN_THREADS=8
NUM_TABLES=10
SIZE_TABLES=100000
REPORT_INTERVAL=1
TIME=60
SCRIPT=oltp_read_write.lua
# Override these defaults by exporting them in the command line prior to
# running the script
PREP_THREADS=${PREP_THREADS:=10}
RUN_THREADS=${RUN_THREADS:=2}
NUM_TABLES=${NUM_TABLES:=10}
SIZE_TABLES=${SIZE_TABLES:=10000}
REPORT_INTERVAL=${REPORT_INTERVAL:=5}
TIME=${TIME:=60}
BENCH_TEST=${BENCH_TEST:="/usr/share/sysbench/oltp_read_write.lua"}
PROXYSQL_PORT=${PROXYSQL_PORT:="16033"}

#printf "$RED[$(date)] Dropping 'sysbench' schema if present and preparing test dataset:$NORMAL\n"
#mysql -h127.0.0.1 -P16033 -uroot -p$MYSQL_PWD -e"DROP DATABASE IF EXISTS sysbench; CREATE DATABASE IF NOT EXISTS sysbench"
printf "$RED[$(date)] Dropping 'sysbench' schema if present and preparing test dataset:$NORMAL\n"
mysql -h127.0.0.1 -P$PROXYSQL_PORT -uroot -p$MYSQL_PWD -e"DROP DATABASE IF EXISTS sysbench; CREATE DATABASE IF NOT EXISTS sysbench"

#printf "$POWDER_BLUE[$(date)] Running Sysbench Benchmarks against ProxySQL:"
#sysbench /usr/share/sysbench/$SCRIPT --table-size=$SIZE_TABLES --tables=$NUM_TABLES --threads=$PREP_THREADS \
# --mysql-db=sysbench --mysql-user=root --mysql-password=$MYSQL_PWD --mysql-host=127.0.0.1 --mysql-port=16033 --db-driver=mysql prepare
printf "$POWDER_BLUE[$(date)] Running Sysbench Benchmarks against ProxySQL:"
sysbench $BENCH_TEST --table-size=$SIZE_TABLES --tables=$NUM_TABLES --threads=$PREP_THREADS \
--mysql-db=sysbench --mysql-user=root --mysql-password=$MYSQL_PWD --mysql-host=127.0.0.1 --mysql-port=$PROXYSQL_PORT --db-driver=mysql prepare

#sleep 5

sysbench /usr/share/sysbench/$SCRIPT --table-size=$SIZE_TABLES --tables=$NUM_TABLES --threads=$RUN_THREADS \
--mysql-db=sysbench --mysql-user=root --mysql-password=$MYSQL_PWD --mysql-host=127.0.0.1 --mysql-port=16033 --skip-trx=ON \
--time=$TIME --report-interval=$REPORT_INTERVAL --db-driver=mysql run
#sysbench $BENCH_TEST --table-size=$SIZE_TABLES --tables=$NUM_TABLES --threads=$RUN_THREADS \
# --mysql-db=sysbench --mysql-user=root --mysql-password=$MYSQL_PWD --mysql-host=127.0.0.1 --mysql-port=$PROXYSQL_PORT --skip_trx=on \
# --time=$TIME --report-interval=$REPORT_INTERVAL --db-driver=mysql run

printf "$POWDER_BLUE$BRIGHT[$(date)] Benchmarking COMPLETED!$NORMAL\n"
36 changes: 11 additions & 25 deletions bin/docker-mysql-post.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
. constants

printf "$YELLOW[$(date)] Waiting for MySQL service on master"
printf "$YELLOW[$(date)] Waiting for MySQL service on primary"
# INIT REPL ONCE SLAVE IS UP
RC=1
while [ $RC -eq 1 ]
Expand All @@ -14,20 +14,16 @@ done
printf "$LIME_YELLOW\n"

mysql -h127.0.0.1 -P13306 -uroot -p$MYSQL_PWD -e" \
SET SQL_LOG_BIN=0; \
CREATE USER rpl_user@'%' IDENTIFIED BY 'password'; \
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%'; \
GRANT REPLICATION SLAVE, BACKUP_ADMIN ON *.* TO rpl_user@'%'; \
FLUSH PRIVILEGES; \
SET SQL_LOG_BIN=1; \
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='password' FOR CHANNEL 'group_replication_recovery'; \
SET GLOBAL group_replication_bootstrap_group=ON; \
SET GLOBAL group_replication_allow_local_disjoint_gtids_join=ON; \
START GROUP_REPLICATION; \
SET GLOBAL group_replication_allow_local_disjoint_gtids_join=OFF; \
SET GLOBAL group_replication_bootstrap_group=OFF; \
SELECT * FROM performance_schema.replication_group_members;"

printf "$YELLOW[$(date)] Waiting for MySQL service on slave 1"
printf "$YELLOW[$(date)] Waiting for MySQL service on replica 1"
# INIT REPL ONCE SLAVE IS UP
RC=1
while [ $RC -eq 1 ]
Expand All @@ -40,18 +36,12 @@ done
printf "$LIME_YELLOW\n"

mysql -h127.0.0.1 -P13307 -uroot -p$MYSQL_PWD -e" \
SET SQL_LOG_BIN=0; \
CREATE USER rpl_user@'%' IDENTIFIED BY 'password'; \
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%'; \
FLUSH PRIVILEGES; \
SET SQL_LOG_BIN=1; \
RESET MASTER; \
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='password' FOR CHANNEL 'group_replication_recovery'; \
SET GLOBAL group_replication_allow_local_disjoint_gtids_join=ON; \
START GROUP_REPLICATION; \
SET GLOBAL group_replication_allow_local_disjoint_gtids_join=OFF; \
SELECT * FROM performance_schema.replication_group_members;"

printf "$YELLOW[$(date)] Waiting for MySQL service on slave 2"
printf "$YELLOW[$(date)] Waiting for MySQL service on replica 2"
RC=1
while [ $RC -eq 1 ]
do
Expand All @@ -63,21 +53,17 @@ done
printf "$LIME_YELLOW\n"

mysql -h127.0.0.1 -P13308 -uroot -p$MYSQL_PWD -e" \
SET SQL_LOG_BIN=0; \
CREATE USER rpl_user@'%' IDENTIFIED BY 'password'; \
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%'; \
FLUSH PRIVILEGES; \
SET SQL_LOG_BIN=1; \
RESET MASTER; \
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='password' FOR CHANNEL 'group_replication_recovery'; \
SET GLOBAL group_replication_allow_local_disjoint_gtids_join=ON; \
START GROUP_REPLICATION; \
SET GLOBAL group_replication_allow_local_disjoint_gtids_join=OFF; \
SELECT * FROM performance_schema.replication_group_members;"

printf "$YELLOW[$(date)] Adding ProxySQL cluster state monitor script and user:"
mysql -h127.0.0.1 -P13306 -uroot -p$MYSQL_PWD < ./conf/mysql/addition_to_sys.sql 2>&1
mysql -h127.0.0.1 -P13306 -uroot -p$MYSQL_PWD -e"GRANT usage,replication client on *.* to monitor@'%' identified by 'monitor';" > /dev/null 2>&1
mysql -h127.0.0.1 -P13306 -uroot -p$MYSQL_PWD -e"GRANT SELECT on sys.* to monitor@'%';" > /dev/null 2>&1

printf "$POWDER_BLUE$BRIGHT[$(date)] MySQL Provisioning COMPLETE!$NORMAL\n"
mysql -h127.0.0.1 -P13306 -uroot -p$MYSQL_PWD -e" \
CREATE USER monitor@'%' identified by 'monitor'; \
GRANT usage,replication client on *.* to monitor@'%'; \
GRANT SELECT on sys.* to monitor@'%';" 2>&1

printf "$POWDER_BLUE$BRIGHT[$(date)] MySQL Provisioning COMPLETE!$NORMAL\n"
2 changes: 2 additions & 0 deletions bin/docker-proxy-post.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ printf "$LIME_YELLOW\n"
printf "$POWDER_BLUE[$(date)] Configuring ProxySQL...$LIME_YELLOW\n"

mysql -uradmin -pradmin -h127.0.0.1 -P16032 < $(pwd)/conf/proxysql/config.sql

printf "$POWDER_BLUE[$(date)] ProxySQL Provisioning COMPLETE!$NORMAL\n"
26 changes: 14 additions & 12 deletions conf/mysql/addition_to_sys.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
USE sys;

DELIMITER $$

CREATE FUNCTION IFZERO(a INT, b INT)
RETURNS INT
DETERMINISTIC
RETURN IF(a = 0, b, a)$$

CREATE FUNCTION LOCATE2(needle TEXT(10000), haystack TEXT(10000), offset INT)
RETURNS INT
DETERMINISTIC
RETURN IFZERO(LOCATE(needle, haystack, offset), LENGTH(haystack) + 1)$$

CREATE FUNCTION GTID_NORMALIZE(g TEXT(10000))
RETURNS TEXT(10000)
DETERMINISTIC
RETURN GTID_SUBTRACT(g, '')$$

CREATE FUNCTION GTID_COUNT(gtid_set TEXT(10000))
RETURNS INT
DETERMINISTIC
Expand Down Expand Up @@ -44,7 +44,7 @@ BEGIN
END WHILE;
RETURN result;
END$$

CREATE FUNCTION gr_applier_queue_length()
RETURNS INT
DETERMINISTIC
Expand All @@ -54,23 +54,25 @@ Received_transaction_set FROM performance_schema.replication_connection_status
WHERE Channel_name = 'group_replication_applier' ), (SELECT
@@global.GTID_EXECUTED) )));
END$$

CREATE FUNCTION gr_member_in_primary_partition()
RETURNS VARCHAR(3)
DETERMINISTIC
BEGIN
RETURN (SELECT IF( MEMBER_STATE='ONLINE' AND ((SELECT COUNT(*) FROM
performance_schema.replication_group_members WHERE MEMBER_STATE != 'ONLINE') >=
((SELECT COUNT(*) FROM performance_schema.replication_group_members)/2) = 0),
'YES', 'NO' ) FROM performance_schema.replication_group_members JOIN
performance_schema.replication_group_member_stats USING(member_id));
'YES', 'NO' ) FROM performance_schema.replication_group_members WHERE MEMBER_ID=@@SERVER_UUID);
END$$

CREATE VIEW gr_member_routing_candidate_status AS SELECT
sys.gr_member_in_primary_partition() as viable_candidate,
IF( (SELECT (SELECT GROUP_CONCAT(variable_value) FROM
performance_schema.global_variables WHERE variable_name IN ('read_only',
'super_read_only')) != 'OFF,OFF'), 'YES', 'NO') as read_only,
sys.gr_applier_queue_length() as transactions_behind, Count_Transactions_in_queue as 'transactions_to_cert' from performance_schema.replication_group_member_stats;$$

sys.gr_applier_queue_length() as transactions_behind, Count_Transactions_in_queue as 'transactions_to_cert'
from performance_schema.replication_group_member_stats rgms
where rgms.MEMBER_ID=(select gv.VARIABLE_VALUE
from `performance_schema`.global_variables gv where gv.VARIABLE_NAME='server_uuid');
$$
DELIMITER ;
14 changes: 11 additions & 3 deletions conf/mysql/mysql1/my.cnf
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
[mysqld]
ssl_ca=ca.pem
ssl_cert=server-cert.pem
ssl_key=server-key.pem

loose-group_replication_local_address= "mysql1:24901"
loose-group_replication_group_seeds= "mysql1:24901,mysql2:24901,mysql3:24901"
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"

plugin-load=group_replication.so
loose-group_replication_local_address="mysql1:24901"
loose-group_replication_group_seeds="mysql1:24901,mysql2:24901,mysql3:24901"
loose-group_replication_group_name="b30a2c04-6e46-11e8-b6e9-fbf465dfdf2c"
loose-group_replication_recovery_get_public_key=ON
loose-group_replication_start_on_boot=off
loose-group_replication_bootstrap_group=off
transaction_write_set_extraction=XXHASH64
plugin-load=group_replication.so

default_authentication_plugin=caching_sha2_password

binlog_format=ROW
binlog_checksum=NONE
Expand Down
14 changes: 11 additions & 3 deletions conf/mysql/mysql2/my.cnf
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
[mysqld]
ssl_ca=ca.pem
ssl_cert=server-cert.pem
ssl_key=server-key.pem

loose-group_replication_local_address= "mysql2:24901"
loose-group_replication_group_seeds= "mysql1:24901,mysql2:24901,mysql3:24901"
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"

plugin-load=group_replication.so
loose-group_replication_local_address="mysql2:24901"
loose-group_replication_group_seeds="mysql1:24901,mysql2:24901,mysql3:24901"
loose-group_replication_group_name="b30a2c04-6e46-11e8-b6e9-fbf465dfdf2c"
loose-group_replication_recovery_get_public_key=ON
loose-group_replication_start_on_boot=off
loose-group_replication_bootstrap_group=off
transaction_write_set_extraction=XXHASH64
plugin-load=group_replication.so

default_authentication_plugin=caching_sha2_password

binlog_format=ROW
binlog_checksum=NONE
Expand Down
14 changes: 11 additions & 3 deletions conf/mysql/mysql3/my.cnf
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
[mysqld]
ssl_ca=ca.pem
ssl_cert=server-cert.pem
ssl_key=server-key.pem

loose-group_replication_local_address= "mysql3:24901"
loose-group_replication_group_seeds= "mysql1:24901,mysql2:24901,mysql3:24901"
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"

plugin-load=group_replication.so
loose-group_replication_local_address="mysql3:24901"
loose-group_replication_group_seeds="mysql1:24901,mysql2:24901,mysql3:24901"
loose-group_replication_group_name="b30a2c04-6e46-11e8-b6e9-fbf465dfdf2c"
loose-group_replication_recovery_get_public_key=ON
loose-group_replication_start_on_boot=off
loose-group_replication_bootstrap_group=off
transaction_write_set_extraction=XXHASH64
plugin-load=group_replication.so

default_authentication_plugin=caching_sha2_password

binlog_format=ROW
binlog_checksum=NONE
Expand Down
17 changes: 9 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: "2.0"
services:
mysql1:
hostname: mysql1
image: mysql:5.7
ports:
image: mysql:8.0
ports:
- "13306:3306"
volumes:
- ./conf/mysql/mysql1:/etc/mysql/conf.d
Expand All @@ -13,8 +13,8 @@ services:
- MYSQL_ROOT_PASSWORD=root
mysql2:
hostname: mysql2
image: mysql:5.7
ports:
image: mysql:8.0
ports:
- "13307:3306"
volumes:
- ./conf/mysql/mysql2:/etc/mysql/conf.d
Expand All @@ -26,8 +26,8 @@ services:
- MYSQL_ROOT_PASSWORD=root
mysql3:
hostname: mysql3
image: mysql:5.7
ports:
image: mysql:8.0
ports:
- "13308:3306"
volumes:
- ./conf/mysql/mysql3:/etc/mysql/conf.d
Expand All @@ -37,11 +37,12 @@ services:
- mysql1
environment:
- MYSQL_ROOT_PASSWORD=root
proxysql:
image: pondix/proxysql:latest-stretch
proxysql1:
image: proxysql/proxysql:latest
ports:
- "16033:6033"
- "16032:6032"
- "16080:6080"
volumes:
- ./conf/proxysql/proxysql.cnf:/etc/proxysql.cnf
depends_on:
Expand Down