本文共 1356 字,大约阅读时间需要 4 分钟。
1.在tomcat的安装目录的bin文件夹的startup.sh的最后一行exec "$PRGDIR"/"$EXECUTABLE" start "$@" 之前加上下面的一段代码
export CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=118.194.246.76 -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=/usr/local/tomcat80/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/local/tomcat80/conf/jmxremote.access"
参数说明:-Djava.rmi.server.hostname=xxx.xxx.xxx.xxx 主机地址,我配置的是外网地址 -Dcom.sun.management.jmxremote.port=xxx 端口号、配置完端口号之后需要将此端口开放出来 可以使用命令:iptables -A INPUT -p tcp --d port 端口号 -j ACCEPT -Dcom.sun.management.jmxremote.authenticate=true 是否开启认证、false的时候可以不使用密码访问 -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=..
jmxremote相关文件在tomcat的conf目录创建
其中jmxremote.access文件的内容可以配置为: username1 readonly username2 readwrite
jmxremote.password文件可以配置为: username1 password1 username2 password2 将以上俩文件放在对应配置目录tomcat/conf/下 并且将以上俩个文件访问权限配置成: chmod 600 jmx*
2.注意localhost中配置的地址是否跟上面的hostname一致,可以使用命令hostname -i查看,如果现实127.0.0.1,则需要vi /etc/hosts文件,修改为上面步骤1中的hostname的值
3.步骤1中的port需要是防火墙允许的,iptables -A INPUT -p tcp --d port 端口号 -j ACCEPT 添加到防火墙允许范围,防火墙的关闭是 service iptables stop
4.本地window的jvisual工具便可以进行远程连接了。