最近在需要在雲主機上進行壓力測試,所以需要Linux的Agent。
一、安裝:教程可以百度,大概步驟如下:
1、Upload Linux.zip to 指定的機器
2、解壓,chmod 777 $Linux/installer.sh
3、執行Linux下的installer.sh (sudo權限)
按照提示安裝下去即可。
注:安裝完成后,在/opt/HP/HP_LoadGenerator/bin下所有目錄及子目錄均屬於非root用戶及非root用戶組。如果出現文件夾為root用戶組,文件為bin用戶,則也會出現Not all extension Dlls were loaded的問題,需要重新安裝。
二、環境變量配置(基於bsh)
1、在/opt/HP/HP_LoadGenerator/新增env.sh文件,內容如下:
#!/bin/bsh export PRODUCT_DIR="/opt/HP/HP_LoadGenerator" export M_LROOT="/opt/HP/HP_LoadGenerator" export LD_LIBRARY_PATH=$M_LROOT/bin:$M_LROOT/lib:/usr/lib export DISPLAY='0.0' export PATH=$PATH:${M_LROOT}/bin
2、修改該文件的使用屬性
chmod 777 env.sh
3、在環境變量中使用該文件,在/etc/profile 和/etc/bashrc 最后加入:
source /opt/HP/HP_LoadGenerator/env.sh
4、用戶重新登陸,檢查環境變量是否生效
echo $PRODUCT_DIR echo $M_LROOT echo $LD_LIBRARY_PATH echo $PATH
5、執行/opt/HP/HP_LoadGenerator/bin/verify_generator
提示各種glibc缺失,需要自行安裝。最特殊的是glibc++.so.5,需要手動單獨安裝。
特殊說明:此處提示${M_LROOT},${LD_LIBRART_PATH}找不到時,可以先忽略不管(前提步驟4的結果都正確)。
遇到的問題:
(1)/opt/HP/HP_LoadGenerator/bin/lrv/limithost: /opt/HP/HP_LoadGenerator/bin/lrv/chk_thread_lmt: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
sudo yum install glibc.i686
(2)/opt/HP/HP_LoadGenerator/bin/lrv/chk_thread_lmt: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
/opt/HP/HP_LoadGenerator/bin/lrv/limithost: line 134: [: : integer expression expected
sudo yum install libgcc-4.4.7-11.el6.i686.rpm
(3)/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
sudo yum install compat-libstdc++-33-3.2.3-69.el6.i686
6、關閉防火牆等其他安全通信策略
7、啟動linux agent 進程(在/opt/HP/HP_LoadGenerator/bin/下)。成功后可以看到進程號,如果失敗在/tmp下有個m_daemon***.log 文件去查看失敗原因。
./m_daemon_setup start
(1)/tmp/m_daemon***.log出現如下報錯:
18/06/2015 11:22:49 Error: Communication error: Failed to get the server host IP by calling the gethostbyname function. [MsgId: MERR-10344] 18/06/2015 11:22:49 Error: Two Way Communication Error: Function two_way_comm_create_acceptor failed. [MsgId: MERR-60999] 18/06/2015 11:22:49 Error: Failed to create "launchservice" server. [MsgId: MERR-29974] 18/06/2015 11:22:49 Warning: Extension liblauncher.so reports error -1 on call to function ExtPerThreadInitialize [MsgId: MWAR-10485] 18/06/2015 11:22:49 Error: Vuser failed to initialize extension liblauncher.so. [MsgId: MERR-10700]
- 先看下機器名稱:
# hostname
- 將上步驟獲取的機器名稱寫入/etc/hosts中即可。
三、controller連接、場景試跑,報錯:Not all extension Dlls were loaded
分析:開始以為本地Dll路徑不對,百度一下,HP的論壇里這個問題很多人提問,但回答都說是linux agent的配置錯誤。
下面就回過頭來看./verify_generator時產生的錯誤並徹底解決他們
1.${M_LROOT}找不到
解決 M_LROOT變量找不到的問題修改: /opt/HP/HP_LoadGenerator/bin/lrv/vusrchk中288行,將unset M_LROOT下移到289行后面
269 my_shell="/bin/$my_shell" 270 else 271 temp=`$my_shell -c ' echo MERCURY ' 2> /dev/null` 272 if [ "$temp" = "MERCURY" ];then 273 echo "Failed $trail" 274 remote_install=1 275 echo "_____Failed to run $my_shell. $trail" 276 exit 1 277 fi 278 fi 279 fi 280 281 if [ $found_ksh != 0 ]; then 282 ENV="$HOME/.profile" 283 export ENV 284 fi 285 286 echo $ECHO_N "Verify \$M_LROOT ...$ECHO_C" 287 save_m_lroot="$M_LROOT" 288 #unset M_LROOT 289 temp=`$my_shell -c ' echo MERCURY $M_LROOT ' 2> /dev/null` 290 unset M_LROOT 291 new_m_lroot=`echo $temp | $SED -e 's/.*MERCURY[ ]*\(.*\)/\1/'` 292 293 if [ "$new_m_lroot" = "" ]; then 294 echo "Failed $trail" 295 remote_install=1 296 echo "_____It was not possible to set the \$M_LROOT from $trail" 297 echo "_____the shell dot files. One of several things might be happening: $trail" 298 echo "_____1) \$M_LROOT is not set at all in the shell dot files. $trail" 299 echo "_____2) There is some error in the shell dot files which stops their execution $trail" 300 echo "_____ before it sets \$M_LROOT. $trail" 301 echo "_____3) There is conditional code in the shell dot files (most likely related to $trail" 302 echo "_____ interactive and non interactive shells) and \$M_LROOT is set $trail" 303 echo "_____ only in one of the sections. $trail" 304 echo "_____Aborting virtual user tests on host `$HOSTNAME` $trail"
2、找不到${LD_LIBRARY_PATH}
解決LD_LIBRARY_PATH找不到的問題:將/opt/HP/HP_LoadGenerator/bin/lrv/vusrchk中356行,改成357行內容。
348 case "$os_name" in 349 HP-UX) 350 temp=`$my_shell -c ' echo MERCURY $SHLIB_PATH ' 2> /dev/null` 351 ;; 352 AIX) 353 temp=`$my_shell -c ' echo MERCURY $LIBPATH ' 2> /dev/null` 354 ;; 355 SunOS|Linux) 356 #temp=`$my_shell -c ' echo MERCURY $LD_LIBRARY_PATH ' 2> /dev/null` 357 temp=`$my_shell -c ' echo MERCURY ${M_LROOT}/bin ' 2> /dev/null` 358 ;; 359 esac
3、解決找不到libdriver.so的問題
Verify running the product executables...Failed _____Failed to run the product executables. _____Error: mdrv: error while loading shared libraries: libdriver.so: cannot open shared object file: No such file or directory
(1) 先find下,看下libdriver.so所在目錄
[work@presstest3 bin]$ find . -name "libdriver.so" ./libdriver.so [work@presstest3 bin]$ pwd /opt/HP/HP_LoadGenerator/bin
(2)將該路徑加入/opt/HP/HP_LoadGenerator/bin/lrv/vusrchk 文件中
修改/opt/HP/HP_LoadGenerator/bin/lrv/vusrchk,在483行處再加入一次這個lib的路徑:export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/${M_LROOT}/bin
469 echo $ECHO_N "Verify that the product executables are run from \$M_LROOT/bin...$ECHO_C" 470 which_mdrv=`$my_shell -c 'which mdrv' | $AWK '{which_mdrv=$0} END{print which_mdrv}'` 471 if [ "$which_mdrv" != "$PRODUCT_DIR/bin/mdrv" ]; then 472 wrong_path=`echo $which_mdrv | $SED -e 's/\/mdrv//'` 473 echo "Failed $trail" 474 remote_install=1 475 echo "_____The product executables are run from $wrong_path $trail" 476 echo "_____and not from $PRODUCT_DIR/bin. $trail" 477 echo "_____Make sure that the PATH environment variable contains $trail" 478 echo "_____$PRODUCT_DIR/bin before $trail" 479 echo "_____$wrong_path. $trail" 480 exit 1 481 else 482 echo "OK $trail" 483 fi 484 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/${M_LROOT}/bin 485 486 echo $ECHO_N "Verify running the product executables...$ECHO_C" 487 rm -f /tmp/verify_mdrv_err.txt 488 if [ $found_ksh != 0 ]; then 489 $my_shell -c '(mdrv > /dev/null) 2> /tmp/verify_mdrv_err.txt' > /dev/null 490 else 491 $my_shell -c '(mdrv > /dev/null) >& /tmp/verify_mdrv_err.txt' > /dev/null 492 fi
至此./verfify_generator 已可以驗證通過。
啟動: ./m_daemon_setup start 執行成功。
四、再次使用Control驗證“Not all extension Dlls were loaded”,該問題消失。
It work!~~~
五、總結:
M_LROOT、LD_LIBRARY_PATH和libdriver.so找不到,主要原因是LR提供的/opt /HP/HP_LoadGenerator/bin/lrv/vusrchk腳本中代碼存在問題引起.寫在這里,方便各位測試同仁遇到問題時不會無厘頭的到處查問題,少走些彎路。當然我的代碼中使用寫死的辦法完全是“頭痛醫頭,腳痛醫腳”的方法,后續有時間時會繼續針對該代碼進行調整,以解決代碼通用性問題,歡迎各位點贊或拍磚!~