Window下执行步骤:

D:\apache-tomcat-7.0.57\bin\catalina.bat

set CATALINA_OPTS=-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8899
-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

D:\apache-tomcat-7.0.57\conf\jmxremote.access

# Default access control entries:
# o The "monitorRole" role has readonly access.
# o The "controlRole" role has readwrite access and can create the standard
# Timer and Monitor MBeans defined by the JMX API. monitorRole readonly
controlRole readwrite \
create javax.management.monitor.*,javax.management.timer.* \
unregister

D:\apache-tomcat-7.0.57\conf\jmxremote.password

# In a typical installation, this file can be read by anybody on the
# local machine, and possibly by people on other machines.
# For # security, you should either restrict the access to this file,
# or specify another, less accessible file in the management config file
# as described above.
#
# Following are two commented-out entries. The "measureRole" role has
# password "QED". The "controlRole" role has password "R&D".

monitorRole tomcat
controlRole tomcat

启动Tomcat后,运行如下命令,检测配置效果(注意实际配置的端口号可能不同):

netstat -an | find "8899"

参考文章:

中文

  http://blog.csdn.net/caolaosanahnu/article/details/7617211

  http://blog.csdn.net/airobot008/article/details/3951524

StackOverflow

  http://stackoverflow.com/questions/516142/does-java-6-open-a-default-port-for-jmx-remote-connections

Oracle官网及博客

  https://docs.oracle.com/cd/E19340-01/820-6740/ggvud/index.html

  https://docs.oracle.com/javase/7/docs/technotes/guides/management/agent.html

  https://blogs.oracle.com/jmxetc/entry/connecting_through_firewall_using_jmx

Linux下执行步骤:

Additional Implementations
JMX Remote Lifecycle Listener - org.apache.catalina.mbeans.JmxRemoteLifecycleListener

This listener requires catalina-jmx-remote.jar to be placed in $CATALINA_HOME/lib. This jar may be found in the extras directory of the binary download area.

The JMX Remote Lifecycle Listener fixes the ports used by the JMX/RMI Server making things much simpler if you need to connect jconsole or a similar tool to a remote Tomcat instance that is running behind a firewall. Only these ports are configured via the listener. The remainder of the configuration is via the standard system properties for configuring JMX. For further information on configuring JMX see Monitoring and Management Using JMX included with the Java SDK documentation.

This listener must only be nested within a Server element.

The following additional attributes are supported by the JMX Remote Lifecycle Listener:

Attribute Description
rmiRegistryPortPlatform

The port to be used by the JMX/RMI registry for the Platform MBeans. This replaces the use of the com.sun.management.jmxremote.port system property that should not be set when using this listener.

rmiServerPortPlatform

The port to be used by the Platform JMX/RMI server.

rmiBindAddress

The address of the interface to be used by JMX/RMI server.

useLocalPorts

Should any clients using these ports be forced to use local ports to connect to the JMX/RMI server. This is useful when tunnelling connections over SSH or similar. Defaults to false.

Using file-based Authentication and Authorisation

If this listener was configured in server.xml as:

  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" />

with the following system properties set (e.g. in setenv.sh):

  -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password
-Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access
-Dcom.sun.management.jmxremote.ssl=false

$CATALINA_BASE/conf/jmxremote.password containing:

admin letmein

$CATALINA_BASE/conf/jmxremote.access containing:

admin readwrite

then opening ports 10001 (RMI Registry) and 10002 (JMX/RMI Server) in your firewall would enable jconsole to connect to a Tomcat instance running behind a firewall using a connection string of the form:

service:jmx:rmi://<hostname>:10002/jndi/rmi://<hostname>:10001/jmxrmi

with a user name of admin and a password of letmein

1.下载catalina-jmx-remote.jar(支持JMX协议)到tomcat的lib下。

2.配置tomcat的server.xml中的Listener(这样Tomcat收到停止指令时,会通知Listner,不会导致端口被绑定,停不掉的情况)。

3.使用独立的扩展shell(setenv.sh),配置jmx的连接参数。

官方文档出处:

http://tomcat.apache.org/tomcat-7.0-doc/config/listeners.html#JMX_Remote_Lifecycle_Listener_-_org.apache.catalina.mbeans.JmxRemoteLifecycleListener

catalina-jmx-remote.jar下载地址:

http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.57/bin/extras/catalina-jmx-remote.jar

http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.28/bin/extras/catalina-jmx-remote.jar

三篇考虑比较周全的文章:

https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=441453905

https://blog.linuxeye.cn/262.html

https://blog.csdn.net/liuxigiant/article/details/40344699

[root@crm_web_dev conf]# cat jmxremote.access
admin
[root@crm_web_dev conf]# cat jmxremote.password
admin
[root@crm_web_dev conf]# vim bin/setenv.sh
[root@crm_web_dev conf]# cd bin
-bash: cd: bin: No such file or directory
[root@crm_web_dev conf]# cd ..
[root@crm_web_dev apache-tomcat-7.0.]# vim bin/setenv.sh
[root@crm_web_dev apache-tomcat-7.0.]# cat bin/setenv.sh
CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=192.168.66.152 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access"
[root@crm_web_dev apache-tomcat-7.0.]# service tomcat7 restart
Using CATALINA_BASE: /usr/local/software/tomcat7./apache-tomcat-7.0.
Using CATALINA_HOME: /usr/local/software/tomcat7./apache-tomcat-7.0.
Using CATALINA_TMPDIR: /usr/local/software/tomcat7./apache-tomcat-7.0./temp
Using JRE_HOME: /usr/local/software/jdk1./jdk1..0_191
Using CLASSPATH: /usr/local/software/tomcat7./apache-tomcat-7.0./bin/bootstrap.jar:/usr/local/software/tomcat7./apache-tomcat-7.0./bin/tomcat-juli.jar
Using CATALINA_BASE: /usr/local/software/tomcat7./apache-tomcat-7.0.
Using CATALINA_HOME: /usr/local/software/tomcat7./apache-tomcat-7.0.
Using CATALINA_TMPDIR: /usr/local/software/tomcat7./apache-tomcat-7.0./temp
Using JRE_HOME: /usr/local/software/jdk1./jdk1..0_191
Using CLASSPATH: /usr/local/software/tomcat7./apache-tomcat-7.0./bin/bootstrap.jar:/usr/local/software/tomcat7./apache-tomcat-7.0./bin/tomcat-juli.jar
Tomcat started.
[root@crm_web_dev apache-tomcat-7.0.]# clear
[root@crm_web_dev apache-tomcat-7.0.]# cat /etc/hosts
127.0.0.1 crm_web_dev localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 localhost
127.0.1.1 crm_web_dev.localdomain crm_web_dev
192.168.66.152 crm_web_dev
192.168.66.152 localhost :: crm_web_dev localhost.localdomain localhost6 localhost6.localdomain6
[root@crm_web_dev apache-tomcat-7.0.]# cat conf/jmxremote.access
admin
[root@crm_web_dev apache-tomcat-7.0.]# cat conf/jmxremote.password
admin
[root@crm_web_dev apache-tomcat-7.0.91]# chmod +x bin/setenv.sh
[root@crm_web_dev apache-tomcat-7.0.]# cat bin/setenv.sh CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=192.168.66.152 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access" [root@crm_web_dev apache-tomcat-7.0.]# cd #CATALINA_HOME [root@crm_web_dev ~]# cd $CATALINA_HOME [root@crm_web_dev apache-tomcat-7.0.]# pwd /usr/local/software/tomcat7./apache-tomcat-7.0. [root@crm_web_dev apache-tomcat-7.0.]# ps -ef | grep tomcat root    : pts/ :: /usr/local/software/jdk1./jdk1..0_191/bin/java -Djava.util.logging.config.file=/usr/local/software/tomcat7./apache-tomcat-7.0./conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize= -Djava.rmi.server.hostname=192.168.66.152 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=/usr/local/software/tomcat7./apache-tomcat-7.0./conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/local/software/tomcat7./apache-tomcat-7.0./conf/jmxremote.access -Dignore.endorsed.dirs= -classpath /usr/local/software/tomcat7./apache-tomcat-7.0./bin/bootstrap.jar:/usr/local/software/tomcat7./apache-tomcat-7.0./bin/tomcat-juli.jar -Dcatalina.base=/usr/local/software/tomcat7./apache-tomcat-7.0. -Dcatalina.home=/usr/local/software/tomcat7./apache-tomcat-7.0. -Djava.io.tmpdir=/usr/local/software/tomcat7./apache-tomcat-7.0./temp org.apache.catalina.startup.Bootstrap start root    : pts/ :: grep tomcat [root@crm_web_dev apache-tomcat-7.0.]# netstat -an | grep  tcp   ::: :::* LISTEN [root@crm_web_dev apache-tomcat-7.0.]# cat conf/server.xml <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> <Listener className="org.apache.catalina.core.JasperListener" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- JMX Remote Lifecycle Listener --> <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="" rmiServerPortPlatform="" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="" minSpareThreads=""/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL HTTP/1.1 Connector on port  --> <Connector port="" protocol="HTTP/1.1" connectionTimeout="" redirectPort="" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="" protocol="HTTP/1.1" connectionTimeout="" redirectPort="" /> --> <!-- Define a SSL HTTP/1.1 Connector on port  This connector uses the BIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <!-- <Connector port="" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> --> <!-- Define an AJP 1.3 Connector on port  --> <Connector port="" protocol="AJP/1.3" redirectPort="" /> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> </Engine> </Service> </Server> [root@crm_web_dev apache-tomcat-7.0.]#
scp catalina-jmx-remote.jar 192.168.66.135:/usr/local/software/tomcat7./apache-tomcat-7.0./lib/

chmod +x /usr/local/software/tomcat7.0/apache-tomcat-7.0.91/lib/catalina-jmx-remote.jar
telnet 192.168.66.152 
CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=192.168.66.16 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access"

注意:必须配置账号密码,否则可能不行。

另一篇用rmi方式访问的例子(配置方式未验证)

https://blog.csdn.net/liuxigiant/article/details/40344699

JMX configuration for Tomcat的更多相关文章

  1. Could not publish server configuration for Tomcat v6.0 Server at localhost.

    经常在使用tomcat服务器的时候 总会发生一些莫名其妙的错误. 就像下面这个错误: 在配置文件中存在多个/MyWeb的配置,导致不能发布服务. 错误信息: Could not publish ser ...

  2. 用JMX远程监控Tomcat

    要通过JMX远程监控Tomcat,首先需要进行Tomcat的JMX远程配置. 注意:此配置添加在catalina.bat文件开头的注释行(rem)后面即可. 不需鉴权的配置: 先修改Tomcat的启动 ...

  3. Could not publish server configuration for Tomcat v6.0 Server at localhost.错误问题解决

    经常在使用tomcat服务器的时候 总会发生一些莫名其妙的错误. 就像下面这个错误: 在配置文件中存在多个/MyWeb的配置,导致不能发布服务. 错误信息: Could not publish ser ...

  4. Could not publish server configuration for Tomcat v7.0 Server at localhost. Multiple Contexts have a path of "/ezoutdoor".

    Could not publish server configuration for Tomcat v7.0 Server at localhost. Multiple Contexts have a ...

  5. 【监控】jvisualvm之jmx远程连接 tomcat war启动应用

    一.tomcat相应jmx配置 1.在tomcat bin目录下的catalina.sh文件中添加如下配置: CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun. ...

  6. Java Management extentsions(jmx)与tomcat

    1,概念:一个可以使用JMX管理器来管理的Java对象称为JMX管理资源(JMX manageable resource).事实上,一个JMX管理资源也可以是一个应用程序.一个实现或者一个服务.设备. ...

  7. myeclipse 项目运行时报错:运行项目时报错:Could not publish server configuration for Tomcat v6.0 Server at localhost. Multiple Contexts have a"/"

    1.先去E:\PLZT\workspace\.metadata\.plugins\org.eclipse.wst.server.core.sever.xml看里面是否存在两个配置是的话删除一个重启服务 ...

  8. Tomcat服务器启动失败:Could not publish server configuration for Tomcat v8.0 Server at localhost. Multiple Contexts have a path of

    在eclipse中使用Tomcat8.0时,出现了如下错误: 解决办法: 在建立Tomcat服务时,eclipse会自动生成一个Servers的项目. 在这个项目中,找到你部署项目的服务文件夹. 在这 ...

  9. 用eclipse启动tomcat时报Could not publish server configuration for Tomcat v8.0 Server at localhost..错误

    网上的解决方法是: 1.如果是使用的eclipse tomcat 插件,需要在你的工作空间 找到如下文件:.metadata.plugins\org.eclipse.wst.server.cor\e\ ...

随机推荐

  1. Unity手游之路手游代码更新策略探讨

    版权声明: https://blog.csdn.net/janeky/article/details/25923151 这几个月公司项目非常忙.加上家里事情也多,所以blog更新一直搁置了. 近期在项 ...

  2. CSS3渐变——径向渐变

    上节在<再说CSS3渐变——线性渐变>和大家一起学习了CSS3 Gradient中径向渐变最新语法(称得上是W3C的标准语法)相关知识以及其基本使用.今天我们在这一篇中主要和大家一起来了解 ...

  3. Java 缓存技术之 ehcache

    1. EHCache 的特点,是一个纯Java ,过程中(也可以理解成插入式)缓存实现,单独安装Ehcache ,需把ehcache-X.X.jar 和相关类库方到classpath中.如项目已安装了 ...

  4. rac添加新节点的步骤与方法2

    上一篇文章,把节点删除了.这次新增加一个节点 .新增加的节点是host03.如下: #Public IP192.168.16.45 racdb1192.168.16.46 racdb2192.168. ...

  5. Web安全入门学习

    前言     最近在公司做Linux下的PHP开发,所以乘此机会学习了下Web安全,了解了常见的Web安全漏洞,以及对应的防御方法(使用DVWA进行学习). 暴力破解 场景     在类似用户登陆界面 ...

  6. AI 正则化

    正则化,是减少泛化误差的技术.

  7. 高阶函数 - aop面向切面编程

    Function.prototype.before = function(beforefn) { var __self = this; return function() { beforefn.app ...

  8. uboot-jiuding 下主Makefile详解

    主Makefile位于uboot源码的根目录下,其内容主要结构为: 1. 确定版本号及主机信息(23至48行)2. 实现静默编译功能(48至55行)3. 设置各种路径(56至123行)4. 设置编译工 ...

  9. Luogu2612 ZJOI2012 波浪 DP

    传送门 花掉了自己用来搞学科的时间做了这道题-- 一道类似的题:Here 考虑拆开绝对值计算贡献.那么我们对于\(1\)到\(N\)的排列,从小到大地将插入它们插入排列中. 假设我们现在计算到了数\( ...

  10. LOJ2537 PKUWC2018 Minimax 树形DP、线段树合并

    传送门 题意:自己去看 首先可以知道,每一个点都有几率被选到,所以$i$与$V_i$的关系是确定了的. 所以我们只需要考虑每一个值的取到的概率. 很容易设计出一个$DP$:设$f_{i,j}$为在第$ ...