tsung 安装配置

一、介绍:

它能用来压力测试HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP 和 Jabber/XMPP的服务器。它可以分布在多个客户机,并能够模拟成千上万的虚拟用户数并发。

传统压力测试工具要收费,而且很贵, 难以扩展,无法很好的集群形成大的压力.Tsung内置支持 HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and Jabber/XMPP协议. Tsung可以同时模拟上百万用户,如果你有够多的机器的话Tsung稳定可靠

二、安装

1、安装前确认系统是否安装了编译环境gcc和perl:

rpm –q gcc

rpm –q perl

没有的话:

\1. # yum install gcc -y

\2. # yum install perl -y

2、安装erlang

Tsung是用erlang写的需要安装erlang:

wget www.erlang.org/download/ot…

tar -zxvf otp_src_R14B04.tar.gz

cd otp_src_R14B04

./configure --prefix=/usr/local/erlang

make

make install

备注:在configure时,会报configure: error: No curses library functions found 错误,这是由于系统缺少ncurses-devel包,安装ncurses-devel包后,重新configure一次:

yum install –y ncurses-devel

在configure时会报java not found,可以在配置加一个—without-javac选项:

./configure --prefix=/home/erlang --without-javac

在configure时还会报一个odbc的disabled,如果你觉得有必要的话,可以安装:(好像不安装也可以直接make,)

yum install unixODBC unixODBC-devel

在configure时还会有其他的错误提醒,可以忽略直接make;

3、安装Tsung

wget tsung.erlang-projects.org/dist/tsung-…

tar -zxvf tsung-1.4.2.tar.gz

cd tsung-1.4.2

./configure --prefix=/usr/local/tsung --with-erlang=/usr/local/erlang

make

make install

4、安装perl的Template

Tsung 生成统计报告时需要用到该模板

wget cpan.org/modules/by-…

tar -zxvf Template-Toolkit-2.24.tar.gz

cd Template-Toolkit-2.24

perl Makefile.PL

make

make test

make install

在perl Makefile.PL时可能会报以下错误:

Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl 5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_pe rl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.

BEGIN failed--compilation aborted at Makefile.PL line 3.

编译FCGI的时候报错.google了下,找到答案,只有安装

yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

就可以了

5、安装gnuplot(图片生成工具)

yum install -y gnuplot gd libpng zlib

确定gnuplot支持png,输入shell命令:gnuplot

gnuplot> set terminal

然后按回车确认是否已经支持png,看到下面这行,说明已经支持了:

\1. png PNG images using libgd and TrueType fonts

退出gnuplot的命令为:exit

6、Tsung 使用方法

为了方便:

ln /usr/local/erlang/bin/erl /usr/sbin/erl (集群的时候会用到,因为ssh要求erl必须在sshd所在的path中)

ln /usr/local/tsung/bin/tsung /usr/bin/tsung

启动Tsung:(一般在/usr/local/tsung/bin/tsung)

tsung -f jabber.xml start

启动后,Tsung会输出log的存放路径(一般在/root/.tsung/)

\1. Starting Tsung

\2. "Log directory is: /root/.tsung/log/20120329-2234"

等待测试完毕,进入log目录

cd /root/.tsung/log/20120329-2234

/usr/local/tsung/lib/tsung/bin/tsung_stats.pl (生成统计图表)

注意:一定要在相应的log目录下,才能生成统计图表。

查看统计图表方法:

可以启动httpd服务,然后将整个log目录复制到httpd可访问目录下,直接访问每一次测试的log目录下report.html

7、关于Tsung的monitor配置

Monitor有两种方式,默认采用erlang,另外一种是snmp:

Erlang需要无密码ssh的配置;

Snmp需要安装snmpd服务及相关工具,snmpd.conf配置一开始不容易配置,需要161udp端口;建议使用snmpd服务,毕竟其他很多测试工具都默认使用snmpd服务监控服务器;

注意:

被监控服务器的防火墙尽量是关闭的,service iptables stop

这里使用snmp类型,默认161端口,也可以指定端口详见user manual

8、实例

1) 编辑xml文件

image.png

关于http协议的http url注意点:

&符号需要更换为& ,否则tsung会报错

?type=2&page=1&pagesize=10 get的方式,在post方式需要在http中再加contents=” type=2&page=1&pagesize=10”

2) Tsung start

image.png

image.png

3) 数据收集-数据文档-图表生成

image.png

4)可以将.tsung/log/ 整个文档放到http服务器主目录下,通过http://192.168.2.211/log/20130325-1053/report.html访问报告文档:(含有表格、图表两种方式)

你可能感兴趣的:(tsung 安装配置)