安装java
jdk-6u45-linux-i586.bin
./jdk-6u45-linux-i586.bin
执行完成后生成目录 jdk1.6.0_45
配置环境变量
export JAVA_HOME=/opt/jdk1.6.0_45
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=".;$JAVA_HOME/lib/dt.jar;$JAVA_HOME/lib/tools.jar:$CLASSPATH"
source /root/.bashrc
配置jmete
以JMeter2.9为例,下载地址:http://jmeter.apache.org/download_jmeter.cgi,选择binaries下2.9版本。
解压完成后,赋权限:chmod 777 -R /opt/apache-jmeter-2.12
添加环境变量:
vi /root/bashrc
添加下述两行:
export JMETER="/usr/local/jmeter/apache-jmeter-2.9"
export CLASSPATH="$JMETER/lib/ext/ApacheJMeter_core.jar:$JMETER/lib/jorphan.jar:$JMETER/lib/logkit-2.0.jar:$CLASSPATH"
完成添加后下述命令使配置生效:
source /root/bashrc
运行脚本
建立测试结果文件test.jtl
在jmeter目录下 ./jmeter -n -t /opt/bugfree.jmx -l /opt/testbf.jtl
[[email protected] opt]# vim /opt/testbf.jtl
1419703126476,2056,Login,200,OK,线程组 1-3,text,true,6168,3,3,1568
1419703126160,2377,Login,200,OK,线程组 1-1,text,true,6168,3,3,1883
1419703126160,2378,Login,200,OK,线程组 1-2,text,true,6168,3,3,1884
1419703128585,609,opened,200,OK,线程组 1-1,text,true,21374,3,3,426
1419703128592,603,opened,200,OK,线程组 1-2,text,true,21374,3,3,417
1419703128587,600,opened,200,OK,线程组 1-3,text,true,21374,3,3,419
1419703129216,835,resolved,200,OK,线程组 1-1,text,true,23062,3,3,646
1419703129221,836,resolved,200,OK,线程组 1-2,text,true,23062,3,3,643
1419703129220,839,resolved,200,OK,线程组 1-3,text,true,23062,3,3,651
1419703130058,402,HTTP请求,200,OK,线程组 1-2,text,true,17357,3,3,389
1419703130053,411,HTTP请求,200,OK,线程组 1-1,text,true,17357,2,2,396
1419703130061,410,HTTP请求,200,OK,线程组 1-3,text,true,17357,1,1,405
查看数据库中记录,执行成功。