前几天应工作的要求,搞起了jmeter压力测试,因为暂时没有多余的linux机器,所以下面的所有操作都是在我本地安装的虚拟机上完成的,不过,并无区别。
主要实现的操作有:
- 在linux上安装jdk并设置环境变量
- 在linux上安装jmeter并设置环境变量
废话也不想多说了,直接贴脚本吧。
#! /bin/bashcd `dirname $0`BASE_PATH=`pwd`configfile=$BASE_PATH/config.inisource $configfileinstall_files=/usr/etc/installFile# install JDKjava -version 2>&1 > /dev/nullif [ $? -ne 0 ];then if [ ! -d $JDK_Install_Path ];then mkdir $JDK_Install_Path fi cp $install_files/jdk*.gz $JDK_Install_Path cd $JDK_Install_Path aaa=`pwd` echo "In $aaa" jdk_name=`ls -l $JDK_Install_Path | awk '/^-/ {print $NF}'` echo "JDK name : $jdk_name" tar -zxf $jdk_name if [ $? -eq 0 ];then javadir=`ls -l $JDK_Install_Path | awk '/^d/ {print $NF}'` echo "JDK dir : $javadir" jdk_home="$JDK_Install_Path/$javadir" echo "" >> /etc/profile echo "JAVA_HOME=$jdk_home" >> /etc/profile echo 'PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile echo 'CLASSPATH=.:$JAVA_HOME/lib/tools.jar' >> /etc/profile echo 'export JAVA_HOME PATH CLASSPATH' >> /etc/profile source /etc/profile sleep 1 java -version 2>&1 > /dev/null if [ $? -eq 0 ];then echo "JDK install completed!" else echo "JDK path error!" echo "Please manual installation, will exit from $ip." fi rm -f $JDK_Install_Path/jdk*.gz else echo "JDK install error." fielse echo "JDK has been installed."fi # install Jmeterjmeter -v 2>&1 > /dev/nullif [ $? -ne 0 ];then if [ ! -d $Jmeter_Install_Path ];then mkdir $Jmeter_Install_Path fi cp $install_files/apache-jmeter*.gz $Jmeter_Install_Path cd $Jmeter_Install_Path bbb=`pwd` echo "In $bbb" jmeter_name=`ls -l $Jmeter_Install_Path | awk '/^-/ {print $NF}'` echo "Jmeter name : $jmeter_name" tar -zxf $jmeter_name if [ $? -eq 0 ];then jmeterdir=`ls -l $Jmeter_Install_Path | awk '/^d/ {print $NF}'` echo "Jmeter dir : $jmeterdir" jmeter_path=$Jmeter_Install_Path/$jmeterdir echo "" >> /etc/profile echo "JMETER_HOME=$jmeter_path" >> /etc/profile echo 'CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH' >> /etc/profile echo 'PATH=$JMETER_HOME/bin/:$PATH' >> /etc/profile echo 'export JMETER_HOME CLASSPATH PATH' >> /etc/profile source /etc/profile sleep 1 jmeter -v 2>&1 > /dev/null if [ $? -eq 0 ];then echo "Jmeter install completed!" echo "JDK and Jmeter install completed." else echo "Jmeter path error!" echo "Please manual installation, will exit from $ip." fi rm -f $Jmeter_Install_Path/apache-jmeter*.gz else echo "Jmeter install error." fielse echo "Jmeter has been installed."ficd / rm -fr /usr/etc/installFilerm -fr /usr/SETUPif [ -f /usr/jmeter.log ];then rm -f /usr/jmeter.logfiif [ -f /usr/jmeter/jmeter.log ];then rm -f /usr/jmeter/jmeter.logfi
以上就是安装的脚本。
最近有点儿懒懒的,多多包涵。
转载请标明出处,喜欢或者有用的话,就给我点个赞吧!