tomcat6 无法在 SL6 上启动

tomcat6 无法在 SL6 上启动

今天上班时发现 tomcat6 无法启动。尝试使用以下命令停止并启动时:

 service tomcat6 stop ; > /var/log/tomcat6/catalina.out && service tomcat6 start && less +F /var/log/tomcat6/catalina.out

它报告OK启动了 tomcat,但使用 时ps,没有显示 tomcat 进程。 catalina.out 文件也没有显示任何内容,完全是空白的。查看 /var/log/tomcat6/tomcat6-initd.log 时,我看到每次尝试时都会重复两行:

/usr/sbin/tomcat6: line 60: ${2}: ambiguous redirect
/usr/sbin/tomcat6: line 30: ${2}: ambiguous redirect

查看 /usr/sbin/tomcat6,两行内容如下:

${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
  -classpath "$CLASSPATH" \
  -Dcatalina.base="$CATALINA_BASE" \
  -Dcatalina.home="$CATALINA_HOME" \
  -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
  -Djava.io.tmpdir="$CATALINA_TMPDIR" \
  -Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
  -Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
  org.apache.catalina.startup.Bootstrap start \
   >> ${2} 2>&1 &

第一行对于 60 和 30 是相同的。我的$JAVA_OPTS理解是:

JAVA_OPTS="-server -Xss128K -Xms3G -Xmx3G -XX:MaxPermSize=256M -Dambiguous.url=https://ambiguous.url.com"

据我所知(说实话,不确定该从哪里看),$CATALINA_OPTS它是空的,但我可能弄错了。有一点可以肯定,我没有调整它的值,并且确信该值与模糊重定向问题无关。

更新:通过将我们的 tomcat6 包更新到最新版本,我现在不会收到上述错误。事实上,/usr/sbin/tomcat6 文件在它之前指向的区域周围读取的内容完全不同:

  ${JAVACMD} $JAVA_OPTS $CATALINA_OPTS \
    -classpath "$CLASSPATH" \
    -Dcatalina.base="$CATALINA_BASE" \
    -Dcatalina.home="$CATALINA_HOME" \
    -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
    -Djava.io.tmpdir="$CATALINA_TMPDIR" \
    -Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties" \
    -Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" \
    org.apache.catalina.startup.Bootstrap start \
    >> ${CATALINA_BASE}/logs/catalina.out 2>&1 &
    if [ ! -z "$CATALINA_PID" ]; then
      echo $! > $CATALINA_PID
    fi

现在情况变得更加复杂,因为 tomcat6-initd.log 根本没有报告任何内容,但服务仍然无法启动。使用 运行 init 脚本会导致-x启动时出现以下输出:

# service tomcat6 start
+ '[' -r /lib/lsb/init-functions ']'
+ . /lib/lsb/init-functions
++ lsb_release -i -s
+ DISTRIB_ID=Scientific
++ basename /etc/init.d/tomcat6
+ NAME=tomcat6
+ unset ISBOOT
+ '[' t = S -o t = K ']'
+ '[' -x /sbin/runuser ']'
+ SU='/sbin/runuser -s /bin/sh'
+ TOMCAT_CFG=/etc/tomcat6/tomcat6.conf
+ '[' -r /etc/tomcat6/tomcat6.conf ']'
+ . /etc/tomcat6/tomcat6.conf
++ CATALINA_BASE=/usr/share/tomcat6
++ CATALINA_HOME=/usr/share/tomcat6
++ JASPER_HOME=/usr/share/tomcat6
++ CATALINA_TMPDIR=/var/cache/tomcat6/temp
++ JAVA_OPTS='-Xms3072m -Xmx3072m -Xss512m -XX:MaxPermSize=512m -server -Dambiguous.url=https://ambiguous.url.com'
++ TOMCAT_USER=root
++ SECURITY_MANAGER=false
++ SHUTDOWN_WAIT=30
++ SHUTDOWN_VERBOSE=false
++ CATALINA_PID=/var/run/tomcat6.pid
+ '[' -r /etc/sysconfig/tomcat6 ']'
+ . /etc/sysconfig/tomcat6
+ CONNECTOR_PORT=8080
+ TOMCAT_SCRIPT=/usr/sbin/tomcat6
+ TOMCAT_PROG=tomcat6
+ TOMCAT_USER=root
+ TOMCAT_LOG=/var/log/tomcat6/tomcat6-initd.log
+ RETVAL=0
+ RETVAL=0
+ case "$1" in
+ start
+ echo -n 'Starting tomcat6: '
Starting tomcat6: + '[' 0 '!=' 0 ']'
+ '[' -f /var/lock/subsys/tomcat6 ']'
+ '[' -f /var/run/tomcat6.pid ']'
+ read kpid
+ '[' -d /proc/ ']'
+ log_success_msg
+ /etc/redhat-lsb/lsb_log_message success
                                                           [  OK  ]
+ '[' Scientific = MandrivaLinux ']'
+ RETVAL=0
+ return
+ exit 0

如果我在 tomcat 工作的单独服务器(有多个虚拟机作为集群运行)上运行完全相同的设置,则输出如下:

# service tomcat6 start
+ '[' -r /lib/lsb/init-functions ']'
+ . /lib/lsb/init-functions
++ lsb_release -i -s
+ DISTRIB_ID=Scientific
++ basename /etc/init.d/tomcat6
+ NAME=tomcat6
+ unset ISBOOT
+ '[' t = S -o t = K ']'
+ '[' -x /sbin/runuser ']'
+ SU='/sbin/runuser -s /bin/sh'
+ TOMCAT_CFG=/etc/tomcat6/tomcat6.conf
+ '[' -r /etc/tomcat6/tomcat6.conf ']'
+ . /etc/tomcat6/tomcat6.conf
++ CATALINA_BASE=/usr/share/tomcat6
++ CATALINA_HOME=/usr/share/tomcat6
++ JASPER_HOME=/usr/share/tomcat6
++ CATALINA_TMPDIR=/var/cache/tomcat6/temp
++ JAVA_OPTS='-Xms3072m -Xmx3072m -Xss512m -XX:MaxPermSize=512m -server -Dambiguous.url=https://ambiguous.url.com'
++ TOMCAT_USER=root
++ SECURITY_MANAGER=false
++ SHUTDOWN_WAIT=30
++ SHUTDOWN_VERBOSE=false
++ CATALINA_PID=/var/run/tomcat6.pid
+ '[' -r /etc/sysconfig/tomcat6 ']'
+ . /etc/sysconfig/tomcat6
+ CONNECTOR_PORT=8080
+ TOMCAT_SCRIPT=/usr/sbin/tomcat6
+ TOMCAT_PROG=tomcat6
+ TOMCAT_USER=root
+ TOMCAT_LOG=/var/log/tomcat6/tomcat6-initd.log
+ RETVAL=0
+ RETVAL=0
+ case "$1" in
+ start
+ echo -n 'Starting tomcat6: '
Starting tomcat6:
+ '[' 0 '!=' 0 ']'
+ '[' -f /var/lock/subsys/tomcat6 ']'
+ export CATALINA_PID=/var/run/tomcat6.pid
+ CATALINA_PID=/var/run/tomcat6.pid
+ touch /var/run/tomcat6.pid
+ '[' 0 -eq 0 -a 0 -eq 0 ']'
+ chown root:root /var/run/tomcat6.pid
+ '[' 0 -eq 0 ']'
+ touch /var/log/tomcat6/tomcat6-initd.log
+ '[' 0 -eq 0 -a 0 -eq 0 ']'
+ chown root:root /var/log/tomcat6/tomcat6-initd.log
+ parseOptions
+ options=
++ awk '!/^#/ && !/^$/ { ORS=" "; print "export ", $0, ";" }' /etc/tomcat6/tomcat6.conf
+ options=' export  CATALINA_BASE="/usr/share/tomcat6" ; export  CATALINA_HOME="/usr/share/tomcat6" ; export  JASPER_HOME="/usr/share/tomcat6" ; export  CATALINA_TMPDIR="/var/cache/tomcat6/temp" ; export  JAVA_OPTS="-Xms3072m -Xmx3072m -Xss512m -XX:MaxPermSize=512m -server -Dambiguous.url=https://ambiguous.url.com" ; export  TOMCAT_USER="root" ; export  SECURITY_MANAGER="false" ; export  SHUTDOWN_WAIT="30" ; export  SHUTDOWN_VERBOSE="false" ; export  CATALINA_PID="/var/run/tomcat6.pid" ; '
+ '[' -r /etc/sysconfig/tomcat6 ']'
++ awk '!/^#/ && !/^$/ { ORS=" ";
                                           print "export ", $0, ";" }' /etc/sysconfig/tomcat6
+ options=' export  CATALINA_BASE="/usr/share/tomcat6" ; export  CATALINA_HOME="/usr/share/tomcat6" ; export  JASPER_HOME="/usr/share/tomcat6" ; export  CATALINA_TMPDIR="/var/cache/tomcat6/temp" ; export  JAVA_OPTS="-Xms3072m -Xmx3072m -Xss512m -XX:MaxPermSize=512m -server -Dambiguous.url=https://ambiguous.url.com" ; export  TOMCAT_USER="root" ; export  SECURITY_MANAGER="false" ; export  SHUTDOWN_WAIT="30" ; export  SHUTDOWN_VERBOSE="false" ; export  CATALINA_PID="/var/run/tomcat6.pid" ;  '
+ TOMCAT_SCRIPT=' export  CATALINA_BASE="/usr/share/tomcat6" ; export  CATALINA_HOME="/usr/share/tomcat6" ; export  JASPER_HOME="/usr/share/tomcat6" ; export  CATALINA_TMPDIR="/var/cache/tomcat6/temp" ; export  JAVA_OPTS="-Xms3072m -Xmx3072m -Xss512m -XX:MaxPermSize=512m -server -Dambiguous.url=https://ambiguous.url.com" ; export  TOMCAT_USER="root" ; export  SECURITY_MANAGER="false" ; export  SHUTDOWN_WAIT="30" ; export  SHUTDOWN_VERBOSE="false" ; export  CATALINA_PID="/var/run/tomcat6.pid" ;   /usr/sbin/tomcat6'
+ '[' 0 -eq 0 -a false = true ']'
+ '[' 0 -eq 0 ']'
+ /sbin/runuser -s /bin/sh - root -c ' export  CATALINA_BASE="/usr/share/tomcat6" ; export  CATALINA_HOME="/usr/share/tomcat6" ; export  JASPER_HOME="/usr/share/tomcat6" ; export  CATALINA_TMPDIR="/var/cache/tomcat6/temp" ; export  JAVA_OPTS="-Xms3072m -Xmx3072m -Xss512m -XX:MaxPermSize=512m -server -Dambiguous.url=https://ambiguous.url.com" ; export  TOMCAT_USER="root" ; export  SECURITY_MANAGER="false" ; export  SHUTDOWN_WAIT="30" ; export  SHUTDOWN_VERBOSE="false" ; export  CATALINA_PID="/var/run/tomcat6.pid" ;   /usr/sbin/tomcat6 start'
+ '[' 0 -eq 0 ']'
+ log_success_msg
+ /etc/redhat-lsb/lsb_log_message success
                                                           [  OK  ]
+ touch /var/lock/subsys/tomcat6
+ '[' Scientific = MandrivaLinux ']'
+ exit 0

为了更全面,start()函数内容/etc/init.d/tomcat6如下:

function start() {

   echo -n "Starting ${TOMCAT_PROG}: "
   if [ "$RETVAL" != "0" ]; then
     log_failure_msg
     return
   fi
   if [ -f "/var/lock/subsys/${NAME}" ]; then
        if [ -f "/var/run/${NAME}.pid" ]; then
            read kpid < /var/run/${NAME}.pid
#           if checkpid $kpid 2>&1; then
            if [ -d "/proc/${kpid}" ]; then
                log_success_msg
                if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
                    echo
                fi
                RETVAL="0"
                return
            fi
        fi
    fi
    # fix permissions on the log and pid files
    export CATALINA_PID="/var/run/${NAME}.pid"
    touch $CATALINA_PID 2>&1 || RETVAL="4"
    if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
      chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
    fi
    [ "$RETVAL" -eq "0" ] && touch $TOMCAT_LOG 2>&1 || RETVAL="4"
    if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
      chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
    fi
    parseOptions
    if [ "$RETVAL" -eq "0" -a "$SECURITY_MANAGER" = "true" ]; then
        $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security" \
            >> ${TOMCAT_LOG} 2>&1 || RETVAL="4"
    else

       [ "$RETVAL" -eq "0" ] && $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> ${TOMCAT_LOG} 2>&1 || RETVAL="4"
    fi
    if [ "$RETVAL" -eq "0" ]; then
        log_success_msg
        touch /var/lock/subsys/${NAME}
    else
        log_failure_msg "Error code ${RETVAL}"
    fi
    if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
        echo
    fi
}

答案1

在控制台上输入内容reboot,用额头用很大的力气按下回车键,问题就解决了。

相关内容