Using SYSTEMD to implement Tomcat multiple instances

Source: Internet
Author: User

Environment: CentOS 7 x86_64


1. Installing the JDK

RPM-IVH jdk-8u60-linux-x64.rpm



2. Create a regular user

Getent Group Tomcat | | Groupadd-r tomcatgetent passwd Tomcat | | Useradd-r-d/opt-s/bin/nologin Tomcat


3. Download Tomcat 7

Cd/optwget Http://mirrors.ustc.edu.cn/apache/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gztar ZXVF APACHE-TOMCAT-7.0.64.TAR.GZMV apache-tomcat-7.0.64 tomcat01chown-r tomcat:tomcat Tomcat01tar zxvf APACHE-TOMCAT-7.0.64.TAR.GZMV apache-tomcat-7.0.64 tomcat02chown-r Tomcat:tomcat tomcat02


Two instances simultaneously listening on port 8080 will inevitably create a conflict, so it must be modified.

Sed-i ' s/8080/8081/g '/opt/tomcat01/conf/server.xmlsed-i ' s/8005/8001/g '/opt/tomcat01/conf/server.xmlsed-i ' s/8080 /8082/g '/opt/tomcat02/conf/server.xmlsed-i ' s/8005/8002/g '/opt/tomcat02/conf/server.xml

AJP is usually not used, it is closed here uniformly.

Sed-i '/8009/d '/opt/tomcat01/conf/server.xmlsed-i '/8009/d '/opt/tomcat01/conf/server.xml

The default operating mode for Tomcat under Linux is bio, which is very low performance, it is recommended to use APR or NIO,

This is changed to NIO, which is non-blocking IO, which performs better.

Sed-i.bak ' s#http/1.1#org.apache.coyote.http11.http11nioprotocol# '/opt/tomcat01/conf/server.xmlsed-i.bak ' S#HTTP /1.1#org.apache.coyote.http11.http11nioprotocol# '/opt/tomcat02/conf/server.xml


3. Create a startup file

Cd/usr/lib/systemd/systemcat >tomcat01.service <<eof[unit]description=apache Tomcat 8After=network.target [Service] type=oneshotexecstart=/opt/tomcat01/bin/startup.shexecstop=/opt/tomcat01/bin/shutdown.shremainafterexit= Yesuser=tomcatgroup=tomcat[install]wantedby=multi-user.targeteof

tomcat02

Sed ' s/tomcat01/tomcat02/g ' tomcat01.service > Tomcat02.service


4. Start the service

Systemctl enable Tomcat01systemctl enable Tomcat02systemctl start Tomcat01systemctl start tomcat02


5. Review the process

PS aux |grep Tomcat



This article is from the "Focus on Linux Operations" blog, please be sure to keep this source http://purplegrape.blog.51cto.com/1330104/1702292

Using SYSTEMD to implement Tomcat multiple instances

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.