PMMLoadTestMySQL

by perconalab
158 deployments · 157 still active · last rev. 3 months ago

Load Test Driver for PMM Using Sysbench TPC-C Workload

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=512M
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
pmm-admin config --server $PMMSERVER
# Run repair just in case there is orphaned server with such name 
pmm-admin repair
pmm-admin add mysql
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=4  --tables=10 --scale=1 prepare
./tpcc.lua  --rate=10 --db-driver=mysql --mysql-user=root --mysql-db=tpcc --percentile=99 --time=0 --threads=128 --report-interval=10 --tables=10 --scale=1 run > /tmp/tpccrun_log

# Remove from PMM 
# pmm-admin remove --all

# This updates the packages on the system from the distribution repositories.

# DEBIAN_FRONTEND=noninteractive apt-get upgrade -y

#