搭建模擬環(huán)境:
操作系統(tǒng):centos7
內(nèi)存:1G
jdk:1.8.0_131
tomcat:8.0.48
環(huán)境準備我們這里就不直接演示了,直接配置tomcat的jmx
1、進入到tomcat的bin目錄下
# cd /opt/tomcat/apache-tomcat-8.0.48/bin/
2、編輯配置文件
# vim catalina.sh
3、在下圖中上面添加參數(shù)
參數(shù)添加后的樣子
3.1、此配置連接jmx不需要賬號密碼:
CATALINA_OPTS="$CATALINA_OPTS-Dcom.sun.management.jmxremote-Djava.rmi.server.hostname=192.168.100.117-Dcom.sun.management.jmxremote.port=9999-Dcom.sun.management.jmxremote.ssl=false-Dcom.sun.management.jmxremote.authenticate=false"
配置后的截圖:
參數(shù)說明:
hostname:是監(jiān)控tomcat所在服務器的ip地址
jmxremote.port:端口號,是要開啟的監(jiān)控端口號
jmxremote.ssl:是否要開啟ssl連接
authenticate:false表示監(jiān)控不需要用戶和密碼
3.2、需要配置用戶名、密碼:
CATALINA_OPTS="$CATALINA_OPTS-Dcom.sun.management.jmxremote-Djava.rmi.server.hostname=192.168.100.117-Dcom.sun.management.jmxremote.port=9999-Dcom.sun.management.jmxremote.ssl=false-Dcom.sun.management.jmxremote.authenticate=true-Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access"
配置后的截圖:
參數(shù)說明:
authenticate:為true開啟賬號驗證
access.file:權(quán)限文件路徑
password.file:密碼文件路徑
3.3、當沒有配置密碼驗證的時候,不需要此步操作,當啟用用戶、密碼驗證后需要操作此步驟
3.3.1、找到j(luò)dk安裝目錄
如果不知道安裝到目錄那個地方可以通過命令查找:
# java -verbose
3.3.2、切換到j(luò)dk目錄中
進入# cd jre/lib/management/
在文件目錄下會有jmxremote.access jmxremote.password.template文件,拷貝到tomcat的conf目錄下
# cp jmxremote.* /opt/tomcat/apache-tomcat-8.0.48/conf/
3.3.3、修改jmxremote.access文件
3.3.4、重命名密碼文件:
# mv jmxremote.password.template jmxremote.password
新聞熱點
疑難解答
圖片精選