-
Notifications
You must be signed in to change notification settings - Fork 0
/
perf.sh
165 lines (115 loc) · 6.19 KB
/
perf.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
nthreads=1
ntables=4
nscale=4
runtime=300
logdir="./logs/th-$nthreads-tb-$ntables-sc-$nscale-tm-$runtime"
echo "Creating $logdir"
rm -rf "$logdir"
mkdir "$logdir"
sleep 10
echo "Startign MySQL setup"
sudo systemctl start mysql
mysql -u root -ppassword -e "SELECT @@datadir;"
sudo systemctl stop mysql
sudo rsync -av /var/lib/mysql /mnt/btrfs
sudo rsync -av /var/lib/mysql /mnt/ext4
sudo rsync -av /var/lib/mysql /mnt/zfs
sudo rsync -av /var/lib/mysql /mnt/xfs
sudo mv /var/lib/mysql /var/lib/mysql_bak
engines=(InnoDB MyISAM CSV)
rm -rf FS_engine_timestamp.csv
for engine in "${engines[@]}"; do
# 1. Run on btrfs
sudo systemctl stop mysql
sudo sed -i '22s/.*/datadir = \/mnt\/btrfs\/mysql/' /etc/mysql/mysql.conf.d/mysqld.cnf
sudo sed -i '16s/.*/alias \/var\/lib\/mysql\/ -> \/mnt\/btrfs\/mysql\/\,/' /etc/apparmor.d/tunables/alias
sudo systemctl restart apparmor
sudo systemctl start mysql
# Run tests
mysql -u root -ppassword -e "DROP SCHEMA IF EXISTS sbtest;"
mysql -u root -ppassword -e "CREATE SCHEMA sbtest;"
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' prepare
if [ "$engine" != "InnoDB" ]; then
chmod +x ./change_engine.sh
./change_engine.sh sbtest $engine
fi
sleep 60
start_time=$(date +%s.%N)
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --time=$runtime --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' run > "$logdir/btrfs-${engine}.log"
sysbench --test=/usr/share/sysbench/tpcc.lua --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' cleanup
end_time=$(date +%s.%N)
sleep 60
echo "btrfs,${engine},${start_time},${end_time}" >> FS_engine_timestamp.csv
# End test run
mysql -u root -ppassword -e "SELECT @@datadir;"
# 2. Run on ext4
sudo systemctl stop mysql
sudo sed -i '22s/.*/datadir = \/mnt\/ext4\/mysql/' /etc/mysql/mysql.conf.d/mysqld.cnf
sudo sed -i '16s/.*/alias \/var\/lib\/mysql\/ -> \/mnt\/ext4\/mysql\/\,/' /etc/apparmor.d/tunables/alias
sudo systemctl restart apparmor
sudo systemctl start mysql
# Run tests
mysql -u root -ppassword -e "DROP SCHEMA IF EXISTS sbtest;"
mysql -u root -ppassword -e "CREATE SCHEMA sbtest;"
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' prepare
if [ "$engine" != "InnoDB" ]; then
chmod +x ./change_engine.sh
./change_engine.sh sbtest $engine
fi
sleep 60
start_time=$(date +%s.%N)
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --time=$runtime --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' run > "$logdir/ext4-${engine}.log"
sysbench --test=/usr/share/sysbench/tpcc.lua --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' cleanup
end_time=$(date +%s.%N)
sleep 60
echo "ext4,${engine},${start_time},${end_time}" >> FS_engine_timestamp.csv
# End test run
mysql -u root -ppassword -e "SELECT @@datadir;"
# 3. Run on zfs
sudo systemctl stop mysql
sudo sed -i '22s/.*/datadir = \/mnt\/zfs\/mysql/' /etc/mysql/mysql.conf.d/mysqld.cnf
sudo sed -i '16s/.*/alias \/var\/lib\/mysql\/ -> \/mnt\/zfs\/mysql\/\,/' /etc/apparmor.d/tunables/alias
sudo systemctl restart apparmor
sudo systemctl start mysql
# Run tests
mysql -u root -ppassword -e "DROP SCHEMA IF EXISTS sbtest;"
mysql -u root -ppassword -e "CREATE SCHEMA sbtest;"
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' prepare
if [ "$engine" != "InnoDB" ]; then
chmod +x ./change_engine.sh
./change_engine.sh sbtest $engine
fi
sleep 60
start_time=$(date +%s.%N)
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --time=$runtime --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' run > "$logdir/zfs-${engine}.log"
sysbench --test=/usr/share/sysbench/tpcc.lua --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' cleanup
end_time=$(date +%s.%N)
sleep 60
echo "zfs,${engine},${start_time},${end_time}" >> FS_engine_timestamp.csv
# End test run
mysql -u root -ppassword -e "SELECT @@datadir;"
# 4. Run on xfs
sudo systemctl stop mysql
sudo sed -i '22s/.*/datadir = \/mnt\/xfs\/mysql/' /etc/mysql/mysql.conf.d/mysqld.cnf
sudo sed -i '16s/.*/alias \/var\/lib\/mysql\/ -> \/mnt\/xfs\/mysql\/\,/' /etc/apparmor.d/tunables/alias
sudo systemctl restart apparmor
sudo systemctl start mysql
# Run tests
mysql -u root -ppassword -e "DROP SCHEMA IF EXISTS sbtest;"
mysql -u root -ppassword -e "CREATE SCHEMA sbtest;"
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' prepare
if [ "$engine" != "InnoDB" ]; then
chmod +x ./change_engine.sh
./change_engine.sh sbtest $engine
fi
sleep 60
start_time=$(date +%s.%N)
sysbench --test=/usr/share/sysbench/tpcc.lua --threads=$nthreads --tables=$ntables --scale=$nscale --time=$runtime --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' run > "$logdir/xfs-${engine}.log"
sysbench --test=/usr/share/sysbench/tpcc.lua --tables=$ntables --scale=$nscale --db-driver=mysql --mysql-db=sbtest --mysql-user=root --mysql-password='password' cleanup
end_time=$(date +%s.%N)
sleep 60
echo "xfs,${engine},${start_time},${end_time}" >> FS_engine_timestamp.csv
# End test run
done
mysql -u root -ppassword -e "SELECT @@datadir;"
echo "Script finished"