## 修改jmeter.properties文件
# Remote Hosts - 此处填写对应linux负载机的ip地址,多台负载机ip地址通过逗号隔开
remote_hosts=192.168.175.135:1099
# RMI port to be used by the server (must start rmiregistry with same port)
server_port=1099
# the following property before starting the server:
server.rmi.localport=1099
# Set this if you don't want to use SSL for RMI
server.rmi.ssl.disable=true
## 修改system.properties文件。在最后一行加上当前windows主控机的ip地址
java.rmi.server.hostname=128.23.58.41
yum install -y yum-utils
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
##文档中仓库地址不在国内,访问较慢,此处可更改为别的镜像仓库,如:
##阿里云镜像仓:http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://magantt5.mirror.aliyuncs.com”]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
##查看当前docker版本
docker version
##运行测试用例看看docker是否安装成功。没有报错即安装成功
docker run hello-world
# jmbase。dockerfile文件
# 基础镜像文件openjdk:8
FROM openjdk:8-jre-slim
# 镜像创建者名字
MAINTAINER yourname
# jmeter版本。与windows的jmeter版本保持一致
ARG JMETER_VERSION=5.4.1
# 安装基本工具
RUN apt-get clean && apt-get update && apt-get -qy install wget telnet iputils-ping unzip
# 安装jmeter
RUN mkdir /jmeter \
&& cd /jmeter/ \
&& wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz \
&& tar -xvzf apache-jmeter-$JMETER_VERSION.tgz -C /jmeter
# 设置jmeter容器环境
ENV JMETER_HOME /jmeter/apache-jmeter-$JMETER_VERSION/
ENV PATH $JMETER_HOME/bin:$PATH
docker build -f ./jmbase -t jm:base .
# jm:slaves。dockerfile文件
# 使用jmbase作为基础镜像
FROM jm:base
MAINTAINER yourname
# 从JMeter Slaves/Server的容器中要公开的端口
EXPOSE 1099
# 启动容器 运行应用程序
ENTRYPOINT $JMETER_HOME/bin/jmeter-server \
-Dserver.rmi.localport=1099 \
-Dserver_port=1099 \
-Dserver.rmi.ssl.disable=true \
ENTRYPOINT $JMETER_HOME/bin/jmeter-server
)的情况下,进行挂载,手动更改配置文件使用,此处也不涉及。## 创建jm:slave镜像
[root@localhost mydata]# docker build -f ./jmslaves -t jm:slaves .
##创建完成后,查看对应镜像
[root@localhost mydata]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jm slaves 464afdad68b6 2 hours ago 416MB
jm master c6ba6cd0665c 6 months ago 416MB
jm base 5e1087e447bb 6 months ago 416MB
openjdk 8-jre-slim 54301e8a1f0d 2 years ago 194MB
[root@localhost mydata]# docker run -it -d --name jmeter-slave -p 1099:1099 jm:slaves
## 当步骤2中jmeter-slave的dockerfile没有指定容器内运行环境时,手动挂载
## docker run -it -d --name jmeter-slave -v /mydata/jmslave01/jmeter/apache-jmeter-5.4.1:/jmeter/apache-jmeter-5.4.1 -p 1099:1099 jm:slaves
## 修改jmeter.properties文件
# RMI port to be used by the server (must start rmiregistry with same port)
server_port=1099
# the following property before starting the server:
server.rmi.localport=1099
# Set this if you don't want to use SSL for RMI
server.rmi.ssl.disable=true
## 修改system.properties文件。在最后一行加上当前linux负载机的ip地址
java.rmi.server.hostname=192.168.175.135
通过挂载的方式启动容器,修改配置文件后,重启jmeter
docker restart jmeter-slave