Skip to main content

Configuring Tomcat as Service

Configuring Tomcat as Service

  • Till now we are starting or stopping the tomcat instance from the home through the catalina script.
  • We will not be able to start this through service or systemctl
  • In the previous sessions you might have seen that we have started this through service but it is a custom script written by me
  • Apart from that we can't directly use tomcat through service
  • Now let us see how to accomplish this.
  • For this we should have jvsc package installed on our CentOS/Redhat machine.
  • This package will help us to run the java services as daemons or services.
    • Install through YUM
     # yum install jsvc -y
    
    • If the packages are not available then we need to download and install from the source.
    NOTE: Please ensure that you have configured you JAVA_HOME before proceeding with the below.
     # wget http://www-eu.apache.org/dist//commons/daemon/source/commons-daemon-1.0.15-src.tar.gz
     # tar -xzvf commons-daemon-1.0.15-src.tar.gz
     # cd commons-daemon-1.0.15-src/src/native/unix
     # echo $JAVA_HOME
     # make
     # ./jsvc -help
    
  • Now we should have tomcat user and apache
# useradd tomcat
# groupadd apache
# usermod -G apache tomcat
  • Change the owner and group of the $CATALINA_HOME
Before doing this be sure tomcat is not running. Stop if it is running
# cd /opt
# chown -R tomcat:apache tomcat8
  • We need to create a file where our ENVIRONMENT variables can be setup for tomcat
# vi /etc/sysconfig/tomcat

CATALINA_HOME=/opt/tomcat8
JAVA_HOME=/opt/jdk8
JSVC=/usr/share/jsvc-src/commons-daemon-1.0.15-src/src/native/unix
  • Now we need to create a service file for tomcat
# vi /usr/lib/systemd/system/tomcat.service

[Unit]
Description=Tomcat WebServer
After=syslog.target network.target

[Service]
Type=forking
User=tomcat
EnvironmentFile=/etc/sysconfig/tomcat
ExecStart=/opt/tomcat8/bin/catalina.sh start
ExecStop=/opt/tomcat8/bin/catalina.sh stop

[Install]
WantedBy=multi-user.target
  • Enable the tomcat service
# systemctl enable tomcat.service
  • Start Tomcat
# systemctl start tomcat.service

Comments

Popular posts from this blog

Troubleshooting Tomcat using Catalina log

Troubleshooting Tomcat using Catalina log We can get the  catalina  logs in  $CATALINA_HOME/logs Here we'll have a  catalina.out We can see some huge info in that log file. If we want to what exactly happens since the start of tomcat then we need to log that into a new file. By default we have log rotation enabled on this logs. For now let us stop tomcat and nullify the catalina.out file and then start tomcat to have some new info in the catalina.out # service tomcat stop # cd $CATALINA_HOME/logs # :> catalina.out (or) cat /dev/null > catalina.out # ll catalina.out -rw-r----- 1 root root 0 Feb 18 16:19 catalina.out # service tomcat start # ll catalina.out -rw-r----- 1 root root 17341 Feb 18 16:21 catalina.out We can see the log being written after the start of tomcat. Now we can notice the instance giving some information about the starting of tomcat, about the configuration for the startup, path of the servlet instance for which the log is responsible for,

Red Hat Enterprise Virtualization Manager RHEL 7 – Part 2

I have just published  what is RHEV  is the first article to understand RHEV Better. In order to maintain multiple RHEV-Hosts from central place RHEV-Manager is required. RHEV-M will be used as central place to manage all RHEV-Hosts. In this Article We are going to see HowTo Install RHEV-M Red Hat Enterprise Virtualization Manager RHEL 7. Red Hat Enterprise Virtualization Management (RHEV-M) is a virtual management console built on Red Hat Enterprise Linux (RHEL). It interacts with individual RHEV-Hosts using the Virtual Desktop Server Manager (VDSM). A VDSM agent is running on each of the RHEV-H nodes. RHEV-M allows administrators to manage/control number of data centers and their network, compute and storage resources. In addition RHEV-M provides a central repository for storing virtual machines, disks, images and virtual machine snapshots. Install RHEV-M Hardware Requirements Hard Disk Space Minimum 50GB RAM Minimum 4GB – Max 2TB Dual Core or High Processor 1Gbps NIC Ca

RHVH 4.1 Installation Steps for Red Hat Virtualization Host

Red Hat Virtualization Host (RHVH 4.1) is installed using a special build ( Download Link )of Red Hat Enterprise Linux with only the packages required to host virtual machines. It uses an Anaconda installation interface based on the one used by Red Hat Enterprise Linux hosts, and can be updated through the Red Hat Virtualization Manager or via yum. Using the yum command is the only way to install additional packages and have them persist after an upgrade. In this article we are going to see RHVH 4.1 installation RHVH features a Web interface for monitoring the host’s resources and performing administrative tasks. Direct access to RHVH via SSH or console is not supported, so the Cockpit user interface provides a graphical user interface for tasks that are performed before the host is added to the Red Hat Virtualization Manager, such as configuring networking and deploying a self-hosted engine, and can also be used to run terminal commands via the  Tools > Terminal. Access the C