mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-10 01:12:18 +08:00
PT-2340 - Support MySQL 8.4
- Adjusted sandbox scripts, so they can start MySQL 8.4 - Added MySQL 8.4 configuration file - Removed empty file sandbox/5.6 - Removed unused files sandbox/set-mysql, sandbox/slave_channels_t.sql, sandbox/jenkins-test - Removed offensive terminology from the sandbox scripts wherever it is possible
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
STOP SLAVE FOR CHANNEL '';
|
||||
SET GLOBAL master_info_repository = 'TABLE';
|
||||
SET @@GLOBAL.relay_log_info_repository = 'TABLE';
|
||||
STOP REPLICA FOR CHANNEL '';
|
||||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=ON;
|
||||
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
|
||||
SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is used to do a test run on a Jenkins node. Jenkins jobs
|
||||
# set env vars based on job params (like MYSQL and TEST_CMD) then execute
|
||||
# this script which does the rest. When this script exists, the Jenkins
|
||||
# job exists, so if some commands (like check-dev-env) fail, then the
|
||||
# Jenkins job will fail too.
|
||||
|
||||
##############
|
||||
# Set modes. #
|
||||
##############
|
||||
set +u
|
||||
set -e
|
||||
set -x
|
||||
|
||||
##################################
|
||||
# Check for needed Perl modules. #
|
||||
##################################
|
||||
util/check-dev-env
|
||||
|
||||
#########################
|
||||
# Check the system env. #
|
||||
#########################
|
||||
env
|
||||
df -h
|
||||
w
|
||||
whoami
|
||||
id
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
echo "Cannot run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# Install barebones MySQL binaries. #
|
||||
#####################################
|
||||
|
||||
if uname -a | grep x86_64 >/dev/null 2>&1; then
|
||||
ARCH="64"
|
||||
else
|
||||
ARCH="32"
|
||||
fi
|
||||
|
||||
APP="${FORK:-"mysql"}"
|
||||
|
||||
MYSQL_BIN_DIR="$HOME/mysql-bin"
|
||||
[ -d "$MYSQL_BIN_DIR" ] || mkdir "$MYSQL_BIN_DIR"
|
||||
|
||||
find_mysql_base_dir() {
|
||||
find "$MYSQL_BIN_DIR" -name "$APP-$1*" -type d | tail -n 1
|
||||
}
|
||||
|
||||
MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)"
|
||||
|
||||
REFETCH_MYSQL="${REFETCH_MYSQL:-""}"
|
||||
if [ "$MYSQL_BASE_DIR" -a "$REFETCH_MYSQL" ]; then
|
||||
rm -rf "$MYSQL_BASE_DIR"
|
||||
MYSQL_BASE_DIR=""
|
||||
fi
|
||||
|
||||
if [ -z "$MYSQL_BASE_DIR" ]; then
|
||||
(
|
||||
cd $MYSQL_BIN_DIR
|
||||
wget -q -O mysql.tar.gz http://10.10.7.145:8000/barebones/$APP/$MYSQL/$ARCH \
|
||||
|| exit 1
|
||||
tar xvfz mysql.tar.gz
|
||||
rm mysql.tar.gz
|
||||
)
|
||||
MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)"
|
||||
fi
|
||||
|
||||
if [ $APP = "mysql" ]; then
|
||||
mysqld_check="$("$MYSQL_BASE_DIR/bin/mysqld" -V)"
|
||||
elif [ $APP = "pxc" ]; then
|
||||
ip="$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')"
|
||||
mysqld_check="$("$MYSQL_BASE_DIR/bin/mysqld" -V --bind-address $ip)"
|
||||
else
|
||||
echo "Invalid FORK=$APP" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$mysqld_check" ]; then
|
||||
echo "$MYSQL_BASE_DIR/bin/mysqld does not execute" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
##########################
|
||||
# Set required env vars. #
|
||||
##########################
|
||||
export PERCONA_TOOLKIT_BRANCH="$PWD"
|
||||
export PERCONA_TOOLKIT_SANDBOX="$MYSQL_BASE_DIR"
|
||||
export PATH="$PATH:/usr/sbin:/usr/local/bin:$MYSQL_BASE_DIR/bin"
|
||||
export LANG="en_US.UTF-8"
|
||||
export USER="${USER:-"jenkins"}"
|
||||
|
||||
# ######################################### #
|
||||
# Remove conf files that's shouldn't exist. #
|
||||
# ######################################### #
|
||||
rm -rf /tmp/pt-* || true
|
||||
rm -rf /tmp/pt_* || true
|
||||
rm -rf /tmp/percona* || true
|
||||
rm ~/.pt-*conf* || true
|
||||
rm ~/.my* || true
|
||||
|
||||
#############################
|
||||
# Check and start test env. #
|
||||
#############################
|
||||
sandbox/test-env checkconfig || exit 1
|
||||
sandbox/test-env stop || exit 1
|
||||
sandbox/test-env kill || exit 1
|
||||
if [ $APP = "mysql" ]; then
|
||||
sandbox/test-env start || exit 1
|
||||
elif [ $APP = "pxc" ]; then
|
||||
sandbox/test-env start cluster || exit 1
|
||||
else
|
||||
echo "Invalid FORK=$app" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#######################
|
||||
# Set debug env vars. #
|
||||
#######################
|
||||
if [ "$DEBUG_CODE" = "true" ]; then
|
||||
export PTDEBUG=1
|
||||
fi
|
||||
|
||||
if [ "$DEBUG_TEST" = "true" ]; then
|
||||
export PTDEVDEBUG=1
|
||||
fi
|
||||
|
||||
##################
|
||||
# Run the tests. #
|
||||
##################
|
||||
EXIT_STATUS=0
|
||||
TEST_CMD="${TEST_CMD:-"prove -r t/"}"
|
||||
|
||||
(
|
||||
eval $TEST_CMD
|
||||
)
|
||||
EXIT_STATUS=$(($? | 0))
|
||||
|
||||
#############
|
||||
# Clean up. #
|
||||
#############
|
||||
sandbox/test-env stop
|
||||
|
||||
exit $EXIT_STATUS
|
||||
@@ -6,10 +6,10 @@ SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
|
||||
SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
|
||||
SET @@GLOBAL.GTID_MODE = ON;
|
||||
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=12345, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan1';
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=12345, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'sourcechan1';
|
||||
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=12346, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan2';
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=12346, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'sourcechan2';
|
||||
|
||||
START SLAVE for channel 'masterchan1';
|
||||
START SLAVE for channel 'masterchan2';
|
||||
START SLAVE for channel 'sourcechan1';
|
||||
START SLAVE for channel 'sourcechan2';
|
||||
|
||||
41
sandbox/servers/8.4/my.sandbox.cnf
Normal file
41
sandbox/servers/8.4/my.sandbox.cnf
Normal file
@@ -0,0 +1,41 @@
|
||||
[client]
|
||||
user = msandbox
|
||||
password = msandbox
|
||||
port = PORT
|
||||
socket = /tmp/PORT/mysql_sandboxPORT.sock
|
||||
|
||||
[mysqld]
|
||||
port = PORT
|
||||
socket = /tmp/PORT/mysql_sandboxPORT.sock
|
||||
pid-file = /tmp/PORT/data/mysql_sandboxPORT.pid
|
||||
basedir = PERCONA_TOOLKIT_SANDBOX
|
||||
datadir = /tmp/PORT/data
|
||||
general_log
|
||||
general_log_file = genlog
|
||||
innodb_buffer_pool_size = 16M
|
||||
innodb_data_file_path = ibdata1:10M:autoextend
|
||||
innodb_data_home_dir = /tmp/PORT/data
|
||||
innodb_lock_wait_timeout = 3
|
||||
innodb_log_file_size = 5M
|
||||
innodb_log_group_home_dir = /tmp/PORT/data
|
||||
key_buffer_size = 5M
|
||||
local-infile = 1
|
||||
log-bin = mysql-bin
|
||||
log-error = /tmp/PORT/data/mysqld.log
|
||||
log_replica_updates
|
||||
lower_case_table_names = 0
|
||||
relay_log = mysql-relay-bin
|
||||
report-host = 127.0.0.1
|
||||
report-port = PORT
|
||||
server-id = PORT
|
||||
slow-query-log = 1
|
||||
slow-query-log-file = /tmp/PORT/data/slow.log
|
||||
log_slow_admin_statements = 1
|
||||
long_query_time = 0
|
||||
|
||||
# fkc test
|
||||
binlog_format = STATEMENT
|
||||
#performance_schema = ON
|
||||
#performance-schema-instrument='wait/lock/metadata/sql/mdl=ON'
|
||||
#performance-schema-instrument='transaction=ON'
|
||||
secure-file-priv =
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -d "$HOME/mysql-bin" ]; then
|
||||
echo "$HOME/mysql-bin does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VER=$1
|
||||
if [ "$VER" ]; then
|
||||
if [ "$VER" != "4.1" -a "$VER" != "5.0" -a "$VER" != "5.1" -a "$VER" != "5.5" -a "$VER" != "5.6" ]; then
|
||||
echo "VERSION must be 4.1, 5.0, 5.1, 5.5, or 5.6. Or, do not specify a version to select all available versions." >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
VER='';
|
||||
fi
|
||||
|
||||
select choice in $(ls -d $HOME/mysql-bin/mysql-$VER* | sort -r); do
|
||||
echo "export PERCONA_TOOLKIT_SANDBOX=$choice"
|
||||
break
|
||||
done
|
||||
|
||||
exit
|
||||
@@ -1,15 +0,0 @@
|
||||
STOP SLAVE FOR CHANNEL '';
|
||||
SET GLOBAL master_info_repository = 'TABLE';
|
||||
SET @@GLOBAL.relay_log_info_repository = 'TABLE';
|
||||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=ON;
|
||||
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
|
||||
SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
|
||||
SET @@GLOBAL.GTID_MODE = ON;
|
||||
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=2900, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan1';
|
||||
|
||||
CHANGE MASTER TO master_host='127.0.0.1', master_port=2901, master_user='msandbox', master_password='msandbox', master_auto_position=1 FOR CHANNEL 'masterchan2';
|
||||
|
||||
START SLAVE for channel 'masterchan1';
|
||||
START SLAVE for channel 'masterchan2';
|
||||
|
||||
@@ -62,13 +62,13 @@ make_sandbox() {
|
||||
local cluster_address="gcomm://"
|
||||
local listen_port=$(($port + 10))
|
||||
local receive_port=$(($port + 20))
|
||||
if [ -n "${master_port}" ]; then
|
||||
local master_listen_port=$(($master_port + 10))
|
||||
cluster_address="gcomm://$ip:$master_listen_port"
|
||||
if [ -n "${source_port}" ]; then
|
||||
local source_listen_port=$(($source_port + 10))
|
||||
cluster_address="gcomm://$ip:$source_listen_port"
|
||||
|
||||
local this_listen_port=$(($port + 10))
|
||||
local this_cluster_address="gcomm://$ip:$this_listen_port"
|
||||
sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "${TMP_DIR}/$master_port/my.sandbox.cnf"
|
||||
sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "${TMP_DIR}/$source_port/my.sandbox.cnf"
|
||||
fi
|
||||
|
||||
sed -e "s/ADDR/$ip/g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
|
||||
@@ -91,8 +91,8 @@ make_sandbox() {
|
||||
if [ -n "$BINLOG_FORMAT" ]; then
|
||||
echo "binlog-format=$BINLOG_FORMAT" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
if [ -n "$SLAVE_EXEC_MODE" ]; then
|
||||
echo "slave_exec_mode=$SLAVE_EXEC_MODE" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
if [ -n "$REPLICA_EXEC_MODE" ]; then
|
||||
echo "${REPLICA_NAME}_exec_mode=$REPLICA_EXEC_MODE" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
if [ -n "$SQL_MODE" ]; then
|
||||
echo "sql-mode=$SQL_MODE" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
@@ -131,7 +131,7 @@ make_sandbox() {
|
||||
echo "enforce_gtid_consistency" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
if [ -n "$REPLICATION_THREADS" ]; then
|
||||
echo "slave_parallel_workers=$REPLICATION_THREADS" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
echo "${REPLICA_NAME}_parallel_workers=$REPLICATION_THREADS" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
if [ -n "$EXTRA_DEFAULTS_FILE" ]; then
|
||||
@@ -139,8 +139,8 @@ make_sandbox() {
|
||||
fi
|
||||
|
||||
if [ $generating_database -eq 0 ]; then
|
||||
# If the sandbox is a slave, set it read_only.
|
||||
if [ "$type" = "slave" ]; then
|
||||
# If the sandbox is a replica, set it read_only.
|
||||
if [ "$type" = "replica" ]; then
|
||||
echo "read_only" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
fi
|
||||
@@ -180,7 +180,7 @@ make_sandbox() {
|
||||
echo "FLUSH PRIVILEGES;" >> $init_file
|
||||
fi
|
||||
|
||||
if [ "$type" = "slave" ]; then
|
||||
if [ "$type" = "replica" ]; then
|
||||
echo "FLUSH TABLES WITH READ LOCK;" >> $init_file
|
||||
echo "SET GLOBAL read_only = ON;" >> $init_file
|
||||
echo "UNLOCK TABLES;" >> $init_file
|
||||
@@ -224,11 +224,10 @@ make_sandbox() {
|
||||
mysql_upgrade_on ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
# If the sandbox is a slave, start the slave.
|
||||
if [ "$type" = "slave" ]; then
|
||||
#${TMP_DIR}/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
|
||||
${TMP_DIR}/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
|
||||
${TMP_DIR}/$port/use -e "start slave"
|
||||
# If the sandbox is a replica, start the replica.
|
||||
if [ "$type" = "replica" ]; then
|
||||
${TMP_DIR}/$port/use -e "change ${CHANGE_SOURCE_NAME} to ${SOURCE_NAME}_host='127.0.0.1', ${SOURCE_NAME}_user='msandbox', ${SOURCE_NAME}_password='msandbox', ${SOURCE_NAME}_port=$source_port, ${SOURCE_NAME}_SSL=1"
|
||||
${TMP_DIR}/$port/use -e "start ${REPLICA_NAME}"
|
||||
fi
|
||||
|
||||
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin" ]; then
|
||||
@@ -248,31 +247,31 @@ make_sandbox() {
|
||||
# Sanity check the cmd line options.
|
||||
# ###########################################################################
|
||||
if [ $# -lt 2 ]; then
|
||||
die "Usage: start-sandbox master|slave|master-master port [master port]"
|
||||
die "Usage: start-sandbox source|replica|source-source port [source port]"
|
||||
fi
|
||||
|
||||
type=$1 # master, slave or master-master
|
||||
type=$1 # source, replica or source-source
|
||||
port=$2 # sandbox port number, e.g. 12345
|
||||
master_port=$3 # master port if slave or master-master
|
||||
source_port=$3 # source port if replica or source-source
|
||||
enable_tokudb=''
|
||||
|
||||
|
||||
if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ] && [ "$type" != "cluster" ] && [ "$type" != "channels" ]; then
|
||||
die "Invalid sandbox type: $type. Valid types are master, slave, master-master, cluster, and channels."
|
||||
if [ "$type" != "source" ] && [ "$type" != "replica" ] && [ "$type" != "source-source" ] && [ "$type" != "cluster" ] && [ "$type" != "channels" ]; then
|
||||
die "Invalid sandbox type: $type. Valid types are source, replica, source-source, cluster, and channels."
|
||||
fi
|
||||
|
||||
if [ $port -le 1024 ]; then
|
||||
die "Invalid port: $port. Ports must be > 1024."
|
||||
fi
|
||||
|
||||
if [ "$type" = "slave" -o "$type" = "master-master" ] && [ -z "$master_port" ]; then
|
||||
die "No master port given for the $type."
|
||||
if [ "$type" = "replica" -o "$type" = "source-source" ] && [ -z "$source_port" ]; then
|
||||
die "No source port given for the $type."
|
||||
fi
|
||||
|
||||
# If creating a slave, the master must exist first. Not true for creating
|
||||
# a master-master though.
|
||||
if [ "$type" = "slave" ] && [ ! -d "${TMP_DIR}/$master_port" ]; then
|
||||
die "Master sandbox does not exist: ${TMP_DIR}/$master_port"
|
||||
# If creating a replica, the source must exist first. Not true for creating
|
||||
# a source-source though.
|
||||
if [ "$type" = "replica" ] && [ ! -d "${TMP_DIR}/$source_port" ]; then
|
||||
die "Source sandbox does not exist: ${TMP_DIR}/$source_port"
|
||||
fi
|
||||
|
||||
# ###########################################################################
|
||||
@@ -340,23 +339,23 @@ if [ -f $PIDFILE ]; then
|
||||
echo "Sandbox $port already started (found pid file $PIDFILE)"
|
||||
else
|
||||
make_sandbox
|
||||
# make_sandbox has started slave and set read_only if necessary.
|
||||
# make_sandbox has started replica and set read_only if necessary.
|
||||
|
||||
# If the sandbox is a master-master, start the second master and slave the
|
||||
# If the sandbox is a source-source, start the second source and replica the
|
||||
# two together.
|
||||
if [ "$type" = "master-master" ]; then
|
||||
if [ "$type" = "source-source" ]; then
|
||||
mm1_port=$port
|
||||
mm2_port=$master_port
|
||||
port=$master_port # make_sandbox uses $port
|
||||
mm2_port=$source_port
|
||||
port=$source_port # make_sandbox uses $port
|
||||
make_sandbox
|
||||
|
||||
# Slave mm2 -> mm1
|
||||
${TMP_DIR}/$mm2_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_user='msandbox', master_password='msandbox', master_port=$mm1_port"
|
||||
${TMP_DIR}/$mm2_port/use -e "start slave"
|
||||
# Replica mm2 -> mm1
|
||||
${TMP_DIR}/$mm2_port/use -e "change ${CHANGE_SOURCE_NAME} to ${SOURCE_NAME}_host='127.0.0.1', ${SOURCE_NAME}_log_file='mysql-bin.000001', ${SOURCE_NAME}_user='msandbox', ${SOURCE_NAME}_password='msandbox', ${SOURCE_NAME}_port=$mm1_port, ${SOURCE_NAME}_SSL=1"
|
||||
${TMP_DIR}/$mm2_port/use -e "start ${REPLICA_NAME}"
|
||||
|
||||
# Slave mm1 -> mm2
|
||||
${TMP_DIR}/$mm1_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_user='msandbox', master_password='msandbox', master_port=$mm2_port"
|
||||
${TMP_DIR}/$mm1_port/use -e "start slave"
|
||||
# Replica mm1 -> mm2
|
||||
${TMP_DIR}/$mm1_port/use -e "change ${CHANGE_SOURCE_NAME} to ${SOURCE_NAME}_host='127.0.0.1', ${SOURCE_NAME}_log_file='mysql-bin.000001', ${SOURCE_NAME}_user='msandbox', ${SOURCE_NAME}_password='msandbox', ${SOURCE_NAME}_port=$mm2_port, ${SOURCE_NAME}_SSL=1"
|
||||
${TMP_DIR}/$mm1_port/use -e "start ${REPLICA_NAME}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
TMP_DIR=${TMP_DIR:-/tmp}
|
||||
|
||||
# This script controls the Percona Toolkit test environment. The basic
|
||||
# environment is a master on port 12345 in ${TMP_DIR}/12345 and a slave on port
|
||||
# environment is a source on port 12345 in ${TMP_DIR}/12345 and a replica on port
|
||||
# 12346 in ${TMP_DIR}/12346. This script attempts to ensure that all environment
|
||||
# vars like PERCONA_TOOLKIT_BRANCH and PERCONA_TOOLKIT_SANDBOX are correct.
|
||||
# Exist 0 on success/no errors, or 1 on any warnings or errors.
|
||||
@@ -115,7 +115,7 @@ checkconfig() {
|
||||
sandbox_status() {
|
||||
local type=$1
|
||||
local port=$2
|
||||
local master_port=$3
|
||||
local source_port=$3
|
||||
local status=0 # sandbox is ok, no problems
|
||||
|
||||
echo "MySQL $type test server on port $port:"
|
||||
@@ -160,23 +160,23 @@ sandbox_status() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$type" = "slave" ]; then
|
||||
echo -n " slave is running - "
|
||||
# Slave status should show:
|
||||
# Slave_IO_Running: Yes
|
||||
# Slave_SQL_Running: Yes
|
||||
local slave_running=`${TMP_DIR}/$port/use -e 'show slave status\G' 2>/dev/null | grep Running | grep -c Yes`
|
||||
if [ $slave_running -eq 2 ]; then
|
||||
if [ "$type" = "replica" ]; then
|
||||
echo -n " replica is running - "
|
||||
# Replica status should show:
|
||||
# Replica_IO_Running: Yes
|
||||
# Replica_SQL_Running: Yes
|
||||
local replica_running=`${TMP_DIR}/$port/use -e "show ${REPLICA_NAME} status\G" 2>/dev/null | grep Running | grep -c Yes`
|
||||
if [ $replica_running -eq 2 ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "NO"
|
||||
status=1
|
||||
fi
|
||||
|
||||
if [ -n "$master_port" ]; then
|
||||
echo -n " slave to master $master_port - "
|
||||
local mp=`${TMP_DIR}/$port/use -e 'show slave status\G' 2>/dev/null | grep Master_Port | awk '{print $2}'`
|
||||
if [ "$mp" = "$master_port" ]; then
|
||||
if [ -n "$source_port" ]; then
|
||||
echo -n " replica to source $source_port - "
|
||||
local mp=`${TMP_DIR}/$port/use -e "show ${REPLICA_NAME} status\G" 2>/dev/null | grep ${SOURCE_NAME^}_Port | awk '{print $2}'`
|
||||
if [ "$mp" = "$source_port" ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "NO"
|
||||
@@ -248,6 +248,20 @@ set_mysql_version() {
|
||||
fi
|
||||
}
|
||||
|
||||
SOURCE_NAME="master"
|
||||
CHANGE_SOURCE_NAME="master"
|
||||
REPLICA_NAME="slave"
|
||||
set_source_replica_names() {
|
||||
if [ "$MYSQL_VERSION" '>' "8.1" ] && [ "$APP" '!=' "mariadb" ]; then
|
||||
SOURCE_NAME="source"
|
||||
CHANGE_SOURCE_NAME="replication source"
|
||||
REPLICA_NAME="replica"
|
||||
fi
|
||||
export SOURCE_NAME
|
||||
export CHANGE_SOURCE_NAME
|
||||
export REPLICA_NAME
|
||||
}
|
||||
|
||||
_seq() {
|
||||
local i="$1"
|
||||
awk "BEGIN { for(i=1; i<=$i; i++) print i; }"
|
||||
@@ -295,26 +309,36 @@ fi
|
||||
case $opt in
|
||||
start)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
echo "${2:-"master"}" 12345
|
||||
./start-sandbox "${2:-"master"}" 12345
|
||||
echo "${2:-"source"}" 12345
|
||||
./start-sandbox "${2:-"source"}" 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
set_mysql_version
|
||||
set_source_replica_names
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
if [ "${2:-""}" = "channels" ] && [ "$MYSQL_VERSION" '>' "5.6" ]; then
|
||||
./start-sandbox master 12346
|
||||
./start-sandbox source 12346
|
||||
exit_status=$((exit_status | $?))
|
||||
./start-sandbox master 12347
|
||||
./start-sandbox source 12347
|
||||
exit_status=$((exit_status | $?))
|
||||
${TMP_DIR}/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/slave_channels.sql
|
||||
exit_status=$?
|
||||
if [ "$MYSQL_VERSION" '>' "8.1" ] && [ "$APP" '!=' "mariadb" ]; then
|
||||
${TMP_DIR}/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/replica_channels.sql
|
||||
exit_status=$?
|
||||
else
|
||||
${TMP_DIR}/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on-legacy.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on-legacy.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/replica_channels-legacy.sql
|
||||
exit_status=$?
|
||||
fi
|
||||
else
|
||||
./start-sandbox "${2:-"slave"}" 12346 12345
|
||||
./start-sandbox "${2:-"replica"}" 12346 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
./start-sandbox "${2:-"slave"}" 12347 12346
|
||||
./start-sandbox "${2:-"replica"}" 12347 12346
|
||||
exit_status=$((exit_status | $?))
|
||||
fi
|
||||
|
||||
@@ -407,12 +431,12 @@ case $opt in
|
||||
$0 start "$@"
|
||||
;;
|
||||
status)
|
||||
sandbox_status 'master' '12345'
|
||||
master_status=$?
|
||||
sandbox_status 'slave' '12346' '12345'
|
||||
slave_status=$?
|
||||
sandbox_status 'source' '12345'
|
||||
source_status=$?
|
||||
sandbox_status 'replica' '12346' '12345'
|
||||
replica_status=$?
|
||||
echo -n "Percona Test test environment is "
|
||||
if [ $master_status -eq 0 ] && [ $slave_status -eq 0 ]; then
|
||||
if [ $source_status -eq 0 ] && [ $replica_status -eq 0 ]; then
|
||||
echo "ok!"
|
||||
else
|
||||
echo "invalid."
|
||||
|
||||
@@ -839,7 +839,7 @@ SKIP: {
|
||||
# After stopping one of the replication channels, show slave status returns only one slave
|
||||
# but it has a channel name and we didn't specified a channels name in the command line.
|
||||
# It should return undef
|
||||
$slave1_dbh->do("STOP SLAVE for channel 'masterchan2'");
|
||||
$slave1_dbh->do("STOP SLAVE for channel 'sourcechan2'");
|
||||
|
||||
eval {
|
||||
$css = $ms->get_slave_status($slave1_dbh);
|
||||
@@ -850,14 +850,14 @@ SKIP: {
|
||||
'Cannot determine slave in a multi source config without --channel param (only one server)'
|
||||
);
|
||||
|
||||
$slave1_dbh->do("START SLAVE for channel 'masterchan2'");
|
||||
$slave1_dbh->do("START SLAVE for channel 'sourcechan2'");
|
||||
|
||||
# Now try specifying a channel name
|
||||
$ms->{channel} = 'masterchan1';
|
||||
$ms->{channel} = 'sourcechan1';
|
||||
$css = $ms->get_slave_status($slave1_dbh);
|
||||
is (
|
||||
$css->{channel_name},
|
||||
'masterchan1',
|
||||
'sourcechan1',
|
||||
'Returned the correct slave',
|
||||
);
|
||||
|
||||
|
||||
@@ -91,10 +91,10 @@ like (
|
||||
'Message saying channel name must be specified'
|
||||
);
|
||||
|
||||
push @args, ('--channel', 'masterchan1');
|
||||
push @args, ('--channel', 'sourcechan1');
|
||||
|
||||
output(
|
||||
sub { $exit_status = pt_archiver::main(@args, '--channel', 'masterchan1') },
|
||||
sub { $exit_status = pt_archiver::main(@args, '--channel', 'sourcechan1') },
|
||||
stderr => 1,
|
||||
);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ $sb->load_file('chan_master1', "sandbox/gtid_on.sql", undef, no_wait => 1);
|
||||
$sb->load_file('chan_master2', "sandbox/gtid_on.sql", undef, no_wait => 1);
|
||||
$sb->load_file('chan_slave1', "sandbox/slave_channels.sql", undef, no_wait => 1);
|
||||
|
||||
my @args = qw(--execute --no-foreign-key-checks --verbose --databases=sakila --tables=actor --sync-to-master --channel=masterchan1);
|
||||
my @args = qw(--execute --no-foreign-key-checks --verbose --databases=sakila --tables=actor --sync-to-master --channel=sourcechan1);
|
||||
my $exit_status;
|
||||
|
||||
my $output = output(
|
||||
|
||||
Reference in New Issue
Block a user