我們在K8S環境中部署了一個服務,想在線編譯一段代碼進行測試,把arthas導入進去之后,啟動arthas竟然找不到Pod中的Java進程,郁悶。。。
$ java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.4.4
[INFO] Can not find java process. Try to pass <pid> in command line.
Please select an available pid.
按官方的說明文檔描述,假如出現了找不到pid的情況,在當前目錄下應該會輸出相關的log,但是在pod中當前目錄下並沒有日志文件產生啊???問題跟下面參考鏈接中的問題基本類似;
按照有的博主的說法,如果使用openjdk,也會報這個問題,因為其沒有jps,arthas是用jps去找java進程的,使用oracle jdk即可;巧的是,我們pod的容器中使用的就是openjdk。。。
參考Arthas排查Kubernetes中的應用頻繁掛掉重啟問題 #561 一般來說容器中會在PID=1上啟動java或者其他的服務進程,所以在后面加上 1,再試試;
$ java -jar arthas-boot.jar 1
[INFO] arthas-boot version: 3.4.4
[INFO] Start download arthas from remote server: https://arthas.aliyun.com/download/3.4.4?mirror=center
[INFO] File size: 11.94 MB, downloaded size: 1.47 MB, downloading ...
[INFO] File size: 11.94 MB, downloaded size: 9.22 MB, downloading ...
[INFO] Download arthas success.
[INFO] arthas home: /tmp/.arthas/lib/3.4.4/arthas
[INFO] Try to attach process 1
[INFO] Attach process 1 success.
[INFO] arthas-client connect 127.0.0.1 3658
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki https://arthas.aliyun.com/doc
tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html
version 3.4.4
pid 1
time 2020-12-02 07:32:25
[arthas@1]$
因為arthas沒有主動找到Pod中的java進程,在手動指定之后,就可以了。。。