mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-03-24 02:00:47 +08:00
Merged sandbox-pxc-compat
This commit is contained in:
@@ -80,7 +80,7 @@ sub use {
|
||||
if ( $? >> 8 ) {
|
||||
die "Failed to execute $cmd on $server: $out";
|
||||
}
|
||||
return;
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub create_dbs {
|
||||
@@ -203,6 +203,7 @@ sub master_is_ok {
|
||||
# Returns a string if there is a problem with the slave.
|
||||
sub slave_is_ok {
|
||||
my ($self, $slave, $master, $ro) = @_;
|
||||
return if $self->is_cluster_node($slave);
|
||||
PTDEBUG && _d('Checking if slave', $slave, $port_for{$slave},
|
||||
'to', $master, $port_for{$master}, 'is ok');
|
||||
|
||||
@@ -345,7 +346,8 @@ sub verify_test_data {
|
||||
'SELECT * FROM percona_test.checksums',
|
||||
'db_tbl');
|
||||
$self->{checksum_ref} = $ref unless $self->{checksum_ref};
|
||||
my @tables_in_mysql = @{$master->selectcol_arrayref('SHOW TABLES FROM mysql')};
|
||||
my @tables_in_mysql = grep { !/^innodb_(?:table|index)_stats$/ }
|
||||
@{$master->selectcol_arrayref('SHOW TABLES FROM mysql')};
|
||||
my @tables_in_sakila = qw(actor address category city country customer
|
||||
film film_actor film_category film_text inventory
|
||||
language payment rental staff store);
|
||||
@@ -396,6 +398,20 @@ sub clear_genlogs {
|
||||
return;
|
||||
}
|
||||
|
||||
sub is_cluster_node {
|
||||
my ($self, $server) = @_;
|
||||
|
||||
my $sql = "SHOW VARIABLES LIKE 'wsrep_on'";
|
||||
PTDEBUG && _d($sql);
|
||||
my $row = $self->use($server, qq{-ss -e "$sql"});
|
||||
PTDEBUG && _d($row);
|
||||
$row = [split " ", $row];
|
||||
|
||||
return $row && $row->[1]
|
||||
? ($row->[1] eq 'ON' || $row->[1] eq '1')
|
||||
: 0;
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
# ###########################################################################
|
||||
|
||||
@@ -43,6 +43,12 @@ exit_status=0
|
||||
/tmp/$PORT/use < sakila-db/sakila-schema.sql
|
||||
exit_status=$((exit_status | $?))
|
||||
|
||||
# We can remove this once PXC's triggers can handle myisam tables
|
||||
if [ "${2:-""}" = "cluster" ]; then
|
||||
/tmp/$PORT/use -e "ALTER TABLE sakila.film_text DROP KEY idx_title_description"
|
||||
/tmp/$PORT/use -e "ALTER TABLE sakila.film_text ENGINE = 'InnoDB'"
|
||||
fi
|
||||
|
||||
/tmp/$PORT/use < sakila-db/sakila-data.sql
|
||||
exit_status=$((exit_status | $?))
|
||||
|
||||
|
||||
42
sandbox/servers/pxc/5.5/my.sandbox.cnf
Normal file
42
sandbox/servers/pxc/5.5/my.sandbox.cnf
Normal file
@@ -0,0 +1,42 @@
|
||||
[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
|
||||
key_buffer_size = 16M
|
||||
innodb_buffer_pool_size = 16M
|
||||
innodb_data_home_dir = /tmp/PORT/data
|
||||
innodb_log_group_home_dir = /tmp/PORT/data
|
||||
innodb_data_file_path = ibdata1:10M:autoextend
|
||||
innodb_log_file_size = 5M
|
||||
log-bin = mysql-bin
|
||||
relay_log = mysql-relay-bin
|
||||
log_slave_updates
|
||||
server-id = PORT
|
||||
report-host = 127.0.0.1
|
||||
report-port = PORT
|
||||
log-error = /tmp/PORT/data/mysqld.log
|
||||
innodb_lock_wait_timeout = 3
|
||||
general_log
|
||||
general_log_file = genlog
|
||||
|
||||
binlog_format = ROW
|
||||
wsrep_provider = LIBGALERA
|
||||
wsrep_cluster_address = CLUSTER_AD
|
||||
wsrep_sst_receive_address = ADDR:RECEIVE_PRT
|
||||
wsrep_node_incoming_address= ADDR
|
||||
wsrep_slave_threads = 2
|
||||
wsrep_cluster_name = CLUSTER_NAME
|
||||
wsrep_provider_options = "gmcast.listen_addr=tcp://ADDR:LISTEN_PRT;"
|
||||
wsrep_sst_method = rsync
|
||||
wsrep_node_name = PORT
|
||||
innodb_locks_unsafe_for_binlog = 1
|
||||
innodb_autoinc_lock_mode = 2
|
||||
wsrep-replicate-myisam
|
||||
@@ -40,6 +40,28 @@ make_sandbox() {
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${type}" = "cluster" ]; then
|
||||
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/pxc/$version/my.sandbox.cnf /tmp/$port
|
||||
|
||||
local ip="$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')"
|
||||
local libgalera="$PERCONA_TOOLKIT_SANDBOX/lib/libgalera_smm.so"
|
||||
local cluster_name="${CLUSTER_NAME:-"pt_sandbox_cluster"}"
|
||||
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"
|
||||
fi
|
||||
|
||||
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_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/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"
|
||||
fi
|
||||
|
||||
for file in `grep -l PORT /tmp/$port/*`; do
|
||||
sed -e "s/PORT/$port/g" -i.bak $file
|
||||
# Use ! instead of / because the replacment has / (it's a directory)
|
||||
@@ -116,7 +138,7 @@ type=$1 # master, slave or master-master
|
||||
port=$2 # sandbox port number, e.g. 12345
|
||||
master_port=$3 # master port if slave or master-master
|
||||
|
||||
if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ]; then
|
||||
if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ] && [ "$type" != "cluster" ]; then
|
||||
die "Invalid sandbox type: $type. Valid types are master, slave, and master-master."
|
||||
fi
|
||||
|
||||
@@ -154,7 +176,7 @@ cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
# MySQL executables like PERCONA_TOOLKIT_SANDBOX/bin/mysqld_safe.
|
||||
|
||||
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
|
||||
PERCONA_TOOLKIT_SANDBOX=`./mk-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
|
||||
die "PERCONA_TOOLKIT_SANDBOX environment variable is not set."
|
||||
fi
|
||||
|
||||
@@ -284,17 +284,28 @@ fi
|
||||
case $opt in
|
||||
start)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
./start-sandbox master 12345
|
||||
./start-sandbox "${2:-"master"}" 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
set_mysql_version
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
./start-sandbox slave 12346 12345
|
||||
./start-sandbox "${2:-"slave"}" 12346 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
./start-sandbox slave 12347 12346
|
||||
./start-sandbox "${2:-"slave"}" 12347 12346
|
||||
exit_status=$((exit_status | $?))
|
||||
|
||||
if [ "${2:-""}" = "cluster" ]; then
|
||||
echo -n "Checking that the cluster size is correct... "
|
||||
size=$(/tmp/12345/use -ss -e "SHOW STATUS LIKE 'wsrep_cluster_size'" | awk '{print $2}')
|
||||
if [ ${size:-0} -ne 3 ]; then
|
||||
echo "FAILED"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 -a "$MYSQL_VERSION" '>' "4.1" ]; then
|
||||
echo -n "Loading sakila database... "
|
||||
./load-sakila-db 12345
|
||||
./load-sakila-db 12345 "${2:-""}"
|
||||
exit_status=$((exit_status | $?))
|
||||
if [ $exit_status -ne 0 ]; then
|
||||
echo "FAILED"
|
||||
|
||||
@@ -44,7 +44,8 @@ my $dbh = DBI->connect(
|
||||
# Sandbox::ok() will throw "ERROR: Tables are different on master: mysql.proc"
|
||||
$dbh->do("UPDATE mysql.proc SET created='2012-06-05 00:00:00', modified='2012-06-05 00:00:00'");
|
||||
|
||||
my @tables_in_mysql = @{$dbh->selectcol_arrayref('SHOW TABLES FROM mysql')};
|
||||
my @tables_in_mysql = grep { !/^innodb_(?:table|index)_stats$/ }
|
||||
@{$dbh->selectcol_arrayref('SHOW TABLES FROM mysql')};
|
||||
my @tables_in_sakila = qw( actor address category city country customer
|
||||
film film_actor film_category film_text inventory
|
||||
language payment rental staff store );
|
||||
|
||||
Reference in New Issue
Block a user