:.     Home     .:.     Cours     .:.     Faits divers     .:.     Blagues     .:.     Liens     .:.     Perso     .:

 

Installation de Tomcat8 sur CentOS7

 


 Il y a quelques jours j'ai essayé d'installer un tomcat en 30 min. Finalement, ça m'aura pris au moins 2h de temps. Je ne sais pas ce qui s'est passé.
Alors qu'il y a quelques années, j'étais un "spécialiste" optimiseur de plusieurs installations de Tomcat, me voici passant près d'une demi-journée entrain d'installer un tomcat tout simple.

Du coup, je suis obligé de documenter pour ne pas me faire avoir la prochaine fois.

1- Installation du Java :

[root@shibboleth ~]# yum install java-1.8.0-openjdk

[root@shibboleth ~]# java -version

[root@shibboleth ~]# ln -s /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64 /usr/lib/jvm/java

2- Téléchargement et installation de Tomcat :

[root@shibboleth ~]# yum install wget

[root@shibboleth ~]# wget http://apache.mirror.rafal.ca/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.tar.gz

[root@shibboleth ~]# groupadd tomcat

[root@shibboleth ~]# useradd -s /bin/bash -g tomcat -d /opt/tomcat tomcat

[root@shibboleth ~]# tar zxvf apache-tomcat-8.5.15.tar.gz -C /opt/tomcat --strip-components=1

[root@shibboleth tomcat]# chgrp -R tomcat conf
[root@shibboleth tomcat]# chmod g+rwx conf
[root@shibboleth tomcat]# chgrp -R tomcat bin lib
[root@shibboleth tomcat]# chmod g+r conf/*
[root@shibboleth tomcat]# chown -Rv tomcat webapps/ work/ temp/ logs/

3- Lancement de Tomcat et notre fameux SystemD

[root@shibboleth tomcat]# vi /etc/systemd/system/tomcat.service

# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat/
Environment=CATALINA_BASE=/opt/tomcat/
Environment=CATALINA_OPTS=-server -XX:+UseParallelGC
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat
Group=tomcat

[Install]
WantedBy=multi-user.target

[root@shibboleth tomcat]# systemctl daemon-reload

[root@shibboleth tomcat]# systemctl start tomcat

[root@shibboleth tomcat]# systemctl -l status tomcat
[root@shibboleth tomcat]# journalctl -xe | cat
[root@shibboleth tomcat]# cat temp/tomcat.pid
[root@shibboleth tomcat]# ps aux | grep java

[root@shibboleth tomcat]# systemctl enable tomcat
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /etc/systemd/system/tomcat.service.

4- Un peu d'optimisation (pour une machine à 4G de RAM)

[root@shibboleth tomcat]# vi bin/setenv.sh

export CATALINA_OPTS="$CATALINA_OPTS -server"
export CATALINA_OPTS="$CATALINA_OPTS -Xms3072M"
exportCATALINA_OPTS="$CATALINA_OPTS -Xmx3072M"
exportCATALINA_OPTS="$CATALINA_OPTS -XX:+UseG1GC"


[root@shibboleth tomcat]# systemctl restart tomcat

[root@shibboleth tomcat]# tail -f /opt/tomcat/logs/Catalina.out


Sources :

http://www.tomcatexpert.com/blog/2011/11/22/performance-tuning-jvm-running-tomcat
https://www.mulesoft.com/tcat/tomcat-jvm
https://gist.github.com/terrancesnyder/986029/b8948a265733cb6f6baff12c266842600f310421

 


L'information, n'est-elle pas précieuse ? Partageons la tous ensemble !

 © Juin 2017
Roger YERBANGA
www.yerbynet.com