我要评分
获取效率
正确性
完整性
易理解

Migrating from Tomcat to Tomcat

  1. Check that the JDK is installed.

    A Tomcat installation depends on the JDK. Therefore, before installing Tomcat, ensure that the JDK has been installed. For details about the compatibility between Tomcat and JDK versions, see the official document.

  2. Download the Tomcat source package of the target version and decompress it to the Tomcat installation directory on the target host.
    1
    2
    tar -zxvf apache-tomcat-8.5.100.tar.gz
    mv apache-tomcat-8.5.100 {src_tomcat_home}
    
  3. Modify the lib_mig.sh script and grant the execute permission on the script.
    1. Open the lib_mig.sh script.
      1
      vi lib_mig.sh
      
    2. Press i to enter the insert mode and add the following information to the lib_mig.sh file:
      src_path="{src_tomcat_path}"
      dst_path="{dst_tomcat_path}"
      filter_list="catalina.jar tomcat-api.jar tomcat-util.jar servlet-api.jar tomcat-i18n-ja.jar tomcat-jni.jar catalina-storeconfig.jar tomcat-websocket.jar jasper.jar tomcat-jdbc.jar annotations-api.jar catalina-tribes.jar websocket-api.jar jaspic-api.jar ecj-4.5.1.jar tomcat-i18n-fr.jar catalina-ha.jar tomcat-dbcp.jar jasper-el.jar jsp-api.jar tomcat-i18n-es.jar catalina-ant.jar tomcat-coyote.jar tomcat-util-scan.jar el-api.jar"
      exclude_pattern=""
      for file in $filter_list; do
      exclude_pattern+=" -not -name '$file'"
      done
      eval "find '$src_path/lib' -type f $exclude_pattern -exec cp {} '$dst_path/lib' \;"

      src_tomcat_path indicates the source Tomcat installation directory and dst_tomcat_path indicates the target Tomcat installation directory. Replace them with the actual paths.

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
    4. Grant the execute permission on the lib_mig.sh script and execute the script.
      The files that do not exist in filter_list in the tomcat/lib path on the source host are copied to the tomcat/lib directory on the target host.
      1
      2
      chmod 700 lib_mig.sh
      ./lib_mig.sh
      
  4. Migrate folders and extension files.
    • Copy the webapps, logs, temp, and work folders in the source Tomcat directory to the Tomcat directory on the target host.
      1
      cp -r {src_tomcat_path}/webapps {src_tomcat_path}/logs {src_tomcat_path}/temp {src_tomcat_path}/work {dst_tomcat_path}
      
    • Copy the .xml, .properties, and .policy files in the conf directory of the source Tomcat to the conf directory of the target Tomcat.
      1
      find {src_tomcat_path}/conf -type f \( -name "*.xml" -o -name "*.properties" -o -name "*.policy" \) -exec cp {} {dst_tomcat_path}/conf \;
      
  5. Start Tomcat.
    1
    2
    cd {dst_tomcat_path}/bin
    ./startup.sh
    
  6. Access http://IP_address:Port/ to access the Tomcat home page.