安裝並配置 ThingWorx Navigate > 更新 ThingWorx 服務以使用 Java 11
更新 ThingWorx 服務以使用 Java 11
如果您計劃在安裝或升級至 ThingWorx Navigate 9.1.0 之後升級至 Java 11,請執行下列步驟。
步驟 1:更新 ThingWorx-Foundation 服務
ThingWorx 說明中心」的搭配 Java 11 使用 ThingWorx Foundation 安裝程式主題提供更新 ThingWorx-Foundation 服務的指示。
步驟 2:更新 ThingWorx-IntegrationRuntime 服務
更新 ThingWorx-IntegrationRuntime 服務時,請根據您的作業系統執行下列步驟:
Windows 
事前準備
開始之前,請確定以下事項:
已安裝 Java 11。
已在 PATH 系統變數中設定 /bin 目錄。
已將 JAVA_HOME 環境變數設定為使用 Java 11 安裝目錄。
java.exe 檔案位於 Java 11 安裝目錄中。例如,C:\Program Files\Java\jdk-11.0.8\bin\java.exe
ThingWorx-Foundation 服務已更新為使用 Java 11。如需相關指示,請參閱本主題
步驟 1:確定所使用的 Java 版本
使用您環境中的 Process Explorer 來確定 nssm.exe 處理序所使用的 Java 版本。您可以從此處下載 Process Explorer。
1. 以管理員身份開啟指令提示。
2. 從指令提示視窗開啟 Process Explorer。舉例來說,
> C:\Users\Vagrant\Desktop\procexp64.exe
3. 在 Process Explorer 視窗中,找到 nssm.exe 處理序,然後連按兩下 java.exe
如此會開啟一個新內容視窗,其中會列出有關執行 nssm.exe 處理序所使用 java.exe 的詳細資訊。
4. 從內容視窗中,按一下 Image 標籤來識別所使用的 Java 版本。
如果使用的是 Java 11,那就完成了。不需要再執行其他任何步驟。如果使用的是其他任何版本的 Java,則請繼續下一部份:「步驟 2:更新 ThingWorx-IntegrationRuntime 服務」。
步驟 2:更新 ThingWorx-IntegrationRuntime 服務
1. 停止 Thingworx-IntegrationRuntime 服務。
2. 以管理員身份開啟指令提示。
3. 導覽至 ThingWorx Integration Runtime 安裝目錄下的 third-party 目錄。舉例來說,
> cd C:\Program Files (x86)\ThingWorxIntegrationRuntime\third-party
4. 執行下列操作來編輯 Thingworx-IntegrationRuntime 服務組態:
> nssm.exe edit Thingworx-IntegrationRuntime
Apache Tomcat Properties 視窗即會開啟。
5. 開啟 Application 標籤,然後編輯 Path,以針對 Java 11 使用 java.exe。例如,C:\Program Files\Java\jdk-11.0.8\bin\java.exe
6. 按一下 Edit service 以儲存您的變更。編輯成功的訊息會透過快顯視窗進行通知。
7. 啟動 Thingworx-IntegrationRuntime 服務。
8. 核對在 ThingWorx Integration Runtime 安裝目錄內 /IRLogs 資料夾下所建立的記錄檔是否列出已建立連線的記錄。
記錄檔位置範例:C:\Program Files (x86)\ThingWorxIntegrationRuntime\IRLogs\IntegrationRuntime-012144ff23af.log
記錄範例:
[vert.x-worker-thread-1] INFO c.t.i.ThingworxEdgeVerticle - #########
[vert.x-worker-thread-1] INFO c.t.i.ThingworxEdgeVerticle - Connection Established
[vert.x-worker-thread-1] INFO c.t.i.ThingworxEdgeVerticle - #########
9. 發佈此更新,然後您便可使用 Process Explorer 確認 Java 版本。詳細說明可在「步驟 1:確定所使用的 Java 版本」部份找到。
Linux 
事前準備
開始之前,請確定以下事項:
已安裝 Java 11
您已複製 Java 可執行檔所在 Java 11 安裝目錄的路徑。
您可以執行 alternatives --display java | grep 'family java-11' | cut -d' ' -f1。輸出應顯示 Java 可執行檔位置,例如:/usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64/bin/java。此時,您已複製用來配置 ThingWorx-IntegrationRuntime 服務的 /usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64
ThingWorx-Foundation 服務已更新為使用 Java 11。如需相關指示,請參閱本主題
更新 ThingWorx-IntegrationRuntime 服務
1. 停止 Thingworx-IntegrationRuntime 服務。
systemctl stop ThingWorx-Foundation.service
2. 備份位於 ThingWorx Integration Runtime 安裝目錄中 /scripts 資料夾下的 startup.sh 指令集。例如:
/opt/ThingWorxIntegrationRuntime/scripts/startup.sh.backup
3. 編輯 startup.sh 指令集,使其指向在「事前準備」部份中複製的 Java 11 安裝目錄。在此範例中,路徑已從 JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-0.el8_2.x86_64/jre 更新為 JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64
4. 執行下列指令:
# systemctl daemon-reload
5. 啟動 Thingworx-IntegrationRuntime 服務:
systemctl start Thingworx-IntegrationRuntime
6. 確認 Thingworx-IntegrationRuntime 服務是否正在使用 Java 11:
# systemctl status Thingworx-IntegrationRuntime
Thingworx-IntegrationRuntime.service - Thingworx-IntegrationRuntime
Loaded: loaded (/etc/systemd/system/Thingworx-IntegrationRuntime.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-10-07 16:08:43 UTC; 4s ago
Process: 11310 ExecStop=/bin/bash /opt/ThingWorxIntegrationRuntime/scripts/shutdown.sh (code=exited, status=0/SUCCE>
Process: 11336 ExecStart=/bin/bash /opt/ThingWorxIntegrationRuntime/scripts/startup.sh (code=exited, status=0/SUCCE>
Main PID: 11337 (java)
Tasks: 31 (limit: 17467)
Memory: 166.2M
CGroup: /system.slice/Thingworx-IntegrationRuntime.service
└─11337 /usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64/bin/java -Dsecret.management.config.file=/op>
Oct 07 16:08:41 pg-foundation-rhel8.vagrantup.com systemd[1]: Starting Thingworx-IntegrationRuntime...
Oct 07 16:08:41 pg-foundation-rhel8.vagrantup.com bash[11336]: Starting Thingworx-IntegrationRuntime service ...
Oct 07 16:08:43 pg-foundation-rhel8.vagrantup.com bash[11336]: Thingworx-IntegrationRuntime service started
Oct 07 16:08:43 pg-foundation-rhel8.vagrantup.com systemd[1]: Started Thingworx-IntegrationRuntime.
7. 移除備份的 startup.sh.backup 指令集。
8. 核對在 ThingWorx Integration Runtime 安裝目錄內 /IRLogs 資料夾下所建立的記錄檔是否列出已建立連線的記錄。
記錄檔位置範例:/opt/ThingWorxIntegrationRuntime/IRLogs/IntegrationRuntime-a268-012144ff23af.log
記錄範例:
[vert.x-worker-thread-1] INFO c.t.i.ThingworxEdgeVerticle - #########
[vert.x-worker-thread-1] INFO c.t.i.ThingworxEdgeVerticle - Connection Established
[vert.x-worker-thread-1] INFO c.t.i.ThingworxEdgeVerticle - #########
這是否有幫助?