categories: [Tomcat8 cluster,Centos 7]
tags: [Tomcat8 cluster,Centos 7] ##
**I use centos7X64 minimal installation **CentOS-7-x86_64-Minimal-1708
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
Either turn off the firewall or join the release port
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 ~]#
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 ~]#
yum -y install wget
wget http://mirrors.shuosc.org/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz
tar -zxvf apache-tomcat-8.5.24.tar.gz
mv apache-tomcat-8.5.24/usr/local/tomcat8-node1
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
cp /usr/local/tomcat8-node1 /usr/local/tomcat8-node2
cp /usr/local/tomcat8-node1 /usr/local/tomcat8-node3
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
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
systemctl enable tomcat8-node1
systemctl enable tomcat8-node2
systemctl enable tomcat8-node3
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