• CentOS7下利用systemd机制实现tomcat开机自启动


    参考https://www.cloudcared.cn/2173.html

    但是报错,无法启动:

    [root@god tomcat]# journalctl -xe
    Aug 20 11:23:04 xuegod67.cn polkitd[548]: Unregistered Authentication Agent for unix-process:4714:288082 (system bus n
    Aug 20 11:23:05 xuegod67.cn polkitd[548]: Registered Authentication Agent for unix-process:4731:288243 (system bus nam
    Aug 20 11:23:05 xuegod67.cn systemd[1]: Starting Tomcat8...
    -- Subject: Unit tomcat.service has begun start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit tomcat.service has begun starting up.
    Aug 20 11:23:05 xuegod67.cn startup.sh[4737]: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    Aug 20 11:23:05 xuegod67.cn startup.sh[4737]: At least one of these environment variable is needed to run this program
    Aug 20 11:23:05 xuegod67.cn systemd[1]: tomcat.service: control process exited, code=exited status=1
    Aug 20 11:23:05 xuegod67.cn systemd[1]: Failed to start Tomcat8.
    -- Subject: Unit tomcat.service has failed
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit tomcat.service has failed.
    -- 
    -- The result is failed.
    Aug 20 11:23:05 xuegod67.cn systemd[1]: Unit tomcat.service entered failed state.
    Aug 20 11:23:05 xuegod67.cn systemd[1]: tomcat.service failed.
    Aug 20 11:23:05 xuegod67.cn polkitd[548]: Unregistered Authentication Agent for unix-process:4731:288243 (system bus n
    

    又参考另外一篇博文:https://www.jianshu.com/p/f0f8458e1631
    setenv.sh,需要配置java环境

    # 设置JAVA_HOME
    export JAVA_HOME=/usr/local/jdk1.8.0_211
    export JRE_HOME=$JAVA_HOME/jre
    export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
    export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
    
    export CATALINA_HOME=/usr/local/tomcat
    export CATALINA_BASE=/usr/local/tomcat
    # 设置Tomcat的PID文件
    CATALINA_PID="$CATALINA_BASE/tomcat.pid"
    # 添加JVM选项
    JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
    

    这次成功了,记录一下

  • 相关阅读:
    如何使用dom拼接xml字符串(标准方式)
    javascript默认将数字类型的“002,00123”,作为整数,去掉前面的0
    java学习小记
    如何将div排成一行显示(默认垂直显示)
    【转】JDBC调用存储过程之实例讲解
    数组求和算法系列
    《12个球问题》分析
    C#类在什么时候分配内存
    C++请不要问我string s=”a”+”b”分配了几次内存
    算法两道百度笔试题
  • 原文地址:https://www.cnblogs.com/jasonwu/p/13659185.html
Copyright © 2020-2023  润新知