PMMLoadTestMySQL10

by perconalab
224 deployments · 223 still active · last rev. 3 months ago

A version of load test which registers itself as 10 instances of Node + MySQL Metrics. It does not enable QAN

Compatible with: Ubuntu 18.04 LTS
						#!/bin/bash
# This block defines the variables the user of the script needs to input
# when deploying using this script.
#
#
#<UDF name="hostname" label="The hostname for the new Linode.">
# HOSTNAME=
#<UDF name="pmmserver" label="The IP/Host Name of PMM Server to use.">
# PMMSERVER=
#

# Added logging for debug purposes
exec >  >(tee -a /root/stackscript.log)
exec 2> >(tee -a /root/stackscript.log >&2)


# This section sets the hostname.
echo $HOSTNAME > /etc/hostname
hostname -F /etc/hostname

#Percona 

cd /tmp/
wget https://repo.percona.com/apt/percona-release_0.1-6.$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-6.$(lsb_release -sc)_all.deb
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y install percona-server-server-5.7 sysbench sysbench-tpcc bc screen pmm-client

# Create my.cnf

cat > /etc/mysql/my.cnf << EOF
[mysqld]
innodb_buffer_pool_size=128M
innodb_buffer_pool_instances=1
innodb_log_file_size=1G
innodb_flush_method=O_DIRECT
innodb_numa_interleave=1
innodb_flush_neighbors=0
log_bin
server_id=1
expire_logs_days=1
max_binlog_files=1
log_output=file
slow_query_log=ON
long_query_time=0
log_slow_rate_limit=10
log_slow_rate_type=query
log_slow_verbosity=full
log_slow_admin_statements=ON
log_slow_slave_statements=ON
slow_query_log_always_write_time=1
slow_query_log_use_global_control=all
innodb_monitor_enable=all
userstat=1
EOF

service mysql restart 


# Add to PMM Re-use the name if such server already exists.
pmm-admin config --server $PMMSERVER --force

# Use case if we re-provision server without removing services

pmm-admin repair

# Add this server as if it were 10 different servers 
# Add sleep to avoid overload if starting many servers at once 

for i in `seq 1 10`;
do
  echo  Adding $i
  pmm-admin add linux:metrics  $HOSTNAME-$i --force
  pmm-admin add mysql:metrics  $HOSTNAME-$i
  sleep 5
done


pmm-admin annotate "$HOSTNAME monitoring started"

#
cd /usr/share/sysbench/
mysqladmin create tpcc
./tpcc.lua  --db-driver=mysql --mysql-user=root --mysql-db=tpcc  --threads=1  --tables=10 --scale=1 prepare
./tpcc.lua  --rate=5 --db-driver=mysql --mysql-user=root --mysql-db=tpcc --percentile=99 --time=0 --threads=128 --report-interval=10 --tables=10 --scale=1 --enable_purge=yes run > /tmp/tpccrun_lo