阅读背景:

在AWS中为具有连接问题的分布式测试设置JMeter

来源:互联网 

I have to do distributed testing using JMeter. The objective is to have multiple remote servers in AWS controlled by one local server send a file download request to another server in AWS.

我必须使用JMeter进行分布式测试。目标是让AWS中的多个远程服务器由一个本地服务器控制,将文件下载请求发送到AWS中的另一个服务器。

How can I set up the different servers in AWS?
How can I connect to them remotely?

如何在AWS中设置不同的服务器?如何远程连接它们?

Can someone provide some step by step instructions on how to do it?
I have tried several things but keep running into connectivity issues across networks.

有人可以提供一些有关如何操作的分步说明吗?我已经尝试了几件事,但一直遇到跨网络的连接问题。

3 个解决方案

#1


53  

We had a similar task and we ran into a bunch of issues as well. Here are the details of the whole process and what we did to resolve the issues we encountered. Hope it helps.

我们有类似的任务,我们遇到了一堆问题。以下是整个过程的详细信息以及我们为解决遇到的问题所做的工作。希望能帮助到你。

We needed to send requests from 5 servers located in various regions of the world. So we launched 5 micro instances in AWS, each in a different region. We chose the regions to be as geographically apart as possible.

我们需要从位于世界各地的5台服务器发送请求。因此,我们在AWS中启动了5个微实例,每个实例位于不同的区域。我们选择区域尽可能地在地理上分开。

Remote (server) JMeters config

Here is how we set up each instance.

以下是我们如何设置每个实例。

  1. Installed java:

    安装java:

    $ sudo apt-get update
    $ sudo apt-get install default-jre 
    
  2. Installed JMeter:

    已安装的JMeter:

    $ mkdir jmeter
    $ cd jmeter;
    $ wget ftp://apache.mirrors.pair.com//jmeter/binaries/apache-jmeter-2.9.tgz
    $ gunzip apache-jmeter-2.9.tgz;tar xvf apache-jmeter-2.9.tar
    
  3. Edited the jmeter.properties file in the /bin folder of the JMeter installation and uncomment the line containing the server.rmi.localport setting. We changed the port to 50000.

    编辑JMeter安装的/ bin文件夹中的jmeter.properties文件,并取消注释包含server.rmi.localport设置的行。我们将端口更改为50000。

    server.rmi.localport=50000
    
  4. Started JMeter server. Make sure the address and the port the server reports listening to are correct.

    启动JMeter服务器。确保服务器报告的地址和端口正确无误。

    $ cd ~/jmeter/apache-jmeter-2.9/bin
    $ vi jmeter-server
    

Local (client) JMeter config

Then we set up JMeter to run tests remotely on these instances on our local client machine:

然后我们设置JMeter在本地客户机上对这些实例远程运行测试:

  • Ensured to use the same version of JMeter as was running on the servers. Installed Java and JMeter as described above.
  • 确保使用与在服务器上运行的相同版本的JMeter。如上所述安装Java和JMeter。
  • Enabled remote testing by editing the jmeter.properties file that can be found in the bin folder of the JMeter installation. The parameter remote_hosts needed to be set with the public DNS of the remote servers we were connecting to.
  • 通过编辑可在JMeter安装的bin文件夹中找到的jmeter.properties文件启用远程测试。需要使用我们连接的远程服务器的公共DNS设置参数remote_hosts。
  • remote_hosts=54.x.x.x,54.x.x.x,54.x.x.x,54.x.x.x,54.x.x.x
  • remote_hosts = 54.x.x.x,54.x.x.x,54.x.x.x,54.x.x.x,54.x.x.x

We were now able to tell our client JMeter instance to run tests on any or all of our specified remote servers.

我们现在能够告诉客户端JMeter实例在任何或所有指定的远程服务器上运行测试。

Issues and resolutions

Here are the issues we encountered and how we resolved them:

以下是我们遇到的问题以及我们如何解决它们:

  1. The client failed with:

    客户失败了:

    ERROR - jmeter.engine.ClientJMeterEngine: java.rmi.ConnectException: Connection - refused to host: 127.0.0.1

    错误 - jmeter.engine.ClientJMeterEngine:java.rmi.ConnectException:Connection - 拒绝主机:127.0.0.1

    It was due to the server host returning the private IP address as its address because of Amazon NAT. We fixed this by setting the parameter RMI_HOST_DEF that the /usr/local/jmeter/bin/jmeter-server script includes in starting the server:

    这是由于服务器主机因为Amazon NAT而将私有IP地址作为其地址返回。我们通过设置/ usr / local / jmeter / bin / jmeter-server脚本在启动服务器时包含的参数RMI_HOST_DEF来修复此问题:

    RMI_HOST_DEF=-Djava.rmi.server.hostname=54.xx.xx.xx
    

    Now, the AWS instance returned the server’s external IP, and we could start the test.

    现在,AWS实例返回了服务器的外部IP,我们就可以开始测试了。

  2. When the server node attempted to return the result and tried to connect to the client, the server tried to connect to the external IP address of my local machine. But it threw a connection refused error:

    当服务器节点尝试返回结果并尝试连接到客户端时,服务器尝试连接到本地计算机的外部IP地址。但它抛出了连接拒绝错误:

    2013/05/16 12:23:37 ERROR - jmeter.samplers.RemoteListenerWrapper: testStarted(host) java.rmi.ConnectException: Connection refused to host: xxx.xxx.xxx.xx;

    2013/05/16 12:23:37错误 - jmeter.samplers.RemoteListenerWrapper:testStarted(host)java.rmi.ConnectException:连接拒绝主机:xxx.xxx.xxx.xx;

    We resolved this issue by setting up reverse tunnels at the client side.

    我们通过在客户端设置反向隧道来解决此问题。

    • First, we edited the jmeter.properties file in the /bin folder of the JMeter installation and uncommented the line containing the client.rmi.localport setting. We changed the port to 60000:

      首先,我们在JMeter安装的/ bin文件夹中编辑了jmeter.properties文件,并取消注释了包含client.rmi.localport设置的行。我们将端口更改为60000:

      client.rmi.localport=60000
      
    • Then we connected to each of the servers using SSH, and setup a reverse tunnel to port 60000 on the client.

      然后我们使用SSH连接到每个服务器,并在客户端上设置反向隧道到端口60000。

      $ ssh -i ~/.ssh/54-x-x-x.us-east.pem -R 60000:localhost:60000 [email protected]
      

    We kept each of these sessions open, as the JMeter server needs to be able to deliver the test results to the client.

    我们保持每个会话都打开,因为JMeter服务器需要能够将测试结果传递给客户端。

    • Then we set up the JVM_ARGS environment variable on the client, in the jmeter.sh file in the /bin folder:

      然后我们在客户端上的/ bin文件夹中的jmeter.sh文件中设置JVM_ARGS环境变量:

      export JVM_ARGS="-Djava.rmi.server.hostname=localhost"
      

    By doing this, JMeter will tell the servers to connect to localhost:60000 for delivering their results. This ends up being tunneled back to the client.

    通过这样做,JMeter将告诉服务器连接到localhost:60000以提供结果。这最终会被隧道传回客户端。

  3. The SSH connections to the servers kept dropping after staying idle for a little bit. To prevent that from happening, we added a parameter to each of the SSH tunnel set up directing the client to wait 60 seconds before sending a null packet to the server to keep the connection alive:

    在闲置一点之后,与服务器的SSH连接不断下降。为了防止这种情况发生,我们在每个SSH隧道设置中添加了一个参数,指示客户端等待60秒,然后将空数据包发送到服务器以保持连接处于活动状态:

    $ ssh -i ~/.ssh/54-x-x-x.us-east.pem -o ServerAliveInterval=60 -R 60000:localhost:60000 [email protected]
    

(.ssh/config version of all required SSH settings:

(.ssh / config所有必需的SSH设置版本:

 Host 54.x.x.x
   HostName 54.x.x.x
   Port 22
   User ubuntu
   ServerAliveInterval 60
   RemoteForward 127.0.0.1:60000 127.0.0.1:60000
   IdentityFile  ~/.ssh/54-x-x-x.us-east.pem
   IdentitiesOnly yes

Just use ssh 54.x.x.x after setting this up. )

设置完成后,只需使用ssh 54.x.x.x. )

#2


4  

I just went though this on openstack and found the same issues... no idea why the jmeter remoting documentation only covers half the required steps. You can do it without tunnels or touching the properties files.

我刚刚在openstack上找到了这个问题并且发现了同样的问题......不知道为什么jmeter远程处理文档只覆盖了所需步骤的一半。您可以在没有隧道或触摸属性文件的情况下执行此操作。

You need

你需要

  • All nodes to advertise their public IP - on AWS/OS this defaults to the private IP
  • 所有节点都要宣传他们的公共IP - 在AWS / OS上,这默认为私有IP
  • Ingress rules for the RMI port which defaults to 1099 - I use this
  • RMI端口的入口规则默认为1099 - 我使用它
  • Ingress rules for the RMI "local" port which defaults to dynamic. Below I use 4001 for the client and 4000 for servers. The port can be the same but note the properties are different.
  • RMI“本地”端口的入口规则默认为动态。下面我使用4001作为客户端,使用4000作为服务器。端口可以​​是相同的但注意属性是不同的。

If you are using your workstation as the client you probably still need tunnels. Above Archana Aggarwal has good tips for tunnels.

如果您使用工作站作为客户端,您可能仍需要隧道。 Archana Aggarwal上面有隧道的好建议。

Remote servers

Set java.rmi.server.hostname and server.rmi.localport inline or in the properties file.

在内联或属性文件中设置java.rmi.server.hostname和server.rmi.localport。

jmeter-server -Djava.rmi.server.hostname=publicip -Dserver.rmi.localport=4000

Sneaky server on client

You can also run one on the same machine as the client. For clarity I've set java.rmi.server.hostname but left server.rmi.localport as dynamic

您也可以在与客户端相同的计算机上运行一个。为清楚起见,我设置了java.rmi.server.hostname,但将server.rmi.localport保留为动态

jmeter-server -Djava.rmi.server.hostname=localip

Client

Set java.rmi.server.hostname and client.rmi.localport inline or in the properties file. Use -R etc like so:

在内联或属性文件中设置java.rmi.server.hostname和client.rmi.localport。像这样使用-R等:

jmeter -n -t Test.jmx -Rremotepublicip1,remotepublicip2 -Djava.rmi.server.hostname=clientpublicip -Dclient.rmi.localport=4001 -GmypropA=1 -GmypropB=2 -lresults.jtl

#3


0  

When you go for distributed testing using JMeter in AWS, I would suggest you to use docker - which will help us with jmeter test infrastructure very quickly. This way we can also ensure that same version of java and jmeter are installed in all the instances of amazon which is very important of JMeter distributed testing.

当您在AWS中使用JMeter进行分布式测试时,我建议您使用docker - 这将非常快速地帮助我们使用jmeter测试基础架构。这样我们还可以确保在所有亚马逊实例中安装相同版本的java和jmeter,这对JMeter分布式测试非常重要。

Ensure that - you set below properties and ports are open for jmeter-server. [they do not have to be 1099,50000 exactly]

确保 - 您为jmeter-server打开了以下属性和端口。 [他们不必完全是1099,50000]

server.rmi.localport=50000
server_port=1099
java.rmi.server.hostname=SERVER_IP

for client

对于客户

client.rmi.localport=60000

java.rmi.server.hostname=SERVER_IP - this step is very important as the container in aws instance will have their own IP address in the docker network - so master and slave can not communicate. So we explicitly set this property

java.rmi.server.hostname = SERVER_IP - 这一步非常重要,因为aws实例中的容器在docker网络中将拥有自己的IP地址 - 因此master和slave无法通信。所以我们明确设置了这个属性

More info:

更多信息:

https://www.testautomationguru.com/jmeter-distributed-load-testing-using-docker-in-aws/

https://www.testautomationguru.com/jmeter-distributed-load-testing-using-docker-in-aws/


分享到: