We have two Linux servers, each with one Tomcat application server. Both application servers must have access to one folder to up- and download files.
We will create a folder on the first server and enable access through the network on this server for the second server.
Operating System: RedHat Enterprise Linux 7
myAppServer1 - Server
vim /etc/exports
systemctl list-units *nfs-server*
# if 0 loaded units, you have to enable and start
systemctl enable nfs-server.service
systemctl start nfs-server.service
systemctl list-units *nfs-server*
exportfs -r
exportfs -s
vim /etc/fstab
vim /etc/auto.master
vim /etc/auto.misc
systemctl enable autofs.service
systemctl start autofs.service
su tomcat
ls -lisah /app/myApp/uploads
In my last post I set up a Tomcat application server in general, now I enable Tomcat manager app for deployment.
# Tomcat Users
mv /app/myApp/tomcat/conf/tomcat-users.xml /app/myApp/tomcat/conf/tomcat-users.xml_original
vim /app/myApp/tomcat/conf/tomcat-users.xml
vim/app/myApp/tomcat/conf/server.xml
# By default the Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit the Manager's context.xml file.
vim /app/myApp/tomcat/webapps/manager/META-INF/context.xml
<Server port="7010" shutdown="SHUTDOWN">
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="7011" />
<!-- Define an AJP 1.3 Connector on port 7012 -->
<Connector port="7012" protocol="AJP/1.3" secretRequired="false" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="myApp-dev">
<Host name="localhost" appBase="webapps" />
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
</Engine>
</Service>
</Server>
su myUser
# Java
cd /app/java
tar -xzf /app/files/OpenJDK8U-jre_x64_linux_hotspot_8u265b01.tar.gz
tar -xzf /app/files/OpenJDK11U-jre_x64_linux_hotspot_11.0.8_10.tar.gz
tar -xzf /app/files/OpenJDK15U-jre_x64_linux_hotspot_15_36.tar.gz
# myApp Tomcat
cd /app/myApp
tar -xzf /app/files/apache-tomcat-8.5.59.tar.gz
tar -xzf /app/files/apache-tomcat-9.0.39.tar.gz
# Certificate
cp /app/files/corporate_truststore.jks /app/certs/
# SAP JCO
cp /app/files/_sapjco3-64/3.0.19/linuxx86/libsapjco3.so /app/library/
cp /app/files/_sapjco3-64/3.0.19/linuxx86/sapjco3.jar /app/library/
Setup Tomcat
su myUser
# Symlink to actual Tomcat version
ln -s /app/ccp/apache-tomcat-8.5.59 /app/myApp/tomcat
# remove sample application
# but keep the Tomcat Manager app for deployment
rm -rf /app/myApp/tomcat/webapps/docs
rm -rf /app/myApp/tomcat/webapps/examples
rm -rf /app/myApp/tomcat/webapps/ROOT
# configure Tomcat
vim /app/myApp/tomcat/bin/setenv.sh
mv /app/myApp/tomcat/conf/server.xml /app/myApp/tomcat/conf/server.xml_original
vim /app/myApp/tomcat/conf/server.xml
# expand Classpath
vim /app/myApp/tomcat/conf/catalina.properties
# As root
vim /etc/systemd/system/tomcat.service
# enable script:
systemctl enable tomcat.service
# tomcat.service
# Systemd unit file for myApp tomcat
#
# To create clones of this service:
# Systemd unit file for tomcat
[Unit]
Description=myApp Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/app/myApp/tomcat/bin/startup.sh
ExecStop=/app/myApp/tomcat/bin/shutdown.sh
User=myUser
Group=myUser
[Install]
WantedBy=multi-user.target
Service control
Enable user myUser to control Tomcat services:
visudo -f /etc/sudoers
##################################################
## Allow user myUser to control (apache & tomcat) services
%myUser ALL=(root) NOPASSWD: /bin/systemctl
%myUser ALL=(root) NOPASSWD: /usr/sbin/service
Test Tomcat
For Tomcat testing I use my ShowHeaders app (GitHub). ShowHeaders is a minimalistic webapp that is not much more than a "Hello World", but it shows the HTTP headers, what is quite useful when testing reverse proxy integration.
I have to setup and configure a DEV server and afterwards the QA/staging and PROD servers.
I will download required software with my laptop and upload to DEV server into folder /app/files. For other servers I just want to copy this folder from the DEV server.
Technically it is possible to create a new logical volume inside volume group vg00, because there are > 76,5 GB unassigned and free storage.
But the vg00 is reserved for the Operating System and should not used for data from application.
Therefore the additional disk is needed for applicatin data.
Volume creation
Physical Volume with ~ 100 GB is attached to the server and added as /dev/sdb.
A volume group "vg_app" will be created with two logical volumes. One logical volume for logfiles, named "lv_logs" with 20 GB and the other with remaining free space, named "lv_app", for application data.
# create volume group
vgcreate -s 32M vg_app /dev/sdb
# create logical volume for logfiles
lvcreate -L 20G -n lv_log vg_app
# create logical volume for application data
lvcreate -l 100%VG -n lv_app vg_app
# show information
vgdisplay -v /dev/vg_app
mount -a