Crear Clúster amb tomcat amb apache mod_proxy com a load balancer.

Començarem pel final: Optimització del Tomcat :

Copiant la info de : https://rimuhosting.com/knowledgebase/linux/java/libtcnative

Home > Support > HOWTO List > libtcnative install

In most cases we recomend using the mod_proxy /apache combination as a frontend to tomcat. However for those looking to squeeze extra performance out of a bare tomcat installation the following may be useful

Apache Portable Runtime (APR) and Tomcat

Per http://apr.apache.org/ Tomcat can use the Apache Portable Runtime to provide superior scalability, performance, and better integration with native server technologies.

Installing the JNI wrappers for APR used by Tomcat (libtcnative)

You can now grab the latest tcnative wrapper from http://tomcat.apache.org/native-doc/ and drop that into the tomcat libs folder (eg /usr/local/tomcat/libs).

We recommend you use the package install methods shown on the above link to obtain the libraries noted. Those should be available using either yum or apt-get depending on your installed distribution.

You should be able to just grab the jar file and drop that into the tomcat libs folder (check in case it is already present).

Remeber to restart tomcat to make that load the updated/new libraries. And check in the tomcat logs to confirm they have been imported correctly.

I seguim:

Segons: https://tomcat.apache.org/tomcat-10.0-doc/config/http.html

Cal utilitzar el connector? : Java Nio2 Connector NIO2

Instal·lació bàsica del tomcat a debian:

Instal·larem només el paquets tomcat9 necessaris…

apt-get install tomcat9 tomcat9-admin tomcat9-docs tomcat9-examples
apt-get install libtcnative-1
apt-get install ca-certificates-java
apt-get install libapr1 libaprutil1 libaprutil1-dbd-mysql libaprutil1-dbd-odbc libaprutil1-dbd-pgsql libaprutil1-dbd-sqlite3 libaprutil1-ldap libwinpr2-2
cd /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libtcnative-1.so

Nota recordatoria; De la documentació de Tomcat:

CATALINA_HOME and CATALINA_BASE

Throughout the documentation, there are references to the two following properties:

CATALINA_HOME: Represents the root of your Tomcat installation, for example /home/tomcat/apache-tomcat-9.0.10 or C:\Program Files\apache-tomcat-9.0.10.

CATALINA_BASE: Represents the root of a runtime configuration of a specific Tomcat instance. If you want to have multiple Tomcat instances on one machine, use the CATALINA_BASE property.

If you set the properties to different locations, the CATALINA_HOME location contains static sources, such as .jar files, or binary files. The CATALINA_BASE location contains configuration files, log files, deployed applications, and other runtime requirements.

En el cas de Debian:

CATALINA_HOME: /usr/share/tomcatX

CATALINA_BASE: /var/lib/tomcatX