1.filebench安装
首先检测是否安装了gcc:
gcc –version
如果已经安装则执行:
sudo apt-get install flex bison
Ubuntu下安装filebench,首先下载安装包。
szp@szp-pc:~$ wget https://phoenixnap.dl.sourceforge.net/project/filebench/1.5-alpha3/filebench-1.5-alpha3.tar.gz
将filebench解压到/usr/local目录下。
szp@szp-pc:~$ sudo tar -zxf filebench-1.5-alpha3.tar.gz -C /usr/local
进入解压后的目录下,
szp@szp-pc:~$ cd /usr/local/
依次执行以下命令进行安装。
szp@szp-pc:/usr/local/filebench-1.5-alpha3$ sudo ./configure
szp@szp-pc:/usr/local/filebench-1.5-alpha3$ sudo make
szp@szp-pc:/usr/local/filebench-1.5-alpha3$ sudo make install
为了不影响filebench自带的负载文件,复制一份workloads下自带的工作负载文件,然后根据自身需要进行修改。
szp@szp-pc:~$ cp -r /usr/local/share/filebench/workloads/ ./workloads
使用WML语言进行编写,教程如下:workload model language。
2.filebench模拟web服务器测试
使用
sudo filebench -f webserver.f
运行webserver测试。
直接运行会出现无法停止的问题,修改webserver.f,加入退出模式。
1 | // 设置退出模式,支持[ timeout | alldone | firstdone ] |
然后有可能出现以下错误:
szp@szp-pc:~/workloads$ sudo filebench -f webserver.f Filebench Version 1.5-alpha3 0.002: Allocated 173MB of shared memory 0.027: Web-server Version 3.1 personality successfully loaded 0.027: Populating and pre-allocating filesets 0.032: logfiles populated: 1 files, avg. dir. width = 2, avg. dir. depth = 0.0, 0 leafdirs, 0.002MB total size 0.032: Removing logfiles tree (if exists) 0.039: Pre-allocating directories in logfiles tree 0.039: Pre-allocating files in logfiles tree 0.040: bigfileset populated: 10 files, avg. dir. width = 2, avg. dir. depth = 3.3, 0 leafdirs, 0.132MB total size 0.040: Removing bigfileset tree (if exists) 0.046: Pre-allocating directories in bigfileset tree 0.046: Pre-allocating files in bigfileset tree 0.047: Waiting for pre-allocation to finish (in case of a parallel pre-allocation) 0.047: Population and pre-allocation of filesets completed 0.049: Starting 1 filereader instances 9.063: Waiting for pid 8269 thread filereaderthread-1 10.063: Waiting for pid 8269 thread filereaderthread-1 11.064: Running... 11.064: Unexpected Process termination Code 3, Errno 0 around line 77 12.065: Run took 1 seconds... 12.065: Run took 1 seconds...
原因是系统打开了ASLR。
ASLR(Address Space Layout Randomization)在2005年被引入到Linux的内核 kernel 2.6.12 中,当然早在2004年就以patch的形式被引入。随着内存地址的随机化,使得响应的应用变得随机。这意味着同一应用多次执行所使用内存空间完全不同,也意味着简单的缓冲区溢出攻击无法达到目的。
使用root权限以及如下命令关闭ASLR。
1 | echo 0 > /proc/sys/kernel/randomize_va_space |
重新执行filebench程序:
root@szp-pc:/home/szp/workloads# filebench -f webserver.f Filebench Version 1.5-alpha3 0.002: Allocated 173MB of shared memory 0.018: Web-server Version 3.1 personality successfully loaded 0.019: Populating and pre-allocating filesets 0.021: logfiles populated: 1 files, avg. dir. width = 2, avg. dir. depth = 0.0, 0 leafdirs, 0.002MB total size 0.021: Removing logfiles tree (if exists) 0.025: Pre-allocating directories in logfiles tree 0.025: Pre-allocating files in logfiles tree 0.026: bigfileset populated: 10 files, avg. dir. width = 2, avg. dir. depth = 3.3, 0 leafdirs, 0.132MB total size 0.026: Removing bigfileset tree (if exists) 0.030: Pre-allocating directories in bigfileset tree 0.031: Pre-allocating files in bigfileset tree 0.033: Waiting for pre-allocation to finish (in case of a parallel pre-allocation) 0.033: Population and pre-allocation of filesets completed 0.035: Starting 1 filereader instances 1.052: Running... 61.333: Run took 60 seconds... 61.335: Per-Operation Breakdown appendlog 160003ops 2654ops/s 20.7mb/s 0.1ms/op [0.00ms - 151.46ms] closefile10 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.19ms] readfile10 160003ops 2654ops/s 16.0mb/s 0.0ms/op [0.00ms - 0.52ms] openfile10 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 1.19ms] closefile9 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.20ms] readfile9 160003ops 2654ops/s 13.9mb/s 0.0ms/op [0.00ms - 0.33ms] openfile9 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.84ms] closefile8 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.30ms] readfile8 160003ops 2654ops/s 30.3mb/s 0.0ms/op [0.00ms - 0.49ms] openfile8 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.88ms] closefile7 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.28ms] readfile7 160003ops 2654ops/s 28.2mb/s 0.0ms/op [0.00ms - 0.71ms] openfile7 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.85ms] closefile6 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.18ms] readfile6 160003ops 2654ops/s 125.5mb/s 0.0ms/op [0.00ms - 0.68ms] openfile6 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 1.47ms] closefile5 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.10ms] readfile5 160003ops 2654ops/s 9.5mb/s 0.0ms/op [0.00ms - 0.25ms] openfile5 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.77ms] closefile4 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.18ms] readfile4 160003ops 2654ops/s 58.3mb/s 0.0ms/op [0.00ms - 0.31ms] openfile4 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 1.12ms] closefile3 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.13ms] readfile3 160003ops 2654ops/s 30.2mb/s 0.0ms/op [0.00ms - 0.20ms] openfile3 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 1.24ms] closefile2 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.17ms] readfile2 160003ops 2654ops/s 26.7mb/s 0.0ms/op [0.00ms - 0.48ms] openfile2 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 2.47ms] closefile1 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.18ms] readfile1 160003ops 2654ops/s 12.0mb/s 0.0ms/op [0.00ms - 0.25ms] openfile1 160003ops 2654ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.76ms] 61.335: IO Summary: 4960093 ops 82283.522 ops/s 26543/2654 rd/wr 371.3mb/s 0.0ms/op 61.335: Shutting down processes
结果分析:
flowop name - 支持的flowop(测试流程)有很多
所有threads的ops
所有threads的ops / run time
所有threads的READ/WRITE带宽
所有threads的每个op的平均latency
测试中op的最小和最大latency
3.测试程序解释
1 | # 自定义变量 |