tips:撰写本本文时LoadRunner最新版本为9.5,经测试在当前LoadRunner最新版本11.00仍然适用!
1. 在HP的官方网站上下载LoadRunner9.5 的Linux安装程序[T7177-15009.iso],安装文档[hp_man_LRIG9.50_01_pdf.pdf];
安装程序包括Hp、Ibm、Linux、Solaris系统的支持(LR9.0对应安装文件为[TLRNUX900WC_00.zip])。
2. 安装包的处理:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# ZIP解压:
unzip TLRNUX900WC_00.zip
# 挂载ISO:
mkdir /mnt/LoadRunner
mount -t iso9660 -o loop T7177-15009.iso /mnt/LoadRunner
# 开始安装,以LR9.5为例,按提示操作,直接Next到完成。
/mnt/LoadRunner/Linux/installer .sh
# 添加用户和环境变量:
useradd -g 0 -s /bin/csh higkoo
cat /opt/HP/HP_LoadGenerator/env .csh > /etc/ .login
cat /opt/HP/HP_LoadGenerator/env .csh >~higkoo/.cshrc
touch ~root/.rhosts ~higkoo/.rhosts
# 检查运行环境(在本机或使用VNC执行):
su - higkoo
cd /opt/HP/HP_LoadGenerator/bin/
. /verify_generator
# 启动服务(用新增的用户higkoo):
cd /opt/HP/HP_LoadGenerator/bin/
. /m_daemon_setup start
# 检查是否启动:
ps aux | grep m_agent_daemon
netstat -naop | grep 54345
|
3. 注意事项:
开启端口54345或关闭防火墙
1
2
|
service iptables stop
chkconfig iptables off
|
正确设置后用verify_generator的检测结果是:
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
|
./verify_generator
===================================================
HP
Vuser Environment Verification Utility
===================================================
Product: HP LoadRunner 9.50
Version: 09.50.0000
Build: 3378
higkoolincn100ce5:
verify_generator...OK
verify_generator...OK
verify_generator...OK
Don't forget to make sure that the name of the controller machine
is also in .rhosts
verify_generator...OK
verify_generator...OK
verify_generator...OK
verify_generator...OK
verify_generator...OK
verify_generator...OK
verify_generator...OK
_______________________________________________
Summary:
________
Vuser Host higkoo.kisops.org: OK
|
使用Controller连接,在“UNIX Environment Tab”下选择“Don't use RSH”即可连接Linux负载机。
若使用RSH连接,则负载机必须安装RSH并正确配置,正如检测过程中描述的
1
|
Don't forget to make sure that the name of the controller machine
|
补充,Linux下似乎只支持Web/Http协议的脚本。譬如WinSock协议,从名称上都知道只适合Windows:
1
|
Error (-81024): LR_VUG: The
'WinSock'
type
is not supported on
'LINUX'
platforms .
|
另外试了Java协议,确实不行,报错如下:
1
|
Error (-81024): LR_VUG: The
'General-Java'
type
is not supported on
'LINUX'
platforms .
|
依赖库:
1
|
yum -y --disablerepo=\* --enablerepo=AutoInstaller --nogpgcheck --skip-broken localinstall
/mnt/CentOS_Final/CentOS/compat-libstdc
++-33-3.2.3-61.i386.rpm
|
否则会报:
1
|
m_agent_daemon: error
while
loading shared libraries: libstdc++.so.5: cannot
open
shared object
file
: No such
file
or directory
|
注意hosts文件的配置,如果机器名和hosts里配置不一致也会导致LoadRunner启动失败,
这个名字是加压机自己的名字 利用hostname
用户root用户编辑/etc/hosts文件,加入以下内容:(这里加入的ip地址及主机名为loadrunner controller的地址)
192.168.1.169 VU-TEST
譬如:Error: Communication error: Failed to get the server host IP by calling the gethostbyname function.。
附上给LoadRunner定制的系统服务脚本(/etc/init.d/loadrunner):
1
2
3
4
5
6
7
8
9
10
|
#!/bin/bash
# /etc/init.d/loadrunner
# Loadrunner负载生成器服务
DAEMON=m_daemon_setup
ARGV=
"$@"
DIR=
/opt/HP/HP_LoadGenerator/bin/
USER=higkoo
UBIT=
"su - $USER -c "
$UBIT
"cd $DIR && ./$DAEMON $ARGV"
|
运行服务:
1
2
|
service loadrunner start
# m_agent_daemon ( 1808 ),
|
1. 先以root登陆要安装load generator的unix服务器。(目前仅支持uname=linux,SunOS,AIX,HP-UX)
2. 将LR的unix插件copy到服务器上并解压。
3. 运行install.sh 的脚本调起安装的wizard。 Next->Agree->Confirm Install->Finish (安装的log写在/tmp目录下)
4. 检查目录/opt/HP/HP_LoadGenerator (这个就是loadruner的服务器端插件的主目录了)
5. 设置设置几个环境变量
LR自带的是csh下的脚本,bash的脚本自己写,然后设置好切shell的时候自动source相应的脚本执行。
CSH下的脚本:
#!/bin/csh
setenv PRODUCT_DIR /opt/HP/HP_LoadGenerator
setenv M_LROOT $PRODUCT_DIR
if ( `uname` == SunOS ) then
setenv LD_LIBRARY_PATH ${M_LROOT}/bin
else if ( `uname` == Linux ) then
setenv LD_LIBRARY_PATH ${M_LROOT}/bin:${M_LROOT}/lib:/usr/lib
else if ( `uname` == AIX ) then
setenv LIBPATH ${M_LROOT}/bin
else if ( `uname` == HP-UX ) then
setenv SHLIB_PATH ${M_LROOT}/bin
endif
setenv DISPLAY 0.0
setenv PATH ${M_LROOT}/bin:$PATH
注意:
1.这里Loadrunner原始的脚本给LD_LIBRARY_PATH的设置的值是${M_LROOT}/bin,实则library应该指向安装目录的/opt/HP/HP_LoadGenerator/lib下。
因此给LD_LIBRARY_PATH设置值为${M_LROOT}/bin:${M_LROOT}/lib:/usr/lib (这里M_LROOT=/opt/HP/HP_LoadGenerator)
2.原始Loadrunner只提供了CSH的脚本,bash的自己写一份了,下面是自己写的
BASH的脚本
#/bin/bash
export PRODUCT_DIR=/opt/HP/HP_LoadGenerator
export M_LROOT=$PRODUCT_DIR
export LD_LIBRARY_PATH=$M_LROOT/bin:$M_LROOT/lib:/usr/lib
export DISPLAY='221.122.xx.xx:0.0'
export PATH=$PATH:$M_LROOT/bin
注:没按照原始文件根据uname判断来给LD_LIBRARY_PATH执行不同的值。
6. 在不同shell的配置里source这两个文件使得切换shell后执行 (以下方法仅适用于CENTOS-linux系统)
CSH
给文件/etc/csh.cshrc 最后增加 source /opt/HP/HP_LoadGenerator/env.csh
BASH
给文件/etc/profile 最后增加 source /opt/HP/HP_LoadGenerator/env.sh
7.切换SHELL 让source的程序文件执行生效或自己手动执行
8.检查loadrunner配置环境
进入/opt/HP/HP_Loadrunner下,运行verify_generator
[jaunty@localhost bin]$ ./verify_generator
===================================================
HP
Vuser Environment Verification Utility
===================================================
Product: HP LoadRunner 9.50
Version: 09.50.0000
Build: 3378
localhost.localdomain:
- 提示找不到libstdc++.so.5, 就是缺libstdc++5相关包
解决办法:
yum -y install libstdc++.so.5
/opt/HP/HP_LoadGenerator/bin/lrv/chk_thread_lmt: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
/opt/HP/HP_LoadGenerator/bin/lrv/limithost: line 134: [: : integer expression expected
verify_generator…OK
/opt/HP/HP_LoadGenerator/bin/lrv/chk_sems_lmt: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
/opt/HP/HP_LoadGenerator/bin/lrv/limithost: line 154: [: : integer expression expected
verify_generator…OK
verify_generator…OK
Don’t forget to make sure that the name of the controller machine
is also in .rhosts
Verify $M_LROOT …Failed
_____It was not possible to set the $M_LROOT from
_____the shell dot files. One of several things might be happening:
_____1) $M_LROOT is not set at all in the shell dot files.
_____2) There is some error in the shell dot files which stops their execution
_____ before it sets $M_LROOT.
_____3) There is conditional code in the shell dot files (most likely related to
_____ interactive and non interactive shells) and $M_LROOT is set
_____ only in one of the sections.
_____Aborting virtual user tests on host localhost.localdomain
verify_generator…OK
_______________________________________________
Summary:
________
Vuser Host localhost.localdomain: Failed
只要verify 都通过没有错就可以了。如果其他的没错仅有Verify $M_LROOT …Failed ,也可以继续使用。
9. 确认防火墙已经关闭
10.运行 m_daemon_setup -install 成功会获取一个 processid
PS -auxww| grep m_agent
可以看到启动起来的进程信息
11.然后在本地的pc测试机里打开controller,设置load generator 不用RSH ,连接后变为ready 成功.
12.如果本地connet不上,则先检查服务器和本地测试pc之间的网络互通性再检查两端的防火墙设置。如果还有问题则可在服务器的/tmp目录下看到很多Loadruner agent产生的log,根据时间定位,打开查看细节问题。
vim .bashrc
export PRODUCT_DIR=/opt/HP/HP_LoadGeneratorexport M_LROOT=/opt/HP/HP_LoadGenerator
export LD_LIBRARY_PATH=/opt/HP/HP_LoadGenerator/bin
export PATH=/opt/HP/HP_LoadGenerator/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin:/opt/HP/HP_LoadGenerator/bin:/usr/java/jdk/bin:/root/bin
export DISPLAY=localhost:0.0
export PRODUCT_DIR=/opt/HP/HP_LoadGenerator
export M_LROOT=/opt/HP/HP_LoadGenerator
export LD_LIBRARY_PATH=/opt/HP/HP_LoadGenerator/bin
export PATH=/opt/HP/HP_LoadGenerator/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin:/opt/HP/HP_LoadGenerator/bin:/usr/java/jdk/bin:/root/bin
export DISPLAY=localhost:0.0
export PRODUCT_DIR=/opt/HP/HP_LoadGenerator
export M_LROOT=/opt/HP/HP_LoadGenerator
export LD_LIBRARY_PATH=/opt/HP/HP_LoadGenerator/bin
export PATH=/opt/HP/HP_LoadGenerator/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin:/opt/HP/HP_LoadGenerator/bin:/usr/java/jdk/bin:/root/bin
export DISPLAY=localhost:0.0