mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
Merge branch '3.0' into PT-214
This commit is contained in:
@@ -83,6 +83,11 @@ cd ${HOME}/perldev/percona-toolkit
|
|||||||
sandbox/test-env start
|
sandbox/test-env start
|
||||||
```
|
```
|
||||||
To stop the MySQL sandbox: `sandbox/test-env stop`
|
To stop the MySQL sandbox: `sandbox/test-env stop`
|
||||||
|
To enable TokuDB (only available in Percona Server 5.7+), run:
|
||||||
|
|
||||||
|
```
|
||||||
|
ENABLE_TOKUDB=1 sandbox/test-env start
|
||||||
|
```
|
||||||
|
|
||||||
### Running tests
|
### Running tests
|
||||||
```
|
```
|
||||||
|
|||||||
+187
-182
@@ -10,218 +10,223 @@
|
|||||||
# server might have been in.
|
# server might have been in.
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo $1 >&2
|
echo $1 >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_sandbox() {
|
debug_sandbox() {
|
||||||
set -x
|
set -x
|
||||||
local port="$1"
|
local port="$1"
|
||||||
ps x | grep mysql >&2
|
ps x | grep mysql >&2
|
||||||
if [ -d "/tmp/$port" ]; then
|
if [ -d "/tmp/$port" ]; then
|
||||||
ls -lh /tmp/$port/* >&2
|
ls -lh /tmp/$port/* >&2
|
||||||
cat /tmp/$port/data/mysqld.log >&2
|
cat /tmp/$port/data/mysqld.log >&2
|
||||||
tail -n 100 /tmp/$port/data/genlog >&2
|
tail -n 100 /tmp/$port/data/genlog >&2
|
||||||
else
|
else
|
||||||
echo "/tmp/$port does not exist" >&2
|
echo "/tmp/$port does not exist" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_upgrade_on() {
|
mysql_upgrade_on() {
|
||||||
local cnf_file="$1"
|
local cnf_file="$1"
|
||||||
local upgrade="$PERCONA_TOOLKIT_SANDBOX/bin/mysql_upgrade"
|
local upgrade="$PERCONA_TOOLKIT_SANDBOX/bin/mysql_upgrade"
|
||||||
|
|
||||||
$upgrade --defaults-file=$cnf_file --skip-write-binlog
|
$upgrade --defaults-file=$cnf_file --skip-write-binlog
|
||||||
}
|
}
|
||||||
|
|
||||||
make_sandbox() {
|
make_sandbox() {
|
||||||
# Make the sandbox dir and extract the base files.
|
# Make the sandbox dir and extract the base files.
|
||||||
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
|
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
|
||||||
mkdir /tmp/$port || die "Failed to mkdir /tmp/$port"
|
mkdir /tmp/$port || die "Failed to mkdir /tmp/$port"
|
||||||
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/my.sandbox.cnf /tmp/$port
|
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/my.sandbox.cnf /tmp/$port
|
||||||
if [ -e $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz ]; then
|
if [ -e $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz ]; then
|
||||||
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C /tmp/$port
|
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C /tmp/$port
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
|
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
|
||||||
if [ -f $script ]; then
|
if [ -f $script ]; then
|
||||||
cp $script /tmp/$port
|
cp $script /tmp/$port
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${type}" = "cluster" ]; then
|
if [ "${type}" = "cluster" ]; then
|
||||||
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/pxc/$version/my.sandbox.cnf /tmp/$port
|
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/pxc/$version/my.sandbox.cnf /tmp/$port
|
||||||
|
|
||||||
local libgalera="$PERCONA_TOOLKIT_SANDBOX/lib/libgalera_smm.so"
|
local libgalera="$PERCONA_TOOLKIT_SANDBOX/lib/libgalera_smm.so"
|
||||||
local cluster_name="${CLUSTER_NAME:-"pt_sandbox_cluster"}"
|
local cluster_name="${CLUSTER_NAME:-"pt_sandbox_cluster"}"
|
||||||
local cluster_address="gcomm://"
|
local cluster_address="gcomm://"
|
||||||
local listen_port=$(($port + 10))
|
local listen_port=$(($port + 10))
|
||||||
local receive_port=$(($port + 20))
|
local receive_port=$(($port + 20))
|
||||||
if [ -n "${master_port}" ]; then
|
if [ -n "${master_port}" ]; then
|
||||||
local master_listen_port=$(($master_port + 10))
|
local master_listen_port=$(($master_port + 10))
|
||||||
cluster_address="gcomm://$ip:$master_listen_port"
|
cluster_address="gcomm://$ip:$master_listen_port"
|
||||||
|
|
||||||
local this_listen_port=$(($port + 10))
|
local this_listen_port=$(($port + 10))
|
||||||
local this_cluster_address="gcomm://$ip:$this_listen_port"
|
local this_cluster_address="gcomm://$ip:$this_listen_port"
|
||||||
sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "/tmp/$master_port/my.sandbox.cnf"
|
sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "/tmp/$master_port/my.sandbox.cnf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -e "s/ADDR/$ip/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
sed -e "s/ADDR/$ip/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||||
sed -e "s!CLUSTER_AD!$cluster_address!g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
sed -e "s!CLUSTER_AD!$cluster_address!g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||||
sed -e "s/CLUSTER_NAME/$cluster_name/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
sed -e "s/CLUSTER_NAME/$cluster_name/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||||
sed -e "s/RECEIVE_PRT/$receive_port/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
sed -e "s/RECEIVE_PRT/$receive_port/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||||
sed -e "s/LISTEN_PRT/$listen_port/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
sed -e "s/LISTEN_PRT/$listen_port/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||||
sed -e "s!LIBGALERA!$libgalera!g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
sed -e "s!LIBGALERA!$libgalera!g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for file in `grep -l PORT /tmp/$port/* 2>/dev/null`; do
|
for file in `grep -l PORT /tmp/$port/* 2>/dev/null`; do
|
||||||
sed -e "s/PORT/$port/g" -i.bak $file
|
sed -e "s/PORT/$port/g" -i.bak $file
|
||||||
# Use ! instead of / because the replacment has / (it's a directory)
|
# Use ! instead of / because the replacment has / (it's a directory)
|
||||||
sed -e "s!PERCONA_TOOLKIT_SANDBOX!$PERCONA_TOOLKIT_SANDBOX!g" -i.bak $file
|
sed -e "s!PERCONA_TOOLKIT_SANDBOX!$PERCONA_TOOLKIT_SANDBOX!g" -i.bak $file
|
||||||
sed -e "s!MYSQLD!$mysqld!g" -i.bak $file
|
sed -e "s!MYSQLD!$mysqld!g" -i.bak $file
|
||||||
done
|
done
|
||||||
rm /tmp/$port/*.bak >/dev/null 2>&1
|
rm /tmp/$port/*.bak >/dev/null 2>&1
|
||||||
|
|
||||||
if [ -n "$BINLOG_FORMAT" ]; then
|
if [ -n "$BINLOG_FORMAT" ]; then
|
||||||
echo "binlog-format=$BINLOG_FORMAT" >> /tmp/$port/my.sandbox.cnf
|
echo "binlog-format=$BINLOG_FORMAT" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$SLAVE_EXEC_MODE" ]; then
|
if [ -n "$SLAVE_EXEC_MODE" ]; then
|
||||||
echo "slave_exec_mode=$SLAVE_EXEC_MODE" >> /tmp/$port/my.sandbox.cnf
|
echo "slave_exec_mode=$SLAVE_EXEC_MODE" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$SQL_MODE" ]; then
|
if [ -n "$SQL_MODE" ]; then
|
||||||
echo "sql-mode=$SQL_MODE" >> /tmp/$port/my.sandbox.cnf
|
echo "sql-mode=$SQL_MODE" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$GENLOG" ]; then
|
if [ -n "$GENLOG" ]; then
|
||||||
echo "log=genlog" >> /tmp/$port/my.sandbox.cnf
|
echo "log=genlog" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$SKIP_INNODB" ]; then
|
if [ -n "$SKIP_INNODB" ]; then
|
||||||
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
|
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
|
||||||
echo "default-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
echo "default-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
||||||
if [ "$version" ">" "5.5" ]; then
|
if [ "$version" ">" "5.5" ]; then
|
||||||
echo "default-tmp-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
echo "default-tmp-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$MODE_ANSI" ]; then
|
if [ -n "$MODE_ANSI" ]; then
|
||||||
echo "sql_mode=ansi" >> /tmp/$port/my.sandbox.cnf
|
echo "sql_mode=ansi" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
|
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
|
||||||
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf
|
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$LOCAL_INFILE" ]; then
|
if [ -n "$LOCAL_INFILE" ]; then
|
||||||
echo "local-infile=$LOCAL_INFILE" >> /tmp/$port/my.sandbox.cnf
|
echo "local-infile=$LOCAL_INFILE" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$QUERY_CACHE_SIZE" ]; then
|
if [ -n "$QUERY_CACHE_SIZE" ]; then
|
||||||
echo "query_cache_type=1" >> /tmp/$port/my.sandbox.cnf
|
echo "query_cache_type=1" >> /tmp/$port/my.sandbox.cnf
|
||||||
echo "query_cache_size=$QUERY_CACHE_SIZE" >> /tmp/$port/my.sandbox.cnf
|
echo "query_cache_size=$QUERY_CACHE_SIZE" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$GTID" ]; then
|
if [ -n "$GTID" ]; then
|
||||||
echo "gtid_mode=on" >> /tmp/$port/my.sandbox.cnf
|
echo "gtid_mode=on" >> /tmp/$port/my.sandbox.cnf
|
||||||
echo "enforce_gtid_consistency" >> /tmp/$port/my.sandbox.cnf
|
echo "enforce_gtid_consistency" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
if [ -n "$REPLICATION_THREADS" ]; then
|
if [ -n "$REPLICATION_THREADS" ]; then
|
||||||
echo "slave_parallel_workers=$REPLICATION_THREADS" >> /tmp/$port/my.sandbox.cnf
|
echo "slave_parallel_workers=$REPLICATION_THREADS" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$EXTRA_DEFAULTS_FILE" ]; then
|
if [ -n "$EXTRA_DEFAULTS_FILE" ]; then
|
||||||
cat "$EXTRA_DEFAULTS_FILE" >> /tmp/$port/my.sandbox.cnf
|
cat "$EXTRA_DEFAULTS_FILE" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the sandbox is a slave, set it read_only.
|
# If the sandbox is a slave, set it read_only.
|
||||||
if [ "$type" = "slave" ]; then
|
if [ "$type" = "slave" ]; then
|
||||||
echo "read_only" >> /tmp/$port/my.sandbox.cnf
|
echo "read_only" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the sandbox and check that it has InnoDB.
|
# Start the sandbox and check that it has InnoDB.
|
||||||
/tmp/$port/start
|
/tmp/$port/start
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
if [ -z "$SKIP_INNODB" ]; then
|
if [ -z "$SKIP_INNODB" ]; then
|
||||||
/tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1
|
/tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1
|
||||||
# grep exits 0 if lines are found
|
# grep exits 0 if lines are found
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Sandbox $type $port doesn't have InnoDB." >&2
|
echo "Sandbox $type $port doesn't have InnoDB." >&2
|
||||||
debug_sandbox $port
|
debug_sandbox $port
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for sql in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/"*.sql; do
|
for sql in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/"*.sql; do
|
||||||
[ -f "$sql" ] && /tmp/$port/use < $sql
|
[ -f "$sql" ] && /tmp/$port/use < $sql
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create sys schema (if exists and is desired)
|
# create sys schema (if exists and is desired)
|
||||||
if [ -n "$SYS_SCHEMA" ]; then
|
if [ -n "$SYS_SCHEMA" ]; then
|
||||||
local sys_dir="$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/sys"
|
local sys_dir="$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/sys"
|
||||||
cd "$sys_dir"
|
cd "$sys_dir"
|
||||||
[ -f "$sys_dir/sys.sql" ] && /tmp/$port/use < "$sys_dir/sys.sql"
|
[ -f "$sys_dir/sys.sql" ] && /tmp/$port/use < "$sys_dir/sys.sql"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Sandbox $type $port failed to start." >&2
|
echo "Sandbox $type $port failed to start." >&2
|
||||||
debug_sandbox $port
|
debug_sandbox $port
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/tmp/$port/use -e "CREATE DATABASE IF NOT EXISTS percona_test";
|
/tmp/$port/use -e "CREATE DATABASE IF NOT EXISTS percona_test";
|
||||||
/tmp/$port/use -e "CREATE TABLE IF NOT EXISTS percona_test.sentinel (id INT PRIMARY KEY, ping VARCHAR(64) NOT NULL DEFAULT '')";
|
/tmp/$port/use -e "CREATE TABLE IF NOT EXISTS percona_test.sentinel (id INT PRIMARY KEY, ping VARCHAR(64) NOT NULL DEFAULT '')";
|
||||||
|
|
||||||
if [ -n "${MYSQL_UPGRADE:-""}" ]; then
|
if [ -n "${MYSQL_UPGRADE:-""}" ]; then
|
||||||
mysql_upgrade_on /tmp/$port/my.sandbox.cnf
|
mysql_upgrade_on /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the sandbox is a slave, start the slave.
|
# If the sandbox is a slave, start the slave.
|
||||||
if [ "$type" = "slave" ]; then
|
if [ "$type" = "slave" ]; then
|
||||||
/tmp/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
|
/tmp/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
|
||||||
/tmp/$port/use -e "start slave"
|
/tmp/$port/use -e "start slave"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin" ]; then
|
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin" ]; then
|
||||||
# try to enable RocksDB. Only available on Percona Server 5.7.19+
|
# try to enable RocksDB. Only available on Percona Server 5.7.19+
|
||||||
if [ "$version" ">" "5.6" ]; then
|
if [ "$version" > "5.6" ]; then
|
||||||
$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin --enable-rocksdb -u root -pmsandbox -h 127.1 -P $port
|
$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin --enable-rocksdb -u root -pmsandbox -h 127.1 -P $port
|
||||||
fi
|
if [ -n "$ENABLE_TOKUDB" ]; then
|
||||||
fi
|
sudo $PERCONA_TOOLKIT_SANDBOX/bin/ps-admin --enable-tokudb -u root -pmsandbox -h 127.1 -P $port
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Sanity check the cmd line options.
|
# Sanity check the cmd line options.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
die "Usage: start-sandbox master|slave|master-master port [master port]"
|
die "Usage: start-sandbox master|slave|master-master port [master port]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
type=$1 # master, slave or master-master
|
type=$1 # master, slave or master-master
|
||||||
port=$2 # sandbox port number, e.g. 12345
|
port=$2 # sandbox port number, e.g. 12345
|
||||||
master_port=$3 # master port if slave or master-master
|
master_port=$3 # master port if slave or master-master
|
||||||
|
enable_tokudb=''
|
||||||
|
|
||||||
|
|
||||||
if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ] && [ "$type" != "cluster" ] && [ "$type" != "channels" ]; then
|
if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ] && [ "$type" != "cluster" ] && [ "$type" != "channels" ]; then
|
||||||
die "Invalid sandbox type: $type. Valid types are master, slave, and master-master."
|
die "Invalid sandbox type: $type. Valid types are master, slave, and master-master."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $port -le 1024 ]; then
|
if [ $port -le 1024 ]; then
|
||||||
die "Invalid port: $port. Ports must be > 1024."
|
die "Invalid port: $port. Ports must be > 1024."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$type" = "slave" -o "$type" = "master-master" ] && [ -z "$master_port" ]; then
|
if [ "$type" = "slave" -o "$type" = "master-master" ] && [ -z "$master_port" ]; then
|
||||||
die "No master port given for the $type."
|
die "No master port given for the $type."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If creating a slave, the master must exist first. Not true for creating
|
# If creating a slave, the master must exist first. Not true for creating
|
||||||
# a master-master though.
|
# a master-master though.
|
||||||
if [ "$type" = "slave" ] && [ ! -d "/tmp/$master_port" ]; then
|
if [ "$type" = "slave" ] && [ ! -d "/tmp/$master_port" ]; then
|
||||||
die "Master sandbox does not exist: /tmp/$master_port"
|
die "Master sandbox does not exist: /tmp/$master_port"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Sanity check the environment.
|
# Sanity check the environment.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
if [ -z "$PERCONA_TOOLKIT_BRANCH" ]; then
|
if [ -z "$PERCONA_TOOLKIT_BRANCH" ]; then
|
||||||
die "PERCONA_TOOLKIT_BRANCH environment variable is not set."
|
die "PERCONA_TOOLKIT_BRANCH environment variable is not set."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
|
if [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
|
||||||
die "Invalid PERCONA_TOOLKIT_BRANCH directory: $PERCONA_TOOLKIT_BRANCH"
|
die "Invalid PERCONA_TOOLKIT_BRANCH directory: $PERCONA_TOOLKIT_BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||||
@@ -233,38 +238,38 @@ cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
|||||||
# MySQL executables like PERCONA_TOOLKIT_SANDBOX/bin/mysqld_safe.
|
# MySQL executables like PERCONA_TOOLKIT_SANDBOX/bin/mysqld_safe.
|
||||||
|
|
||||||
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
|
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
|
||||||
PERCONA_TOOLKIT_SANDBOX=`./test-env checkconfig | grep PERCONA_TOOLKIT_SANDBOX | cut -d= -f2 | awk '{print $1}'`
|
PERCONA_TOOLKIT_SANDBOX=`./test-env checkconfig | grep PERCONA_TOOLKIT_SANDBOX | cut -d= -f2 | awk '{print $1}'`
|
||||||
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
|
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
|
||||||
die "PERCONA_TOOLKIT_SANDBOX environment variable is not set."
|
die "PERCONA_TOOLKIT_SANDBOX environment variable is not set."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Get server version.
|
# Get server version.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" ]; then
|
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" ]; then
|
||||||
mysqld="bin/mysqld"
|
mysqld="bin/mysqld"
|
||||||
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then
|
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then
|
||||||
mysqld="sbin/mysqld"
|
mysqld="sbin/mysqld"
|
||||||
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then
|
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then
|
||||||
mysqld="libexec/mysqld"
|
mysqld="libexec/mysqld"
|
||||||
else
|
else
|
||||||
die "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec."
|
die "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP="${FORK:-"mysql"}"
|
APP="${FORK:-"mysql"}"
|
||||||
|
|
||||||
if [ $type = "cluster" -o $APP = "pxc" ]; then
|
if [ $type = "cluster" -o $APP = "pxc" ]; then
|
||||||
# disabled for now because used perl module is not available everywhere and in some distros it returns ipv6 address
|
# disabled for now because used perl module is not available everywhere and in some distros it returns ipv6 address
|
||||||
# ip=$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')
|
# ip=$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')
|
||||||
ip=$(hostname -i | cut -d" " -f2)
|
ip=$(hostname -i | cut -d" " -f2)
|
||||||
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V --query_cache_size=0 --query_cache_type=0 --bind-address $ip 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V --query_cache_size=0 --query_cache_type=0 --bind-address $ip 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
||||||
else
|
else
|
||||||
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then
|
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then
|
||||||
die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version does not exist."
|
die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version does not exist."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
@@ -273,27 +278,27 @@ fi
|
|||||||
PIDFILE="/tmp/$port/data/mysql_sandbox$port.pid"
|
PIDFILE="/tmp/$port/data/mysql_sandbox$port.pid"
|
||||||
|
|
||||||
if [ -f $PIDFILE ]; then
|
if [ -f $PIDFILE ]; then
|
||||||
echo "Sandbox $port already started (found pid file $PIDFILE)"
|
echo "Sandbox $port already started (found pid file $PIDFILE)"
|
||||||
else
|
else
|
||||||
make_sandbox
|
make_sandbox
|
||||||
# make_sandbox has started slave and set read_only if necessary.
|
# make_sandbox has started slave 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 master-master, start the second master and slave the
|
||||||
# two together.
|
# two together.
|
||||||
if [ "$type" = "master-master" ]; then
|
if [ "$type" = "master-master" ]; then
|
||||||
mm1_port=$port
|
mm1_port=$port
|
||||||
mm2_port=$master_port
|
mm2_port=$master_port
|
||||||
port=$master_port # make_sandbox uses $port
|
port=$master_port # make_sandbox uses $port
|
||||||
make_sandbox
|
make_sandbox
|
||||||
|
|
||||||
# Slave mm2 -> mm1
|
# Slave mm2 -> mm1
|
||||||
/tmp/$mm2_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm1_port"
|
/tmp/$mm2_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm1_port"
|
||||||
/tmp/$mm2_port/use -e "start slave"
|
/tmp/$mm2_port/use -e "start slave"
|
||||||
|
|
||||||
# Slave mm1 -> mm2
|
# Slave mm1 -> mm2
|
||||||
/tmp/$mm1_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm2_port"
|
/tmp/$mm1_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm2_port"
|
||||||
/tmp/$mm1_port/use -e "start slave"
|
/tmp/$mm1_port/use -e "start slave"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -267,6 +267,10 @@ opt=$1
|
|||||||
|
|
||||||
exit_status=0
|
exit_status=0
|
||||||
|
|
||||||
|
if [ -e ${PERCONA_TOOLKIT_SANDBOX}/lib/mysql/libjemalloc.so ]; then
|
||||||
|
export LD_PRELOAD=${PERCONA_TOOLKIT_SANDBOX}/lib/mysql/libjemalloc.so
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $opt = 'checkconfig' ]; then
|
if [ $opt = 'checkconfig' ]; then
|
||||||
checkconfig 1
|
checkconfig 1
|
||||||
echo -n "Percona Toolkit test environment config is "
|
echo -n "Percona Toolkit test environment config is "
|
||||||
|
|||||||
Reference in New Issue
Block a user