`
love19820823
  • 浏览: 935153 次
文章分类
社区版块
存档分类
最新评论

在linux Redhat as4上通过jsvc自动启动tomcat

 
阅读更多

最近在公司配置服务器集群,遇到了很多问题,在网上查了很多资料后基本都解决了 ,写出来与大家分享!

在linux上通过jsvc自动启动tomcat

一. 环境:
1.操作系统:redhat as 4
2.jdk: jdk1.5.0.12
3.jdk安装目录: /usr/java/jdk1.5.0.12
4.tomcat: tomcat5.5
5.tomcat安装目录: /usr/local/tomcat5.5

二.创建用户:
#groupadd tomcat
#useradd -s /sbin/nologin -g tomcat tomcat

三.修改目录所有者:
#chown -R tomcat:tomcat /usr/local/tomcat5.5

四.安装jsvc
#cd /usr/local/tomcat5.5/bin
#tar xvfz jsvc.tar.gz
#mv jsvc src
#cd src
#sh ./support/buildconf.sh
#chmod 755 configure
#./configure --with-java=/usr/java/jdk1.5.0.12
#make

五.修改启动文件
#vi ./native/Tomcat5.sh
改成如下内容:

#
# chkconfig: 345 87 13
# description: Tomcat Daemon
# processname: jsvc
# pidfile: /var/run/jsvc.pid
# config:
#
# Source function library.
# . /etc/rc.d/init.d/functions
#
# prog=tomcat
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#
#
# port="80" minProcessors="5" maxProcessors="75"
# enableLookups="true" redirectPort="8443"
# acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# You need a developement version of Tomcat (Apache Tomcat/4.1-dev)
#
# Adapt the following lines to your configuration

#!/bin/sh
##############################################################################
#
# Copyright 2004 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 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.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#
#
# port="80" minProcessors="5" maxProcessors="75"
# enableLookups="true" redirectPort="8443"
# acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java/jdk1.5.0.12
CATALINA_HOME=/usr/local/tomcat5.5
DAEMON_HOME=/usr/local/tomcat5.5/bin
TOMCAT_USER=tomcat

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/tomcat5.5

CATALINA_OPTS=
CLASSPATH=/
$JAVA_HOME/lib/tools.jar:/
$CATALINA_HOME/bin/commons-daemon.jar:/
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/src/jsvc /
-user $TOMCAT_USER /
-home $JAVA_HOME /
-Dcatalina.home=$CATALINA_HOME /
-Dcatalina.base=$CATALINA_BASE /
-Djava.io.tmpdir=$TMP_DIR /
-wait 10 /
-pidfile $PID_FILE /
-outfile $CATALINA_HOME/logs/catalina.out /
-errfile '&1' /
$CATALINA_OPTS /
-cp $CLASSPATH /
org.apache.catalina.startup.Bootstrap
#
# To get a verbose JVM
#-verbose /
# To get a debug of jsvc.
#-debug /
exit $?
;;

stop)
#
# Stop Tomcat
#
$DAEMON_HOME/src/jsvc /
-stop /
-pidfile $PID_FILE /
org.apache.catalina.startup.Bootstrap
exit $?
;;

*)
echo "Usage tomcat.sh start/stop"
exit 1;;
esac

六.拷贝启动文件
#cp ./native/Tomcat5.sh /etc/init.d/tomcat5
#chmod -c 777 /etc/init.d/tomcat5

七.添加服务
#chkconfig --add tomcat5
#chkconfig --level 345 tomcat5 on

八.完成,启动服务
#service tomcat5 start
这时重启系统,tomcat也就会自动启动了.

九.注意事项
1.启动文件Tomcat5.sh文件中的路径一定要正确,且文件前的注释不能删除,否则不能添加服务.
2.tomcat的安装目录的所有者一定要修改(#chown -R tomcat:tomcat /usr/java/tomcat5.5)
否则会出( Java HotSpot(TM) Client VM warning: Can't detect initial thread stack location - find_vma failed)错误信息.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics