如何在非GUI模式运行多个JMX文件?Linux环境运行故障求助
Got it, let's figure out why you're hitting that frustrating "Engine is busy" error when trying to run two JMeter tests in parallel. Here's what's going on and how to fix it:
What's Causing the Error?
The -r flag in your command tells JMeter to trigger tests on remote distributed testing nodes. By default, each remote JMeter server instance can only handle one test execution at a time. When you launch both commands simultaneously with &, the first test grabs the remote engine, and the second can't get access—hence the "busy" error.
Solutions Based on Your Use Case
Case 1: You're Running Tests Locally (No Remote Nodes)
If you don't actually need to use remote servers, just drop the -r flag. This will let each command spin up its own independent JVM instance without conflicting:
sudo $JMETER/jmeter -n -t $JMETER/test1.jmx > test1.log 2>&1 & sudo $JMETER/jmeter -n -t $JMETER/test2.jmx > test2.log 2>&1 &
Note: I added log redirection (> test1.log 2>&1) so you can debug issues later without losing output.
Case 2: You Need to Run Tests on Remote Nodes
If distributed testing is a requirement, you have a few options:
Option 1: Run Tests Serially
Wait for the first test to finish before starting the second using && instead of &:
sudo $JMETER/jmeter -n -r -t $JMETER/test1.jmx && sudo $JMETER/jmeter -n -r -t $JMETER/test2.jmx
This is the simplest fix if you don't need strict parallelism.
Option 2: Run Multiple Remote Server Instances (For Parallel Execution)
To run tests in parallel on remote nodes, you need to start multiple independent JMeter server instances on each remote machine, each using a unique port:
- On your remote node(s), start two server instances with different ports:
$JMETER/jmeter-server -Dserver.rmi.localport=1099 > remote1.log 2>&1 & $JMETER/jmeter-server -Dserver.rmi.localport=1100 > remote2.log 2>&1 & - From your local machine, target each unique server instance separately:
sudo $JMETER/jmeter -n -R your_remote_host:1099 -t $JMETER/test1.jmx > test1.log 2>&1 & sudo $JMETER/jmeter -n -R your_remote_host:1100 -t $JMETER/test2.jmx > test2.log 2>&1 &
Make sure your remote firewall allows traffic on both ports (1099 and 1100 in this example).
Option 3: Combine Tests Into a Single Plan (If Feasible)
If your two tests are related, you can merge them into one JMeter test plan with separate thread groups. Then you can run the entire plan once with -r, avoiding the conflict entirely.
Quick Additional Tips
- Avoid relying on
$JMETERwithsudo—the sudo environment might not have this variable defined. Use absolute paths instead (e.g.,/opt/apache-jmeter-5.6.3/bin/jmeter). - If you're running tests as root (via
sudo), ensure the JMeter directory has proper permissions for the root user.
内容的提问来源于stack exchange,提问作者litterbugkid

