Deploy two atat7.0.40 and register them as services under Linux6

Source: Internet
Author: User
Linux6 under the deployment of 2 Tomcat 7.0.40 and registered into the service [root @ Tomcatconf] # cd/opt/[root @ Tomcatopt] # lltotal16drwxr-xr-x.85005004096Apr419: 52jdk1. 7.0 _ 21drwxr-xr-x.2rootroot4096Ma... deploy two Tomcat 7.0.40 in Linux6 and register it as a service [root @ Tomcat conf] # cd/opt/[root @ Tomcat opt] # lltotal 16drwxr-xr-x. 8 500 500 4096 Apr 4 jdk1.7.0 _ 21drwxr-xr-x. 2 root 4096 May 10 2012 rhdrwxr-xr-x. 9 root 4096 May 31 tomctomcatadrwxr-xr-x. 9 root r Oot 4096 May 31 TomcatB [root @ Tomcat opt] # ls/etc/init. d/Tomcat */etc/init. d/TomcatA/etc/init. d/TomcatB [root @ Tomcat opt] # ls/tmp/hsperfdata_root tomcatA_process_count.txt tomcatB_process_count.txt yum. log [root @ Tomcat opt] # chkconfig -- add TomcatA [root @ Tomcat opt] # chkconfig -- add TomcatB [root @ Tomcat opt] # chkconfig -- list | grep TomcatTomcatA 0: off 1: off 2: on 3: on 4: on 5: on 6: offTomcatB 0: off 1: off 2: on 3: on 4: on 5: on 6: off [root @ Tomcat bin] # more/etc/init. d/TomcatA #! /Bin/bash # chkconfig: 2345 10 90 # description: TomcatA serviceJAVA_HOME =/opt/jdk1.7.0 _ 21CATALINA_HOME =/opt/TomcatATOMCAT_START = $ CATALINA_HOME/bin/startup. shTOMCAT_STOP = $ CATALINA_HOME/bin/shutdown. sh # source function library .. /etc/rc. d/init. d/functions # check that networking is up. ["$ {NETWORKING}" = "no"] & exit 0 # check for tomcat scriptif [! -F $ CATALINA_HOME/bin/catalina. sh]; then echo "TomcatA not valilable... "exitfistart () {echo-n" Starting TomcatA: "daemon $ TOMCAT_START echo touch/var/lock/subsys/tomcat} stop () {ps ax -- width = 1000 | grep "/opt/TomcatA/temp [o] rg. apache. catalina. startup. bootstrap start "| awk '{printf $1"}' | wc | awk '{print $2}'>/tmp/tomcatA_process_count.txt read line </tmp/tomcatA_process_count.txt if [$ Line-gt 0]; then echo-n "TomcatA (pid" ps ax -- width = 1000 | grep "/opt/TomcatA/temp org. apache. catalina. startup. bootstrap start "| awk '{printf $1" "} 'echo-n") is running... "echo-n $" Shutting down TomcatA: "daemon $ TOMCAT_STOP rm-f/var/lock/subsys/tomcat. pid echo else echo "TomcatA is stopped" fi} restart () {stop start} status () {ps ax -- width = 1000 | grep "/opt/TomcatA/temp [o] Rg. apache. catalina. startup. bootstrap start "| awk '{printf $1"}' | wc | awk '{print $2}'>/tmp/tomcatA_process_count.txt read line </tmp/tomcatA_process_count.txt if [$ line-gt 0]; then echo-n "TomcatA (pid" ps ax -- width = 1000 | grep "/opt/TomcatA/temp org. apache. catalina. startup. bootstrap start "| awk '{printf $1" "} 'echo-n") is running... "echo else echo" TomcatA is stopped "fi} ca Se "$1" in start) start; stop) stop; restart) stop sleep 3 start; status) status; *) echo "Usage: tomcatA {start | stop | restart | status} "exit 1 esacexit 0 [root @ Tomcat bin] # [root @ Tomcat bin] # more/etc/init. d/TomcatB #! /Bin/bash # chkconfig: 2345 10 90 # description: TomcatB serviceJAVA_HOME =/opt/jdk1.7.0 _ 21CATALINA_HOME =/opt/TomcatBTOMCAT_START = $ CATALINA_HOME/bin/startup. shTOMCAT_STOP = $ CATALINA_HOME/bin/shutdown. sh # source function library .. /etc/rc. d/init. d/functions # check that networking is up. ["$ {NETWORKING}" = "no"] & exit 0 # check for tomcat scriptif [! -F $ CATALINA_HOME/bin/catalina. sh]; then echo "TomcatB not valilable... "exitfistart () {echo-n" Starting TomcatB: "daemon $ TOMCAT_START echo touch/var/lock/subsys/tomcat} stop () {ps ax-width = 1000 | grep "/opt/TomcatB/temp [o] rg. apache. catalina. startup. bootstrap start "| awk '{printf $1"}' | wc | awk '{print $2}'>/tmp/tomcatB_process_count.txt read line </tmp/tomcatB_process_count.txt if [$ Line-gt 0]; then echo-n "TomcatB (pid" ps ax -- width = 1000 | grep "/opt/TomcatB/temp org. apache. catalina. startup. bootstrap start "| awk '{printf $1" "} 'echo-n") is running... "echo-n $" Shutting down Tomcat: "daemon $ TOMCAT_STOP rm-f/var/lock/subsys/tomcat. pid echo else echo "TomcatB is stopped" fi} restart () {stop start} status () {ps ax -- width = 1000 | grep "/opt/TomcatB/temp [o] Rg. apache. catalina. startup. bootstrap start "| awk '{printf $1"}' | wc | awk '{print $2}'>/tmp/tomcatB_process_count.txt read line </tmp/tomcatB_process_count.txt if [$ line-gt 0]; then echo-n "TomcatB (pid" ps ax -- width = 1000 | grep "/opt/TomcatB/temp org. apache. catalina. startup. bootstrap start "| awk '{printf $1" "} 'echo-n") is running... "echo else echo" TomcatB is stopped "fi} cas E "$1" in start) start; stop) stop; restart) stop sleep 3 start; status) status; *) echo "Usage: tomcatB {start | stop | restart | status} "exit 1 esacexit 0 [root @ Tomcat bin] modify setclasspath in the bin directory of the two tomcat servers. sh, add the JAVA_HOME environment variable [root @ Tomcat bin] # more/opt/ATA/bin/setclasspath. sh #! /Bin/sh # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. see the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except t in compliance with # the License. you may obtain a copy of the License ## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "as is" BASIS, # without warranties or conditions of any kind, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ----------------------------------------------------------------------------- # Set JAVA_H OME or JRE_HOME if not already set, ensure any provided settings # are valid and consistent with the selected start-up options and set up the # endorsed directory. # $ Id: setclassp. sh 1430568 2013-01-08 22: 08: 57Z schultz $ # export JAVA_HOME =/opt/jdk1.7.0 _ 21 # Make sure prerequisite environment variables are setif [-z "$ JAVA_HOME "-a-z" $ JRE_HOME "]; then if $ darwin; then # Bugzilla 54390 if [-x '/usr/libexec/java_home']; then export JAVA_HOME = '/usr/libexec/java_home' # Bugzilla 37284 (reviewed ). elif [-d "/System/Library/Frameworks/JavaVM. framework/Versions/CurrentJDK/Home "]; then export JAVA_HOME ="/System/Library/Frameworks/JavaVM. framework/Versions/CurrentJDK/Home "fi else JAVA_PATH = 'which java 2>/dev/nu Ll 'if ["x $ JAVA_PATH "! = "X"]; then JAVA_PATH = 'dirname $ JAVA_PATH 2>/dev/null 'jre_home = 'dirname $ JAVA_PATH 2>/dev/Null' fi if ["x $ JRE_HOME" = "x"]; then # XXX: shocould we try other locations? If [-x/usr/bin/java]; then JRE_HOME =/usr fi if [-z "$ JAVA_HOME"-a-z "$ JRE_HOME"]; then echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined" echo "At least one of these environment variable is needed to run this program" exit 1 when IIF [-z "$ JAVA_HOME" -a "$1" = "debug"]; then echo "JAVA_HOME shocould point to a JDK in order to run in debug mode. "exit 1 fiif [- Z "$ JRE_HOME"]; then JRE_HOME = "$ JAVA_HOME" fi # If we're re running under jdb, we need a full jdk. if ["$1" = "debug"]; then if ["$ os400" = "true"]; then if [! -X "$ JAVA_HOME"/bin/java-o! -X "$ JAVA_HOME"/bin/javac]; then echo "The JAVA_HOME environment variable is not defined correctly" echo "This environment variable is needed to run this program" echo "NB: JAVA_HOME shoshould point to a JDK not a JRE "exit 1 fi else if [! -X "$ JAVA_HOME"/bin/java-o! -X "$ JAVA_HOME"/bin/jdb-o! -X "$ JAVA_HOME"/bin/javac]; then echo "The JAVA_HOME environment variable is not defined correctly" echo "This environment variable is needed to run this program" echo "NB: JAVA_HOME shoshould point to a JDK not a JRE "exit 1 fi fifi # Don't override the endorsed dir if the user has set it previuslyif [-z" $ JAVA_ENDORSED_DIRS "]; then # Set the default-Djava. endorsed. dirs argument JAVA_ENDORSED_D IRS = "$ CATALINA_HOME"/endorsedfi # Set standard commands for invoking Java. _ RUNJAVA = "$ JRE_HOME"/bin/javaif ["$ os400 "! = "True"]; then _ RUNJDB = "$ JAVA_HOME"/bin/jdbfi [root @ Tomcat bin]
Related Article

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.