Centos7 install the correct posture of the Tomcat8 pseudo cluster and set the boot self-start practice notes


title: Centos7 installs the correct posture of Tomcat8 pseudo-cluster and sets the boot self-start practice notes

categories: [Tomcat8 cluster,Centos 7]
tags: [Tomcat8 cluster,Centos 7] ##

**I use centos7X64 minimal installation **CentOS-7-x86_64-Minimal-1708

Personal blog on github: Personal blog powered by hexo

Students who have not installed jdk, please move to the article of [centos7 install jdk8 in the correct posture and set the boot-up] article

1. Configure the firewall:

Either turn off the firewall or join the release port

1.1 Turn off the firewall directly###

systemctl stop firewalld.service #Stop firewall
systemctl disable firewalld.service #Prohibit firewall startup
firewall-cmd --state #View the default firewall status (notrunning will be displayed after it is turned off, and running after it is turned on)
[ root@localhost ~]# firewall-cmd --state
not running
[ root@localhost ~]#

1.2 Add release port###

firewall-cmd --zone=public--add-port=18080/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
firewall-cmd --zone=public--add-port=28080/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
firewall-cmd --zone=public--add-port=38080/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
firewall-cmd --reload #Refresh the firewall to take effect
firewall-cmd --zone=public--list-ports #View the firewall release port list
[ root@localhost ~]# firewall-cmd --zone=public--add-port=18080/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
success
[ root@localhost ~]# firewall-cmd --zone=public--add-port=28080/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
success
[ root@localhost ~]# firewall-cmd --zone=public--add-port=38080/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
success
[ root@localhost ~]# firewall-cmd --reload #Refresh the firewall to take effect
success
[ root@localhost ~]# firewall-cmd --zone=public--list-ports #View the firewall release port list
80 /tcp 8080/tcp 18080/tcp 28080/tcp 38080/tcp
[ root@localhost ~]#

2. Install wget

yum -y install wget

3. Download tomcat8

wget http://mirrors.shuosc.org/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz

4. Unzip##

tar -zxvf apache-tomcat-8.5.24.tar.gz

5. Move to /usr/local

mv apache-tomcat-8.5.24/usr/local/tomcat8-node1

6. Configure tomcat jdk environment variables##

vi /usr/local/tomcat8-node1/bin/catalina.sh

Add the following code in front of OS specific support.:

JAVA_HOME=/usr/local/java/jdk1.8.0_151
JRE_HOME=$JAVA_HOME/jre

7. Copy two copies of tomcat8-node1 and rename them to tomcat8-node2, tomcat8-node3

cp /usr/local/tomcat8-node1 /usr/local/tomcat8-node2
cp /usr/local/tomcat8-node1 /usr/local/tomcat8-node3

8. Modify tomcat8-node1, tomcat8-node2 and tomcat8-node3 ports in three places##

vi /usr/local/tomcat8-node1/conf/server.xml
vi /usr/local/tomcat8-node2/conf/server.xml
vi /usr/local/tomcat8-node3/conf/server.xml
< Server port="8005" shutdown="SHUTDOWN"><Connector port="8080" protocol="HTTP/1.1" redirectPort="8443"/><Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

**It is customarily changed to: **

tomcat8-node1:180051808018009
tomcat8-node2:280052808028009
tomcat8-node3:380053808038009

7. Configure tomcat8-node1, tomcat8-node2, tomcat8-node3 boot up##

in/usr/lib/systemd/Add tomcat8 in the system directory-node1.service,tomcat8-node2.service,tomcat8-node3.service file, the specific content is as follows:
vi /usr/lib/systemd/system/tomcat8-node1.service
[ Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
  
[ Service]
Type=oneshot
ExecStart=/usr/local/tomcat8-node1/bin/startup.sh
ExecStop=/usr/local/tomcat8-node1/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes

[ Install]
WantedBy=multi-user.target

vi /usr/lib/systemd/system/tomcat8-node2.service
[ Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
  
[ Service]
Type=oneshot
ExecStart=/usr/local/tomcat8-node2/bin/startup.sh
ExecStop=/usr/local/tomcat8-node2/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes

[ Install]
WantedBy=multi-user.target

vi /usr/lib/systemd/system/tomcat8-node3.service
[ Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
  
[ Service]
Type=oneshot
ExecStart=/usr/local/tomcat8-node3/bin/startup.sh
ExecStop=/usr/local/tomcat8-node3/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes

[ Install]
WantedBy=multi-user.target

8. Allow tomcat8-node1, tomcat8-node2, tomcat8-node3 to start on boot##

systemctl enable tomcat8-node1
systemctl enable tomcat8-node2
systemctl enable tomcat8-node3

9. tomcat8 common commands##

systemctl enable tomcat8-node1.service    //Boot tomcat

systemctl disable tomcat8-node1.service    //Disable boot tomcat

systemctl start tomcat8-node1.service    #Start tomcat

systemctl stop tomcat8-node1.service    #Close tomcat

systemctl restart tomcat8-node1.service   #Restart tomcat

systemctl status tomcat8-node1.service   #View status tomcat

systemctl enable tomcat8-node1.service   #Allow boot-up

Recommended Posts

Centos7 install the correct posture of the Tomcat8 pseudo cluster and set the boot self-start practice notes
Centos7 to install the correct posture of Tomcat8 and set the boot self-start practice notes
Centos7 activemq startup failure to solve the correct posture practice notes
Centos7 installation jdk8 correct posture practice notes
CentOS6.5 install Java 8 and Tomcat8
CentOS6.5 install Java 8 and Tomcat8
CentOS6.5 install Java 8 and Tomcat8
virtualBox install centos, and build tomcat
Centos install the latest version of cmake
Simple practice of RHCS cluster in CentOS6
Download of VM virtual machine and install centos7
How to install and uninstall tomcat on centos