...
And then paste the following script into the file, making sure that the script is adjusted so that:
- JAVA_HOME
...
- is the
...
- base installation of Java. If you don't know where this is, run the command:
Code Block |
---|
update-alternatives --list java |
This will give you the full path of the java program, for example: /usr/lib/jvm/temurin-11-jdk-amd64/bin/java
. The installation directory in this case is /usr/lib/jvm/temurin-11-jdk-amd64
.
- The memory settings (-Xms and -Xmx) on the line for CATALINA_OPTS are set as needed (this example assumes you are allocating 8GB of memory to tomcat); see Tomcat
...
- Planning for details of estimating Tomcat's memory allocation
...
- The location of the GC (Garbage Collection) log file, set in CATALINA_OPTS, is correct - in the examples below, this
/opt/tomcat/logs
Java 8
Code Block |
---|
[Unit] Description=Apache Tomcat Web Application Container After=network.target [Service] Type=forking Environment=JAVA_HOME=/usr/optlib/jdkjvm/jdk1.8.0_85/jretemurin-8-jdk-amd64 Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms8096M -Xmx8096M -server -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/opt/tomcat/logs/gc-%%t.log' Environment='JAVA_OPTS=-Djava.awt.headless=true' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh WorkingDirectory=/opt/tomcat User=tomcat Group=tomcat UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target |
...
Code Block |
---|
[Unit] Description=Apache Tomcat Web Application Container After=network.target [Service] Type=forking Environment=JAVA_HOME=/usr/optlib/jdkjvm/temurin-11-jdk-11.0.13+8amd64 Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms8096M -Xmx8096M -server -Xlog:gc=debug:file=/opt/tomcat/logs/gc-%%t.log:time,uptimemillis,tid' Environment='JAVA_OPTS=-Djava.awt.headless=true' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh WorkingDirectory=/opt/tomcat User=tomcat Group=tomcat UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target |
...