简体   繁体   English

无法将jconsole连接到远程服务器,tomcat无法启动

[英]Can't connect jconsole to remote server, tomcat failing to start

Trying to connect jconsole to a remote server. 尝试将jconsole连接到远程服务器。

I added this to my catalina.sh: 我把它添加到我的catalina.sh:

export JAVA_OPTS="-Dcom.sun.management.jmxremote \
    -Dcom.sun.management.jmxremote.port=9005 \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -Djava.rmi.server.hostname=xx.xx.xx.xx"

catalina.out shows: catalina.out显示:

Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: myhostname: myhostname

Not sure why it repeats my hostname in the error message? 不确定为什么它会在错误消息中重复我的主机名?

BTW, since I set authentication to false, in the jconsole app, do I leave username/password blank or is that for logging into the server? 顺便说一句,因为我将身份验证设置为false,在jconsole应用程序中,我是否将用户名/密码留空或是用于登录服务器?

You have to add the same host name in /etc/hosts file as you have defined in /etc/sysconfig/network file. 您必须在/etc/hosts文件中添加与/etc/sysconfig/network文件中定义的相同的主机名。 This is how I solved my problem. 这就是我解决问题的方法。

I have found the solution for this issue. 我找到了解决这个问题的方法。 Add the following in your catalina.sh file: catalina.sh文件中添加以下内容:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=7010 -Djava.rmi.server.hostname=${IP}" JAVA_OPTS =“$ JAVA_OPTS -Dcom.sun.management.jmxremote = true -Dcom.sun.management.jmxremote.ssl = false -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.port = 7010 -Djava.rmi.server.hostname = $ {IP}“

Also add the following line in your /etc/init.d/hosts file: 还要在/etc/init.d/hosts文件中添加以下行:

127.0.0.1 localhost <your_hostname>

This resolved the issue. 这解决了这个问题。 I am able to run jconsole as well as jvisualvm on this port now. 我现在可以在这个端口上运行jconsolejvisualvm
I hope this helps ! 我希望这有帮助 !

If you want to get the IP address dynamically you can try: 如果您想动态获取IP地址,可以尝试:

IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false  -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=${IP}"
  1. If you use '\\' in your 'export' statement, remove those. 如果在“export”语句中使用“\\”,请删除它们。

  2. To connect to remote java process, Use IP address of the server where your java process (tomcat instance) is running. 要连接到远程java进程,请使用运行java进程(tomcat实例)的服务器的IP地址。 The UnknownHostException is thrown when IP address could not be determined, so another option is to add the name - IP address definition to your hosts file. 无法确定IP地址时抛出UnknownHostException,因此另一个选项是将名称 - IP地址定义添加到hosts文件中。

You can try adding the parameters that you have added in JAVA_OPTS to CATALINA_OPTS. 您可以尝试将在JAVA_OPTS中添加的参数添加到CATALINA_OPTS。 It should work that way. 它应该这样工作。
Also make sure u are making the settings with the same profile login from where you are running tomcat. 还要确保使用与运行tomcat的位置相同的配置文件登录进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM