-
Notifications
You must be signed in to change notification settings - Fork 14
/
run_tpcc.sh
65 lines (52 loc) · 1.56 KB
/
run_tpcc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
##
## tpcc 自动测试脚本,仅供参考
##
##
## created by yejr(imysql@imysql.com, http://imysql.com, QQ: 4700963, QQ群: 125572178、272675472)
## MySQL中文网: http://imysql.com
## 叶金荣(yejr)
## 小叶子她爹,装过Linux,写过PHP,优化过MySQL,目前围绕运维领域打杂
## 新浪微博: @叶金荣, 微信公众号: MYSQL中文网
## QQ群: 125572178、272675472
##
#指定本地的mysql libdir,可根据实际情况自行调整
export LD_LIBRARY_PATH=/usr/local/mysql/lib/
. ~/.bash_profile
set -u
set -x
set -e
BASEDIR="/opt/yejr/tpcc-mysql"
cd $BASEDIR
#运行过程全部记录日志到 run_tpcc.log 中
exec 3>&1 4>&2 1>> run_tpcc.log 2>&1
# 下面参数根据实际情况自行修改
DBIP=1.2.3.4
DBPORT=3306
DBUSER='tpcc'
DBPASSWD='tpcc'
NOW=`date +'%Y%m%d%H%M'`
WIREHOUSE=100
DBNAME="tpcc${WIREHOUSE}"
WARMUP=300
DURING=3600
#初始化测试数据
#./tpcc_load $DBIP:$DBPORT $DBNAME $DBUSER $DBPASSWD $WIREHOUSE
for THREADS in 64 128 256 384 512 640 768 896 1024 1152 1280 1408 1536 1664 1792 1920
do
./tpcc_start -h $DBIP -P $DBPORT -d $DBNAME -u $DBUSER -p "${DBPASSWD}" -w $WIREHOUSE -c $THREADS -r $WARMUP -l $DURING > tpcc_${THREADS}_THREADS_${NOW} 2>&1
# 每次测试完都要重启 mysqld,可根据实际情况自行调整
/etc/init.d/mysql stop
while [ 1 ]
do
#判断mysqld进程是否还存活的依据,可根据实际情况自行调整
if [ ! -z "ps -ef|grep -v grep|grep 'mysqld'" ] ; then
sleep 60
fi
done
# 清除 OS cache
echo 3 > /proc/sys/vm/drop_caches
# 再次启动 mysqld
/etc/init.d/mysql start
sleep 60
done