- Java环境参考:http://visitor.blog.51cto.com/11247238/1956799
- Tomcat部署参考:http://visitor.blog.51cto.com/11247238/1956809
- 从官网下载Tomcat对应版本的catalina-jmx-remote.jar(这个使用Tomcat 7.0.81版本)
Tomcat下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.81/bin/apache-tomcat-7.0.81.tar.gz
catalina-jmx-remote.jar包下载完成后放到Tomcat的lib目录下
[[email protected] lib]# pwd /usr/local/tomcat/lib [[email protected] lib]# wget
- 在bin/catalina.sh添加如下内容(Windows环境catalina.bat文件)
[[email protected] lib]# cd /usr/local/tomcat/bin/ [[email protected] bin]# vim catalina.sh CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7090 -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.100.1 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=/usr/local/softinstall/tomcat/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/local/softinstall/tomcat/conf/jmxremote.access"
- 编辑访问授权文件
[[email protected] lib]# cd /usr/local/tomcat/conf/ [[email protected] conf]# vim jmxremote.access [[email protected] conf]# cat jmxremote.access monitorRole readonly controlRole readwrite
- 编辑密码文件
[[email protected] conf]# vim jmxremote.password [[email protected] conf]# cat jmxremote.password monitorRole tomcat controlRole tomcat
注意:密码文件应该是只读的,只能由Tomcat运行用户。
更改密码文件权限,否则汇报如下错误:
Error: Password file read access must be restricted: /usr/local/tomcat/conf/jmxremote.password
[[email protected] conf]# chmod 0400 jmxremote.password [[email protected] conf]# ll jmxremote.password -r-------- 1 root root 36 Aug 25 15:47 jmxremote.password
- 启动Tomcat
[[email protected] conf]# ../bin/startup.sh Using CATALINA_BASE: /usr/local/softinstall/tomcat Using CATALINA_HOME: /usr/local/softinstall/tomcat Using CATALINA_TMPDIR: /usr/local/softinstall/tomcat/temp Using JRE_HOME: /usr/local/softinstall/jdk1.7.0_79 Using CLASSPATH: /usr/local/softinstall/tomcat/bin/bootstrap.jar:/usr/local/softinstall/tomcat/bin/tomcat-juli.jar Tomcat started. [[email protected] conf]# netstat -nlput | grep java tcp 0 0 :::7090 :::* LISTEN 7329/java tcp 0 0 ::ffff:127.0.0.1:7005 :::* LISTEN 7329/java tcp 0 0 :::7080 :::* LISTEN 7329/java [[email protected] conf]# curl -I localhost:7080 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: text/html;charset=ISO-8859-1 Transfer-Encoding: chunked Date: Fri, 25 Aug 2017 08:58:54 GMT
Tomcat启动成功、JMX7090端口启动成功
- 在一台windows服务器上部署Java环境
在Jdk的安装目录bin目录下找到jvisualvm.exe (另一个工具为jconsole.exe也在bin目录下,这里使用jvisualvm工具)
C:\Program Files\Java\jdk1.8.0_131\bin
双击运行jvisualvm.exe
点击——远程——添加远程主机——在弹出的窗口中填写要远程主机的名——点击确定
应用程序——远程——选择之间添加的主机——右击——添加jmx连接——在弹出的窗口中填写连接信息——确定
连接成功
时间: 2024-10-07 05:29:46