Install and Launch JMeter GUI on AWS EC2
Tags: aws, performance, testing, java
Published: 2022-12-31 16:01:54

<!-- wp:paragraph -->
<p>When you run performance tests using JMeter on cloud instances, you typically do not need to launch the user interface of JMeter. Especially if your CI/CD pipelines are designed properly, the JMeter scripts will be checked out from git repo for further execution. In some cases, you may need to open the user interface from a cloud instance for a quick edit or to validate the settings. In this blog article, we will see how to install and launch JMeter GUI on AWS EC2.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Prerequisites</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The following are the prerequisites to install and launch JMeter GUI on AWS EC2. </p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>an AWS Instance</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Java</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>JMeter</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>xauth</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Putty or Mobaxterm</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2>Installing Java and JMeter</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Spin up an Amazon Linux 2 EC2 instance and ssh into it. Instructions to launch EC2 are beyond the scope of this blog article. Once the ssh is successful, issue the commands below which will update the packages, install Java and JMeter.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>sudo yum update -y
sudo yum install java-17-amazon-corretto -y

# validate java
java -version

# download JMeter 5.5
wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.5.tgz

# download JMeter 5.5 checksum
sha512sum apache-jmeter-5.5.tgz

# validate checksum
if &#91;&#91; $(cat apache-jmeter-5.5.tgz.sha512 | awk '{print $1}') -eq $(sha512sum apache-jmeter-5.5.tgz | awk '{print $1}') ]] ; then echo "Valid checksum. Proceeding to extract."; else echo "Invalid Checksum, please download it from secured source." ; fi ;

# extracting JMeter
tar -xf apache-jmeter-5.5.tgz
rm apache-jmeter-5.5.tgz

# validate JMeter
cd apache-jmeter-5.5/bin/
./jmeter -v</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Congratulations! You have successfully installed Java and JMeter on AWS EC2.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>SSH Client Configuration</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The next step is to install MobaXterm or Putty. Installing MobaXterm and Putty is straightforward. Here are the links for <a href="https://mobaxterm.mobatek.net" target="_blank" rel="noreferrer noopener nofollow">MobaXterm </a>and <a href="https://www.putty.org" target="_blank" rel="noreferrer noopener">Putty</a>. Both MobaXterm and Putty have packed with X11 package.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In MobaXterm, go to S<strong>ettings &gt; Configuration</strong>, then click <strong>X11 </strong>tab to view the X11 settings.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9836,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/12/image-6.png"><img src="https://qainsights.com/wp-content/uploads/2022/12/image-6.png" alt="MobaXterm X11 Settings" class="wp-image-9836"/></a><figcaption class="wp-element-caption">MobaXterm X11 Settings</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In Putty, you need to enable X11 explicitly by navigating to <strong>Connection &gt; X11</strong>, then check <strong>Enable X11 forwarding</strong> as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9838,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/12/image-8.png"><img src="https://qainsights.com/wp-content/uploads/2022/12/image-8.png" alt="Putty X11 Settings" class="wp-image-9838"/></a><figcaption class="wp-element-caption">Putty X11 Settings</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Installing X and Launching J</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The next step is to install xauth in EC2. SSH into EC2 using either MobaXterm or Putty, then issue the commands below to install xauth and configure the DISPLAY parameter.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>sudo yum install xauth -y

export DISPLAY=localhost:10.0

# validate X11 forwarding
# this should print `<span style="background-color: initial; font-family: inherit; font-size: inherit; color: inherit;">X11Forwarding yes</span>`
sudo cat /etc/ssh/sshd_config | grep X11

# reboot
sudo reboot
</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>After rebooting successfully, ssh again, then navigate to <code>apache-jmeter-5.5/bin/</code>, then run <code>./jmeter</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It will launch the JMeter GUI as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9841,"sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-large"><a href="https://qainsights.com/wp-content/uploads/2022/12/image-9.png"><img src="https://qainsights.com/wp-content/uploads/2022/12/image-9-1024x713.png" alt="JMeter GUI on AWS EC2" class="wp-image-9841"/></a><figcaption class="wp-element-caption">JMeter GUI on AWS EC2</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Similarly, you can also leverage Putty to ssh into it, then launch the GUI.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Final Words</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As mentioned above, it is easy and straightforward to launch JMeter GUI on AWS EC2 for a quick edit. With this setup, there is no need to download the test plan locally then launch it using a local installation of JMeter. For macOS, you can use XQuartz.</p>
<!-- /wp:paragraph -->