Application Server Setup

Lab Application Server Setup (Linux)


The Supercar-Trader application you will be working with in the labs is a simple Struts application which provides for an online supercar store which has some performance/code issues. The application is a Java WAR file that you will deploy on a Linux host where you have installed MySQL 5.7 and Apache Tomcat 9.0.50 using the instructions provided below.

You should use a different Linux host to run the application on (Do Not Use the same host/vm that you used to install the AppDynamics Platform on).

It is recommended that you use one of the following Linux host/vm types with the following resource requirements:

  • Amazon Linux 2 (AL2) 
  • CentOS 7
  • CPU: 2 Cores (Minimum)
  • Memory: 8 GB RAM (Minimum), 16 GB RAM (Recommended)
  • Storage: 40 GB (Minimum), 60 GB (Recommended)

You should ensure that the agents running on the Lab Application Server have connectivity to your AppDynamics Platform so they can establish a one-way outbound HTTP or HTTPS connection. The most common ports that need to be open to connect to an on-prem AppDynamics Platform are listed below:

Port Name Default
Controller primary port (HTTP) 8090
Controller SSL port (HTTPS) 8181
Events Service primary port (HTTP) 9080
Events Service SSL port (HTTPS) 9081
EUM server primary port (HTTP) 7001
EUM server SSL port (HTTPS) 7002

For more information about AppDynamics Platform ports, see the documentation found here


Please install a fresh copy of MySQL 5.7 and Tomcat 9.0.50 on your Linux host as per the instructions provided here and be sure to use the versions mentioned, otherwise, the application will not work and you will loose valuable time troubleshooting unnecessary problems.


You will be performing the following setup steps for the lab application dependencies:

  • Download Lab Artifacts Zip File
  • Install Java v1.8 
  • Install MySQL v5.7
  • Initialize Application Database
  • Install and Configure Tomcat v9.0.50
  • Install PhantomJS v2.1.1


Download Lab Artifacts Zip File

When you change ownership of the /opt/appdynamics directory in the next step, please ensure that you use the same OS user and group when you change ownership of the directory where you install Tomcat.

Before you download the lab artifacts zip file, use the commands below to create the directory where you’ll copy the file to.

cd /opt

sudo mkdir appdynamics

sudo chown -R [your-os-user]:[your-os-group] /opt/appdynamics

cd /opt/appdynamics

mkdir lab-artifacts

If wget is not already installed on your Linux host you can try using the command below to install it. (command may vary based on your Linux distro)

sudo yum install wget

You can use the link below to download the zip file and upload it to the directory you just created using the link below.

lab-artifacts.zip

Alternatively, you can download it directly to your Linux host using the commands below.

cd /opt/appdynamics/lab-artifacts

wget https://povplaybook.appdpartnerlabs.net/zip/lab-artifacts.zip

Once you have the zip file in the /opt/appdynamics/lab-artifacts directory, use the commands below to unzip the file.

cd /opt/appdynamics/lab-artifacts

unzip lab-artifacts.zip


Install Java v1.8

Use the command below to install Java 1.8 (command may vary based on your Linux distro)

sudo yum install java-1.8.0

Use the command below to validate the Java 1.8 install.

java -version

The output should look similar to this.

openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)


Begin Installing MySQL v5.7

Use the commands below to install MySQL 5.7 Community Version (assumes you already have wget installed)

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm

sudo yum install mysql-server


Resolving GPG Key Error

If you get a GPG public key error like the one seen below, then follow the next steps to resolve it.

Public key for mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm is not installed


 Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Create a new public key file using the commands below.

cd /tmp

touch mysql_pubkey.asc

Now use the link below to get the updated public key and copy it into the ‘mysql_pubkey.asc’ file you just created.

MySQL 5.7 Reference Manual

The contents of your saved ‘mysql_pubkey.asc’ file should look like the example below.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6
Comment: Hostname: pgp.mit.edu

mQINBGG4urcBEACrbsRa7tSSyxSfFkB+KXSbNM9rxYqoB78u107skReefq4/+Y72TpDvlDZL
mdv/lK0IpLa3bnvsM9IE1trNLrfi+JES62kaQ6hePPgn2RqxyIirt2seSi3Z3n3jlEg+mSdh
AvW+b+hFnqxo+TY0U+RBwDi4oO0YzHefkYPSmNPdlxRPQBMv4GPTNfxERx6XvVSPcL1+jQ4R
2cQFBryNhidBFIkoCOsz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C06eb0pSi8P/iy+dNnxrtiE
Nn9vkkA7AmZ8RsvPXYVeDCDSsL7UfhbS77r2L1qTa2aB3gAZUDIOXln51lSxMeeLtOequLME
V2Xi5km70rdtnja5SmWfc9fyExunXnsOhg6UG872At5CGEZU0c2Nt/hlGtOR3xbt3O/Uwl+d
ErQPA4BUbW5K1T7OC6oPvtlKfF4bGZFloHgt2yE9YSNWZsTPe6XJSapemHZLPOxJLnhs3VBi
rWE31QS0bRl5AzlO/fg7ia65vQGMOCOTLpgChTbcZHtozeFqva4IeEgE4xN+6r8WtgSYeGGD
RmeMEVjPM9dzQObf+SvGd58u2z9f2agPK1H32c69RLoA0mHRe7Wkv4izeJUc5tumUY0e8Ojd
enZZjT3hjLh6tM+mrp2oWnQIoed4LxUw1dhMOj0rYXv6laLGJ1FsW5eSke7ohBLcfBBTKnMC
BohROHy2E63Wggfsdn3UYzfqZ8cfbXetkXuLS/OM3MXbiNjg+ElYzjgWrkayu7yLakZx+mx6
sHPIJYm2hzkniMG29d5mGl7ZT9emP9b+CfqGUxoXJkjs0gnDl44bwGJ0dmIBu3ajVAaHODXy
Y/zdDMGjskfEYbNXCAY2FRZSE58tgTvPKD++Kd2KGplMU2EIFT7JYfKhHAB5DGMkx92HUMid
sTSKHe+QnnnoFmu4gnmDU31i
=Xqbo
-----END PGP PUBLIC KEY BLOCK-----

Import the new public key file using the commands below.

gpg --import mysql_pubkey.asc

sudo rpm --import mysql_pubkey.asc

Now run the installation again using the commands below. The installation should now succeed.

sudo yum install mysql-server


Finish Installing MySQL v5.7

Start the MySQL service using the command below.

sudo systemctl start mysqld

Verify the MySQL service.

service mysqld status

The output should look similar to this.

Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-07-08 17:16:33 UTC; 5 days ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 6099 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 6049 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 6102 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─6102 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Jul 08 17:16:28 ip-172-31-44-9.us-east-2.compute.internal systemd[1]: Starting MySQL Server...
Jul 08 17:16:33 ip-172-31-44-9.us-east-2.compute.internal systemd[1]: Started MySQL Server.

Secure MySQL - During the installation process, a temporary password is generated for the MySQL root user. Locate it in the mysqld.log with this command.

sudo grep 'temporary password' /var/log/mysqld.log

Make note of the password, which you will need in the next step to secure the installation and where you will be forced to change it. Execute the secure mysql installation tool with the command below.

mysql_secure_installation

Make sure the new password you enter next is Welcome1! otherwise the application will not be able to connect to the database.

Now enter the following.

New password: Welcome1!
Remove anonymous users? n
Disallow root login remotely? n
Remove test database and access to it? n
Reload privilege tables now? y


Initialize Application Database

Now we will run the database scripts that create the database schema, the tables, and the data for our application. Change directory to where the database scripts are located.

cd /opt/appdynamics/lab-artifacts/db-scripts

Use the following commands to run the database scripts.

mysql -u root -pWelcome1! < mysql-01.sql

mysql -u root -pWelcome1! < mysql-02.sql

mysql -u root -pWelcome1! < mysql-03.sql


Install and Configure Tomcat v9.0.50

Use the following commands to create the directory for Tomcat, download it, and install it. (assumes you already have wget installed)

cd /usr/local

sudo mkdir apache

cd /usr/local/apache

sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.50/bin/apache-tomcat-9.0.50.tar.gz

sudo tar -zxpvf apache-tomcat-9.0.50.tar.gz -C /usr/local/apache

When you change ownership of the /usr/local/apache directory in the next step, please ensure that you use the same OS user and group you used when changing ownership of the /opt/appdynamics directory previously.

Use the command below to change ownership of the Tomcat directory structure.

sudo chown -R [your-os-user]:[your-os-group] /usr/local/apache

Now rename the Tomcat install directory and set the required CATALINA_HOME environment variable using commands below.

mv apache-tomcat-9.0.50 apache-tomcat-9

echo "export CATALINA_HOME='/usr/local/apache/apache-tomcat-9/'" >> ~/.bashrc
source ~/.bashrc

By default no user or account is allowed to access to the Tomcat Manager Web Page and Admin Page. Use the command below to edit the file ”/usr/local/apache/apache-tomcat-9/conf/tomcat-users.xml”

vi /usr/local/apache/apache-tomcat-9/conf/tomcat-users.xml

Add the following lines to the end of the file just before the last XML tag you see in the file named </tomcat-users> and then save the file.

<!-- User linuxtechi who can access only manager section --> 
  <role rolename="manager-gui" /> 
  <user username="admin" password="welcome1" roles="manager-gui" /> 
  

By default no remote access is allowed for the Tomcat Manager Web Page. Use the command below to edit the file ”/usr/local/apache/apache-tomcat-9/webapps/manager/META-INF/context.xml”

vi /usr/local/apache/apache-tomcat-9/webapps/manager/META-INF/context.xml

Comment out the following lines for the Valve tag in the file as seen below and then save the file.

<!--  
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />  
-->

Start Tomcat using the commands below.

cd /usr/local/apache/apache-tomcat-9/bin

./startup.sh

Verify you can access the Tomcat Manager Web page from your browser.

http://{ip-address-or-hostname}:8080/manager/html

Enter the user name and password you added to the tomcat-users.xml file previously.

image

Now stop Tomcat using the commands below. (We’ll start it up again after we’ve applied the AppDynamics Java Agent in the next lab)

cd /usr/local/apache/apache-tomcat-9/bin

./shutdown.sh


Install PhantomJS v2.1.1

Use the commands below to install PhantomJS that will be needed to provide the load generation for the lab application.

cd /tmp

sudo yum install glibc fontconfig freetype freetype-devel fontconfig-devel wget bzip2
cd /tmp

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
cd /tmp

sudo tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/

sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin

Now use the command below to validat the install of PhantomJS

phantomjs --version

You should see output from the command like below.

[ec2-user@ip-172-31-44-9 phantomjs]$ phantomjs --version
2.1.1


Next

We’ll install the AppDynamics Java Agent and deploy the Supercar-Trader application in the Java Monitoring Lab.