在容器啟動(dòng)時(shí),tomcat的輸出日志信息如下;
創(chuàng)新互聯(lián)專注于企業(yè)成都全網(wǎng)營銷、網(wǎng)站重做改版、涿鹿網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、html5、商城開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)營銷網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為涿鹿等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
docker logs 5ddb9eeb4815
Using CATALINA_BASE:?? /opt/tomcat-8.5.11
Using CATALINA_HOME:?? /opt/tomcat-8.5.11
Using CATALINA_TMPDIR: /opt/tomcat-8.5.11/temp
Using JRE_HOME:??????? /opt/jdk1.8.0_73
Using CLASSPATH:?????? /opt/tomcat-8.5.11/bin/bootstrap.jar:/opt/tomcat-8.5.11/bin/tomcat-juli.jar
Tomcat started.
22-Jul-2019 06:12:52.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:??????? Apache Tomcat/8.5.11
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:????????? Jan 10 2017 21:02:52 UTC
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:???????? 8.5.11.0
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:?????????????? Linux
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:??????????? 3.10.0-514.el7.x86_64
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:????????? amd64
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:???????????? /opt/jdk1.8.0_73/jre
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:?????????? 1.8.0_73-b02
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:??????????? Oracle Corporation
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:???????? /opt/tomcat-8.5.11
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:???????? /opt/tomcat-8.5.11
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/tomcat-8.5.11/conf/logging.properties
22-Jul-2019 06:12:52.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
22-Jul-2019 06:12:52.300 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
22-Jul-2019 06:12:52.300 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
22-Jul-2019 06:12:52.300 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/tomcat-8.5.11
22-Jul-2019 06:12:52.300 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat-8.5.11
22-Jul-2019 06:12:52.300 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat-8.5.11/temp
22-Jul-2019 06:12:52.300 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
22-Jul-2019 06:12:52.566 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
22-Jul-2019 06:12:52.593 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
22-Jul-2019 06:12:52.606 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
22-Jul-2019 06:12:52.607 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
22-Jul-2019 06:12:52.611 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1015 ms
22-Jul-2019 06:12:52.663 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
22-Jul-2019 06:12:52.664 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.11
22-Jul-2019 06:12:52.682 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.5.11/webapps/ROOT
22-Jul-2019 06:13:09.698 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [16,530] milliseconds.
22-Jul-2019 06:13:09.795 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.5.11/webapps/ROOT has finished in 17,113 ms
22-Jul-2019 06:13:09.795 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.5.11/webapps/docs
22-Jul-2019 06:13:09.891 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.5.11/webapps/docs has finished in 96 ms
22-Jul-2019 06:13:09.891 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.5.11/webapps/examples
22-Jul-2019 06:13:10.384 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.5.11/webapps/examples has finished in 493 ms
22-Jul-2019 06:13:10.385 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.5.11/webapps/host-manager
22-Jul-2019 06:13:10.429 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.5.11/webapps/host-manager has finished in 43 ms
22-Jul-2019 06:13:10.429 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.5.11/webapps/manager
22-Jul-2019 06:13:10.470 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.5.11/webapps/manager has finished in 41 ms
22-Jul-2019 06:13:10.487 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
22-Jul-2019 06:13:10.494 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
22-Jul-2019 06:13:10.495 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 17883 ms
22-Jul-2019 06:15:15.904 INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
22-Jul-2019 06:15:15.905 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
22-Jul-2019 06:15:15.957 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
22-Jul-2019 06:15:16.008 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
22-Jul-2019 06:15:16.055 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
22-Jul-2019 06:15:16.056 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
22-Jul-2019 06:15:16.056 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
22-Jul-2019 06:15:16.060 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
進(jìn)入容器內(nèi)部查看其時(shí)間
本地的CST時(shí)區(qū),說明Docker與操作系統(tǒng)使用的是同一個(gè)時(shí)區(qū)
?說明: ?????
????? (1) UTC
整個(gè)地球分為二十四時(shí)區(qū),每個(gè)時(shí)區(qū)都有自己的本地時(shí)間。在國際無線電通信場合,為了統(tǒng)一起見,使用一個(gè)統(tǒng)一的時(shí)間,稱為通用協(xié)調(diào)時(shí)(UTC, Universal Time Coordinated)。
(2) GMT
格林威治標(biāo)準(zhǔn)時(shí)間 (Greenwich Mean Time)指位于英國倫敦郊區(qū)的×××格林尼治天文臺(tái)的標(biāo)準(zhǔn)時(shí)間,因?yàn)楸境踝游缇€被定義在通過那里的經(jīng)線。(UTC與GMT時(shí)間基本相同,本文中不做區(qū)分)
(3) CST
中國標(biāo)準(zhǔn)時(shí)間 (China Standard Time)
代碼如下:
GMT + 8 = UTC + 8 = CST
(4) DST
夏令時(shí)(Daylight Saving Time) 指在夏天太陽升起的比較早時(shí),將時(shí)鐘撥快一小時(shí),以提早日光的使用。(中國不使用)
是因?yàn)門omcat啟動(dòng)時(shí),使用了JVM啟動(dòng)時(shí)的默認(rèn)時(shí)區(qū)所致,難道JVM啟動(dòng)不是使用系統(tǒng)提供的默認(rèn)時(shí)區(qū)嗎?答案:不是的,默認(rèn)是UTC時(shí)區(qū)
基于這種現(xiàn)象,本人在容器中寫了測(cè)試的代碼:
public?class?Test{ ???public?static?void?main(String[]?args){ ??????System.out.println(new?java.util.Date()); ??????System.out.println(System.getProperty("user.timezone")); ???} }
進(jìn)行編譯,然后運(yùn)行
javac?-g?Test.java #?java?Test
看如下截圖:
正好相差8個(gè)小時(shí)
找到原因其實(shí)就好解決了
一是修改JVM啟動(dòng)提供的默認(rèn)時(shí)區(qū),二是修改Tomcat啟動(dòng)腳本
我這里選擇修改Tomcat啟動(dòng)腳本的參數(shù)
在$Tomcat_HOME/bin/catalina.sh 中添加如下:
export?JAVA_OPTS="$JAVA_OPTS?-server?-Dfile.encoding=UTF-8?-Duser.timezone=GMT+08"
最后啟動(dòng)Tomcat,正常,見如下:
方法二:
使用tzselect進(jìn)行進(jìn)行修改
# tzselect
?1) Africa
?2) Americas
?3) Antarctica
?4) Arctic Ocean
?5) Asia
?6) Atlantic Ocean
?7) Australia
?8) Europe
?9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
選擇5
Please select a country.
?1) Afghanistan?????????? 18) Israel??????????????? 35) Palestine
?2) Armenia?????????????? 19) Japan???????????????? 36) Philippines
?3) Azerbaijan??????????? 20) Jordan??????????????? 37) Qatar
?4) Bahrain?????????????? 21) Kazakhstan??????????? 38) Russia
?5) Bangladesh??????????? 22) Korea (North)???????? 39) Saudi Arabia
?6) Bhutan??????????????? 23) Korea (South)???????? 40) Singapore
?7) Brunei??????????????? 24) Kuwait??????????????? 41) Sri Lanka
?8) Cambodia????????????? 25) Kyrgyzstan??????????? 42) Syria
?9) China???????????????? 26) Laos????????????????? 43) Taiwan
10) Cyprus??????????????? 27) Lebanon?????????????? 44) Tajikistan
11) East Timor??????????? 28) Macau???????????????? 45) Thailand
12) Georgia?????????????? 29) Malaysia????????????? 46) Turkmenistan
13) Hong Kong???????????? 30) Mongolia????????????? 47) United Arab Emirates
14) India???????????????? 31) Myanmar (Burma)?????? 48) Uzbekistan
15) Indonesia???????????? 32) Nepal???????????????? 49) Vietnam
16) Iran????????????????? 33) Oman????????????????? 50) Yemen
17) Iraq????????????????? 34) Pakistan
選擇9
Please select one of the following time zone regions.
1) Beijing Time
2) Xinjiang Time
選擇1
The following information has been given:
??????? China
??????? Beijing Time
Therefore TZ='Asia/Shanghai' will be used.
Local time is now:????? Mon Jul 22 15:55:01 CST 2019.
Universal Time is now:? Mon Jul 22 07:55:01 UTC 2019.
Is the above information OK?
1) Yes
2) No
選擇1
# cp /etc/timezone /etc/timezone.bak
cat > /etc/timezone << EOF
Asia/Shanghai
EOF
將之前的catalina.sh腳本注釋掉,最后啟動(dòng)Tomcat,時(shí)區(qū)也是正常的
見下圖:
最后,可以將這些配置好的信息,重新打包成新鏡像,然后發(fā)布到repos中
網(wǎng)頁名稱:在容器中啟動(dòng)Tomcat時(shí),其日志時(shí)間與本地時(shí)間不一致
新聞來源:http://jinyejixie.com/article48/ghhdep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、電子商務(wù)、全網(wǎng)營銷推廣、標(biāo)簽優(yōu)化、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)