一、安装TPCC
https://www.hi-linux.com/posts/38534.html
https://imysql.com/2014/10/10/tpcc-mysql-full-user-manual.shtml
https://www.cnblogs.com/xuanzhi201111/p/4148434.html
二、安装配置MySQL
1.下载安装
sudo apt install mysql-server
sudo apt install libmysql++-dev
2.修改用户名密码
log in mysql by password:
1. sudo cat /etc/mysql/debian.cnf
2. mysql -u debian-sys-maint -p
ZSX5MbUDpyxCt9cS
3. mysql> set password for root@localhost = password('123');
4. mysql> update mysql.user set authentication_string=PASSWORD('123'), plugin='mysql_native_password' where user='root';
5. mysql> flush privileges;
6. sudo mysql -u root -p
123
https://www.cnblogs.com/lfri/p/10724943.html
3.修改工作目录(自己测试的分区)
Change mysql dir:
1. service mysql stop
2. sudo cp -arp /var/lib/mysql /data/
3. sudo chown -R mysql:mysql /data/mysql
4. sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
datadir=/data/mysql
5. sudo vim /etc/apparmor.d/usr.sbin.mysqld
/data/mysql r
/data/mysql/** rwk
6. /etc/init.d/apparmor restart
/etc/init.d/mysql restart
https://www.cnblogs.com/wwjchina/p/10949806.html
三、tpcc运行
create databases and tables;
1. cd tpcc
2. sudo mysqladmin -u root -p create tpcc1000
3. sudo mysql -u root -p tpcc1000 < create_table.sql
4. sudo mysql -u root -p tpcc1000 < add_fkey_idx.sql
load data:
sudo ./tpcc_load -h 127.0.0.1 -d tpcc1000 -u root -p '123' -w 100
run:
sudo ./tpcc_start -h 127.0.0.1 -P 3306 -d tpcc1000 -u root -p 123 -w 10 -c 10 -r 120 -l 120 >> mysql_tpcc_20210517
四、自动化运行脚本
1.数据库自动删除
https://www.runoob.com/mysql/mysql-drop-database.html
https://www.cnblogs.com/xpwi/p/9818751.html
2.注意:做文件系统压力测试时,比如按照10%递增,需要将上次load的数据库删除掉,重新以2倍的w数load,其中70个w大约有6.5G左右。
3.运行时如果需要清缓存可以运行脚本:
#!/bin/bash
while true
do
echo "drop_caches"
sudo echo 3 > /proc/sys/vm/drop_caches
sleep 1
sudo sync
sleep 1
done