[英]Profiling Java application in kubernetes
我想在我的 Kubernetes 集群上分析我的 play 應用程序。
我使用的是VisualVM,我采取的步驟如下:
使用以下參數運行我的播放應用程序:
"-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.port=1098"
我的圖像有apt-get install -y visualvm
kubectl port-forward <Container> 1098
我不確定我在這里做錯了什么。 在本地主機上運行應用程序時(不是通過 IDE,直接從啟動腳本)一切正常。
更新 1、部署和服務
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: myApp labels: name: myApp spec: replicas: 1 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: name: myApp labels: name: myApp spec: containers: - name: myApp image: ... args: ["-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.port=1098"] ports: - containerPort: 9000 env: ...
apiVersion: v1
kind: Service
metadata:
name: myApp
labels:
name: myApp
spec:
selector:
name: myApp
ports:
- port: 80
targetPort: 9000
更新 2 @marcospereira
文件->添加JMX連接-> localhost:1098
無法使用服務 jmx:rmi 連接到 localhost:1098...
它可以以與下面的 QA 相同的形式執行。
多個應用程序節點如何在 kubernetes 中公開 jmx?
請設置java.rmi.server.hostname
系統屬性。
"-Dcom.sun.management.jmxremote",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.port=1098"
"-Djava.rmi.server.hostname=127.0.0.1" #add
Jmx 連接到localhost:1098
。
我確認我可以連接。
您也必須添加 rmi 端口選項 -Dcom.sun.management.jmxremote.rmi.port=1098
您需要運行以下命令以正確方式轉發端口:
kubectl 端口轉發 ${pod_name} 1098:1098
在visualvm中,添加localhost:1098的jmx連接。
添加以下參數以在您的 java 選項中啟用 jmx 連接,
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1098
-Dcom.sun.management.jmxremote.rmi.port=1098
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=127.0.0.1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.