mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-02 02:34:19 +00:00
WIP
This commit is contained in:
38
sandbox/servers/8.0/my.sandbox.cnf
Normal file
38
sandbox/servers/8.0/my.sandbox.cnf
Normal file
@@ -0,0 +1,38 @@
|
||||
[client]
|
||||
user = msandbox
|
||||
password = msandbox
|
||||
port = PORT
|
||||
socket = /tmp/PORT/mysql_sandboxPORT.sock
|
||||
loose-local-infile=1
|
||||
|
||||
[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 = 16M
|
||||
local-infile = 1
|
||||
log-bin = mysql-bin
|
||||
log-error = /tmp/PORT/data/mysqld.log
|
||||
log_slave_updates
|
||||
lower_case_table_names = 0
|
||||
relay_log = mysql-relay-bin
|
||||
report-host = 127.0.0.1
|
||||
report-port = PORT
|
||||
server-id = PORT
|
||||
|
||||
# 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 =
|
@@ -20,6 +20,7 @@ sandbox_is_alive() {
|
||||
# only alive when it responds to queries.
|
||||
$BASEDIR/bin/mysqladmin --defaults-file="/tmp/PORT/my.sandbox.cnf" ping >/dev/null 2>&1
|
||||
[ $? -eq 0 ] || return 1
|
||||
echo "return 0"
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -49,9 +50,17 @@ echo -n "Starting MySQL test server on port PORT... "
|
||||
# Start MySQL.
|
||||
cwd=$PWD
|
||||
cd $BASEDIR
|
||||
$BASEDIR/MYSQLD --defaults-file=/tmp/PORT/my.sandbox.cnf > /dev/null 2>&1 &
|
||||
|
||||
init_file="/tmp/PORT/mysql-init"
|
||||
if [ -e $init_file ]; then
|
||||
$BASEDIR/MYSQLD --defaults-file=/tmp/PORT/my.sandbox.cnf -u root --init-file $init_file &
|
||||
else
|
||||
$BASEDIR/MYSQLD --defaults-file=/tmp/PORT/my.sandbox.cnf > /dev/null 2>&1 &
|
||||
fi
|
||||
cd $PWD
|
||||
|
||||
sleep 5
|
||||
|
||||
# Wait for MySQL to actually be up, i.e. to respond to queries.
|
||||
for i in $(_seq 60); do
|
||||
if sandbox_is_alive; then
|
||||
|
@@ -38,9 +38,13 @@ make_sandbox() {
|
||||
# Make the sandbox dir and extract the base files.
|
||||
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
|
||||
mkdir /tmp/$port || die "Failed to mkdir /tmp/$port"
|
||||
local generating_database=0
|
||||
|
||||
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
|
||||
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C /tmp/$port
|
||||
else
|
||||
generating_database=1
|
||||
fi
|
||||
|
||||
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
|
||||
@@ -127,9 +131,61 @@ make_sandbox() {
|
||||
cat "$EXTRA_DEFAULTS_FILE" >> /tmp/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
# If the sandbox is a slave, set it read_only.
|
||||
if [ "$type" = "slave" ]; then
|
||||
echo "read_only" >> /tmp/$port/my.sandbox.cnf
|
||||
if [ $generating_database -eq 0 ]; then
|
||||
# If the sandbox is a slave, set it read_only.
|
||||
if [ "$type" = "slave" ]; then
|
||||
echo "read_only" >> /tmp/$port/my.sandbox.cnf
|
||||
fi
|
||||
fi
|
||||
|
||||
#if [ ! -e $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz ]; then
|
||||
# if [ "$version" > "5.6" ]; then
|
||||
# rm -f /tmp/empty-defaults.txt
|
||||
# touch /tmp/empty-defaults.txt
|
||||
# rm -rf /tmp/$port/data
|
||||
# $PERCONA_TOOLKIT_SANDBOX/$mysqld --defaults-file=/tmp/${port}/my.sandbox.cnf --initialize
|
||||
# else
|
||||
# # MySQL up to 5.6 needs mysql_install_db
|
||||
# # Support for it is a TODO
|
||||
# echo "For MySQL < 5.7 data.tar.gz is required to be in $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/"
|
||||
# exit 1
|
||||
# fi
|
||||
#fi
|
||||
|
||||
if [ $generating_database -eq 1 ]; then
|
||||
if [ "$version" > "5.6" ]; then
|
||||
rm -f /tmp/empty-defaults.txt
|
||||
touch /tmp/empty-defaults.txt
|
||||
rm -rf /tmp/$port/data
|
||||
$PERCONA_TOOLKIT_SANDBOX/$mysqld --defaults-file=/tmp/${port}/my.sandbox.cnf --initialize
|
||||
else
|
||||
# MySQL up to 5.6 needs mysql_install_db
|
||||
# Support for it is a TODO
|
||||
echo "For MySQL < 5.7 data.tar.gz is required to be in $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
init_file="/tmp/$port/mysql-init"
|
||||
rm -rf $init_file
|
||||
|
||||
$PERCONA_TOOLKIT_BRANCH/util/version_cmp $minor_version 5.7.5
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'msandbox';" > $init_file
|
||||
echo "GRANT ALL PRIVILEGES ON *.* TO 'msandbox'@'127.0.0.1' IDENTIFIED BY 'msandbox';" >> $init_file
|
||||
echo "GRANT ALL PRIVILEGES ON *.* TO 'msandbox'@'localhost' IDENTIFIED BY 'msandbox';" >> $init_file
|
||||
echo "FLUSH PRIVILEGES;" >> $init_file
|
||||
else
|
||||
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('msandbox');" > $init_file
|
||||
echo "GRANT ALL PRIVILEGES ON *.* TO 'msandbox'@'localhost' IDENTIFIED BY 'msandbox';" >> $init_file
|
||||
echo "GRANT ALL PRIVILEGES ON *.* TO 'msandbox'@'127.0.0.1' IDENTIFIED BY 'msandbox';" >> $init_file
|
||||
echo "FLUSH PRIVILEGES;" >> $init_file
|
||||
fi
|
||||
|
||||
if [ "$type" = "slave" ]; then
|
||||
echo "FLUSH TABLES WITH READ LOCK;" >> $init_file
|
||||
echo "SET GLOBAL read_only = ON;" >> $init_file
|
||||
echo "UNLOCK TABLES;" >> $init_file
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start the sandbox and check that it has InnoDB.
|
||||
@@ -161,6 +217,7 @@ make_sandbox() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
/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 '')";
|
||||
|
||||
@@ -264,8 +321,10 @@ if [ $type = "cluster" -o $APP = "pxc" ]; then
|
||||
# ip=$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')
|
||||
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`;
|
||||
minor_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,3 | cut -d- -f1`;
|
||||
else
|
||||
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
||||
minor_version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2,3 | cut -d- -f1`;
|
||||
fi
|
||||
|
||||
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then
|
||||
|
Reference in New Issue
Block a user