压力测试工具Tsung1.7的使用


官方文档:http://tsung.readthedocs.io/en/latest/installation.html

tsung分布式环境搭建:
http://www.51testing.com/index.php?action-viewnews-itemid-3720564-php-1

http://blog.sina.com.cn/s/blog_13cc013b50102v5nv.html

详细介绍:
http://www.blogjava.net/yongboy/archive/2016/08/08/431498.html


pts环境搭建:
https://www.bstester.com/category/softtestknowledge/performancetest

#先要安装jdk并配置环境变量


#进去程序安装包所在目录
cd /usr/local/src

mochiweb xpath解析,http中动态变量 包含在tsung源码中
参考地址:https://github.com/mochi/mochiweb

#用脚本tsung_stats.pl输出图形报告
gnuplot and perl5 参考:http://template-toolkit.org/

#待确定是否要安装 build-essential openssl make kernel-devel m4 perl5

yum -y install gnuplot gd libpng zlib bzip2

yum -y install unixODBC unixODBC-devel perl gcc openssl-devel gcc-c++ ncurses-devel gtk2-devel


#安装OpenGL库
yum -y install mesa* freeglut*


单独安装wxWidgets
wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.0/wxWidgets-3.1.0.tar.bz2
tar -xvf wxWidgets-3.1.0.tar.bz2

cd wxWidgets-3.1.0

./configure --with-opengl --enable-debug --enable-unicode

make && make install


#安装erlang
erlang安装包下载地址:http://www.erlang.org/downloads

wget http://erlang.org/download/otp_src_20.2.tar.gz

tar -xvf otp_src_20.2.tar.gz

cd otp_src_20.2

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

make

make install

#新建erlang软连接
ln -s /usr/local/erlang/bin/erl /usr/local/bin/erl

#修改erlang的环境变量到/etc/profile文件中,最后/etc/profile文件如下:
JAVA_HOME=/opt/jdk1.8
JRE_HOME=/opt/jdk1.8/jre
ERLANG_HOME=/usr/local/erlang
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ERLANG_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib
export JAVA_HOME JRE_HOME ERLANG_HOME PATH CLASSPATH

#查看erlang版本
erl -version
Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 9.2

#安装tsung1.7版本
tsung安装目录:/usr/local/tsung1.7
wget http://tsung.erlang-projects.org/dist/tsung-1.7.0.tar.gz

tar zxvf tsung-1.7.0.tar.gz

cd tsung-1.7.0

./configure --prefix=/usr/local/tsung1.7

make

make install

#新建tsung软连接
ln -s /usr/local/tsung1.7/bin/tsung /usr/local/bin/tsung

#修改tsung的环境变量到/etc/profile文件中,最后/etc/profile文件如下:
JAVA_HOME=/opt/jdk1.8
JRE_HOME=/opt/jdk1.8/jre
ERLANG_HOME=/usr/local/erlang
TSUNG_HOME=/usr/local/tsung1.7
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ERLANG_HOME/bin:$:TSUNG_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib
export JAVA_HOME JRE_HOME ERLANG_HOME TSUNG_HOME PATH CLASSPATH

#查看tsung版本
tsung -version

Tsung version 1.7.0

#安装perl Template 用于输出图形报表 build-essential openssl make kernel-devel m4
yum -y install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-Test-Pod perl-Template-Toolkit

wget http://cpan.org/modules/by-module/Template/Template-Toolkit-2.26.tar.gz

tar zxvf Template-Toolkit-2.26.tar.gz

cd Template-Toolkit-2.26

perl Makefile.PL

make

make test

make install

#配置ssh无密码访问
#生成公钥和私钥
每台机器通过ssh-keygen命令生成私钥和公钥,公钥和私钥存放在目录:/root/.ssh/id_rsa,

ssh-keygen -t rsa
之后再3次回车

#私钥
id_rsa

#公钥
id_rsa.pub

#修改文件内容 /etc/ssh/sshd_config
vi /etc/ssh/sshd_config

#启用以下两项配置
RSAAuthentication yes
PubkeyAuthentication yes

#用root用户登录,每台服务器都生成公钥,再合并到authorized_keys

#在主服务器下,合并公钥到authorized_keys。
在/root/.ssh 目录下进行合并
cat /root/.ssh/id_rsa.pub >> authorized_keys
ssh root@从机1 cat /root/.ssh/id_rsa.pub >> authorized_keys
如:
ssh root@192.168.64.132 cat /root/.ssh/id_rsa.pub >> authorized_keys

#将主服务器上 authorized_keys known_hosts复制到从服务器(/root/.ssh)目录下
#scp /root/.ssh/authorized_keys root@从机ip:/root/.ssh/
#scp /root/.ssh/known_hosts root@从机ip:/root/.ssh/

#重新启动sshd服务
systemctl start sshd.service

#重启系统
shutdown -r now

IP直连生效:
tsung.xml文件配置从机hostip属性,或host属性,填写正确IP
tsung启动时,指定本机可用IP地址:tsung -f /opt/tsung/tsung.xml -l /opt/tsung/log/ start

集群部署要求:
1)每台机器上的erlang tsung安转的版本和路径一致
2)通过计算机名实现ssh的无密码访问
3)每台机器/etc/hosts中配置集群的IP和计算机名的对应关系
4)检查机器之间可通过erlang 进行通信
5)检查ssh是否可以通过机器名进行无密码互相访问
6)防火墙是否关闭

终端输入:
erl -rsh ssh -sname foo -setcookie mycookie
例如:
主服务:erl -rsh ssh -sname yunboke -setcookie yunbokecookie
slave:start(remotehost,bar,"-setcookie yunbokecookie").

返回 :{ok,bar@remotehost} ,则部署成功。


#设置端口快速回收
修改文件中快速回收端口的设置:/usr/lib/sysctl.d/50-default.conf
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_fin_timeout=30
net.ipv4.ip_local_port_range=1024 65535

#增加文件句柄数
/etc/security/limits.conf
* soft fsize unlimited
* hard fsize unlimited
* soft cpu unlimited
* hard cpu unlimited
* soft as unlimited
* hard as unlimited
* soft nofile 10240000
* hard nofile 10240000
* soft nproc 10240000
* hard nproc 10240000

#其中nofile指,可设置成无线大,但受制于nr_open,改值通过 /proc/sys/fs/nr_open 来设置
ulimit 包括硬限制和软限制 -H 硬限制 -S 软限制 默认是软限制
系统总限制 /proc/sys/fs/file-max

echo 10240000 > /proc/sys/fs/file-max

file-max 所有进程最大文件数
nr_open 单个进程打开的最大文件数

echo 10240000 > /proc/sys/fs/nr_open

vim /etc/sysctl.conf
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65000
fs.file-max = 65000
fs.nr_open=10240000

fs.nr_open的值<=file.max


#设置 /etc/security/limits.d/20-nproc.conf
#* 代表所有用户,soft 代表软设置,hard 代表硬件设置,nproc 代表最大进程,nofile代表打开最大文件数
* soft nproc 4096
root soft nproc unlimited

改为:

* soft nproc 10240000
root soft nproc unlimited

 

#全局配置放在 系统资源限制设置:/etc/systemd/system.conf 和 用户资源限制设置:/etc/systemd/user.conf
及加载 /etc/systemd/system/*.conf 和 /etc/systemd/user/*.conf
system 和 user 目录下的配置文件会覆盖 system.conf 和user.conf配置。

 

posted on 2018-03-13 22:08  新美好时代  阅读(171)  评论(0编辑  收藏  举报