Java环境变量配置
#! /bin/bash
JAVA_HOME='/usr/java/jdk1.8.0_60'
# /etc/profile
# ~/.bash_profile
echo "" >> /etc/profile
echo "export JAVA_HOME=$JAVA_HOME" >> /etc/profile
echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile
echo "export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar" >> /etc/profile
source /etc/profile
echo `java -version`
Jmeter环境变量配置
#! /bin/bash
echo "" >> /etc/profile
JMETER_HOME='/root/lt/apache-jmeter-5.4.3'
echo "export JMETER_HOME=$JMETER_HOME" >> /etc/profile
echo "export PATH=\$PATH:\$JMETER_HOME/bin" >> /etc/profile
source /etc/profile
echo `jmeter -v`
slave节点jmeter工具和脚本准备
#! /bin/bash
export jm_zip="apache-jmeter-5.4.3.zip"
export jm_pkg="apache-jmeter-5.4.3"
echo '1. 判断~/lt目录是否存在 ,并进入 '
if [ -d "~/lt/" ];then
cd ~/lt/
else
mkdir -p ~/lt && cd ~/lt
fi
echo '==============================================='
echo '2. 将 jmeter工具和参数化数据放到~/lt目录下 '
if [ -f "/tmp/${jm_zip}" ];then
mv /tmp/${jm_zip} ./${jm_zip}
echo "将jmeter压缩包移动到~/lt目录下"
else
echo "/tmp/${jm_zip}文件不存在"
fi
if [ -f /tmp/test*.txt ];then
mv /tmp/test*.txt ./test1.txt
echo "将参数化数据移动到~/lt目录下"
else
echo "/tmp/test*.txt文件不存在"
fi
echo '==============================================='
echo '3. 安 装 upzip解 压 工 具 '
if ! [ -x "$(command -v unzip)" ]; then
echo 'password' | sudo -S yum install -y unzip
else
echo '已安装'
fi
echo '==============================================='
echo '4. 解 压 jmeter zip文 件 '
if [ ! -d "~/lt/${jm_pkg}" ];then
echo '开始解压 '
unzip ~/lt/${jm_zip}
else
echo '文件已解压 '
fi
echo '==============================================='
echo '5. 修 改 jmeter.properties配 置 '
sed -i '/#server.rmi.ssl.disable=false/a\server.rmi.ssl.disable=true' ~/lt/${jm_pkg}/bin/jmeter.properties
echo '==============================================='
echo '6. 将压测数据移动到bin目录下 '
if [ -f test1.txt ];then
mv test1.txt ~/lt/${jm_pkg}/bin/test1.txt
else
echo ""
fi
echo '==============================================='
echo '7. 请使用命令启动服务'
echo '==============================================='
echo `sh ~/lt/apache-jmeter-5.4.3/bin/jmeter-server`
echo '==============================================='