I am trying to make it run setenv.sh to load some JAVA_OPTS but is it not loading nothing. My Tomcat start a .war files using springboot for start my application. The problem here is that it is not loading correct timezone on java and it is not loading JMX and Prometheus exporters.
这是我的文件。
FROM openjdk:11-jre-slim
MAINTAINER Me
USER root
RUN rm -rf ${JAVA_HOME}/*src.zip
ENV JAVA_PKG=jdk-8u202-linux-x64.tar.gz
ENV CATALINA_PKG=apache-tomcat-9.0.55.tar.gz
ENV JAVA_HOME=/opt/jdk1.8.0_202
ENV CATALINA_HOME=/opt/apache-tomcat-9.0.55
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales
RUN sed -i -e 's/# pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=pt_BR.UTF-8
ENV LANG pt_BR.UTF-8
#RUN echo "America/Sao_Paulo" > /etc/timezone
ENV TZ=America/Sao_Paulo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#ENV TZ America/Sao_Paulo
ENV LANGUAGE pt_BR.UTF-8
ENV LC_ALL pt_BR.UTF-8
COPY ./java/${JAVA_PKG} /opt/
RUN tar -xzvf /opt/${JAVA_PKG} --directory=/opt/
RUN rm /opt/${JAVA_PKG}
COPY ./tomcat/${CATALINA_PKG} /opt/
RUN tar -xzvf /opt/${CATALINA_PKG} --directory=/opt/
RUN rm /opt/${CATALINA_PKG}
ENV PATH="$JAVA_HOME/bin:${PATH}"
ENV PATH="$CATALINA_HOME/bin:${PATH}"
# Create a group and user
#RUN addgroup -S tomcat_grp && adduser -S tomcat -G tomcat_grp - criar UID 1002 para facilitar as permissões de escrita no host
RUN groupadd tomcat_grp && useradd -r -u 1002 tomcat -g tomcat_grp
COPY ./lib/* ${CATALINA_HOME}/lib/
RUN chown -R tomcat:tomcat_grp ${CATALINA_HOME}
RUN chmod -R 777 ${CATALINA_HOME}
RUN chown -R tomcat:tomcat_grp ${JAVA_HOME}
RUN chmod -R 777 ${JAVA_HOME}
USER tomcat
EXPOSE 8080
USER root
#prometheus jmx exporter
RUN mkdir -p /opt/jmx_exporter
COPY ./tomcat/jmx_exporter/jmx_prometheus_javaagent-0.17.2.jar /opt/jmx_exporter
COPY ./tomcat/jmx_exporter/config.yaml /opt/jmx_exporter
#clean image
#CMD ["sh", "-c", "apt update"; "apt install wget -y"; "apt-get clean ; apt-get autoclean ; apt-get autoremove"]
RUN apt update && apt install wget -y; apt clean; apt autoclean; apt autoremove
#start tomcat
COPY startup.sh /usr/local/
CMD ["sh", "-c", "chmod a+x /opt/apache-tomcat-9.0.55/bin/catalina.sh; chmod a+x /opt/apache-tomcat-9.0.55/bin/setenv.sh; /opt/apache-tomcat-9.0.55/bin/setenv.sh; chmod a+x /usr/local/startup.sh ; /usr/local/startup.sh"]
#RUN chmod a+x /usr/local/startup.sh ; /usr/local/startup.sh
#CMD ["sh", "-c", "chmod a+x ${CATALINA_HOME}/bin/*.sh; chmod a+x /usr/local/startup.sh ; ${CATALINA_HOME}/bin/startup.sh"]
#COPY startup.sh /usr/local/
#CMD chmod a+x /usr/local/startup.sh
# Launch Tomcat on startup
#CMD /usr/local/startup.sh
这是我的编写堆栈中的一个服务:
tomcat2_ecops_reports_pabx:
build: *build
labels:
- reports_pabx
logging: *default-logging
container_name: ecops_reports_pabx_${CLIENT_NAME}_${VER}_${IMAGE_TAG}
restart: unless-stopped
# command: *command
volumes:
- ${LOCALTIME}
- ${PABXREPTS_PRD}:${POD_WEBAPPS}
- ${REPORTS}:${POD_WEBAPPS}/reports
- ${CONF_CTXT}/context_reports.xml:${CONF_CTXT}/context.xml
# environment:
# CATALINA_OPTS: "-Djava.rmi.server.hostname=$HOST_IP"
# JAVA_OPTS: "-javaagent:/opt/jmx_exporter/jmx_prometheus_javaagent-0.12.0.jar=9404:/opt/jmx_exporter/config.yaml \
# -Duser.timezone=America/Sao_Paulo"
ports:
- 9912:8088
- 8192:8191
- 9402:9404
networks: *networks
我在集装箱里找到了正确的时间:
root@b2ad0fe2338b:/# date
qua 04 jan 2023 19:31:53 -03
root@b2ad0fe2338b:/#
我在主机系统中获得了正确的时间:
[root@VM-L-13104 projeto_psv]# date
Wed Jan 4 19:31:42 -03 2023
穿刺针中的时间:
当前时间:2023年1月4日星期三20:31:35英国夏令时
这是Spring启动过程:
VM settings:
Max. Heap Size (Estimated): 2.52G
Ergonomics Machine Class: server
Using VM: Java HotSpot(TM) 64-Bit Server VM
04-Jan-2023 19:33:49.331 SEVERE [main] org.apache.tomcat.vault.util.PropertySourceVault.init Keystore password should be either masked or prefixed with one of {EXT}, {EXTC}, {CMD}, {CMDC}
org.apache.tomcat.vault.security.vault.SecurityVaultException: Keystore password should be either masked or prefixed with one of {EXT}, {EXTC}, {CMD}, {CMDC}
at org.apache.tomcat.vault.security.vault.PicketBoxSecurityVault.init(PicketBoxSecurityVault.java:168)
at org.apache.tomcat.vault.util.PropertySourceVault.init(PropertySourceVault.java:105)
at org.apache.tomcat.vault.util.PropertySourceVault.<init>(PropertySourceVault.java:82)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.tomcat.util.digester.Digester.<clinit>(Digester.java:104)
at org.apache.catalina.startup.Catalina.createStartDigester(Catalina.java:367)
at org.apache.catalina.startup.Catalina.parseServerXml(Catalina.java:608)
at org.apache.catalina.startup.Catalina.load(Catalina.java:709)
at org.apache.catalina.startup.Catalina.load(Catalina.java:746)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:305)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
04-Jan-2023 19:33:49.679 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.55
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Nov 10 2021 08:26:45 UTC
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.55.0
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-1160.80.1.0.1.el7.x86_64
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /opt/jdk1.8.0_202/jre
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_202-b08
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
04-Jan-2023 19:33:49.683 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /opt/apache-tomcat-9.0.55
04-Jan-2023 19:33:49.684 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /opt/apache-tomcat-9.0.55
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/apache-tomcat-9.0.55/conf/logging.properties
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dserver=tomcat
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djvm=tomcat
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dhttp.port=
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dajp.port=8119
04-Jan-2023 19:33:49.685 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dssl.port=8443
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dshutdown.port=8115
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UnlockExperimentalVMOptions
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseCGroupMemoryLimitForHeap
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:MaxRAMFraction=2
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headless=true
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=UTF-8
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -DjavaEncoding=UTF-8
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.net.preferIPv4Stack=true
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dsun.rmi.dgc.client.gcInterval=3600000
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dsun.rmi.dgc.server.gcInterval=3600000
04-Jan-2023 19:33:49.686 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dsun.lang.ClassLoader.allowArraySyntax=true
04-Jan-2023 19:33:49.687 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -DUseSunHttpHandler=true
04-Jan-2023 19:33:49.687 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dssl.SocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl
04-Jan-2023 19:33:49.687 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dssl.ServerSocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl
04-Jan-2023 19:33:49.687 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=8191
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.rmi.port=8191
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/apache-tomcat-9.0.55
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/apache-tomcat-9.0.55
04-Jan-2023 19:33:49.689 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/apache-tomcat-9.0.55/temp
04-Jan-2023 19:33:49.692 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
04-Jan-2023 19:33:50.555 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8088"]
04-Jan-2023 19:33:50.644 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1490] milliseconds
04-Jan-2023 19:33:50.707 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
04-Jan-2023 19:33:50.707 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.55]
04-Jan-2023 19:33:50.780 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/opt/apache-tomcat-9.0.55/webapps/probe.war]
Security framework of XStream not initialized, XStream is probably vulnerable.
04-Jan-2023 19:34:03.393 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/apache-tomcat-9.0.55/webapps/probe.war] has finished in [12,612] ms
04-Jan-2023 19:34:03.450 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/opt/apache-tomcat-9.0.55/webapps/reports.war]
04-Jan-2023 19:34:04.725 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
04-Jan-2023 19:34:04.731 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/apache-tomcat-9.0.55/webapps/reports.war] has finished in [1,281] ms
04-Jan-2023 19:34:04.743 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8088"]
04-Jan-2023 19:34:04.840 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [14195] milliseconds
This is a main part of my setenv.sh file:
JAVA_HOME=/opt/jdk1.8.0_202
TOMCAT_HOME=/opt/apache-tomcat-9.0.55
SERVER_NAME=tomcat
HOST_IP=10.1.1.144
# Language
LANG=pt_BR
#Custom Ports
#HTTP_PORT=80
#AJP_PORT=8119
SSL_PORT=8443
SHUTDOWN_PORT=8115
JMX_PORT=8191
# JMX Opts
CATALINA_OPTS="-Dcom.sun.management.jmxremote"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=$HOST_IP"
#Prometheus JMX Exporter
JAVA_OPTS="$JAVA_OPTS -javaagent:/opt/jmx_exporter/jmx_prometheus_javaagent-0.12.0.jar=9404:/opt/jmx_exporter/config.yaml"
#SET TIMEZONE IN JVM
JAVA_OPTS="$JAVA_OPTS -Duser.timezone=America/Sao_Paulo"
How can I tell it to load correctly my setenv.sh file? Is this something on spring config lacking configurations?
I tried a lot of things to start it using my VARs even putting then into catalina.sh and I have no positive results.
我需要加载那些应用程序,加载普罗米修斯和JMX,并让它在正确的时间工作。我所有的VAR都在一个真正安装的Tomcat上工作。
我做错了什么,拜托?
我想运行我的tomcat9服务器,用java加载一个正确的时区。它比当前时间多加载一个小时。我需要把JMX放在我的容器之外访问。我需要把这个容器状态导出到Prometheus。
2条答案
按热度按时间enxuqcxy1#
2mbi3lxu2#
巴西时区规则变更
您的问题似乎是Java报告了相同的时间,但在夏令时(我相信BRST=巴西利亚夏令时,即UTC-2)。
根据维基百科,Brazil stopped using daylight saving time在2019年。根据this page的变化是包括在Java 1.8.0_231,而你在Java 1.8.0_202。
如果可以的话,更新到Java 1.8.0_231或更高版本应该可以修复这种不一致性。