cassandra - 将 Cassandra JMX 绑定到 ip
问题描述
我正在使用 Cassandra 3.11.2,但无法在特定接口上绑定 JMX。
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
netstat -l
tcp 0 0 *:7199 *:* LISTEN
我的 cassandra-env.sh 如下:
if [ "x$LOCAL_JMX" = "x" ]; then
LOCAL_JMX=no
fi
# Specifies the default port over which Cassandra will be available for
# JMX connections.
# For security reasons, you should not expose this port to the internet. Firewall it if needed.
JMX_PORT="7199"
if [ "$LOCAL_JMX" = "yes" ]; then
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
else
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT"
# if ssl is enabled the same port cannot be used for both jmx and rmi so either
# pick another value for this property or comment out to use a random port (though see CASSANDRA-7087 for origins)
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=192.168.8.60"
fi
我的印象是 Djava.rmi.server.hostname 会设置 jxm 监听主机。JMX 连接在这种情况下工作正常。
编辑:它现在正在工作,但我与 JMX 主机的连接被拒绝
root@server:/etc/cassandra# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:domain *:* LISTEN
tcp 0 0 192.168.1.100:7199 *:* LISTEN
root@server:/etc/cassandra# nodetool -h 192.168.1.100 status
nodetool: Failed to connect to '192.168.1.100:7199' - ConnectException: 'Connection refused (Connection refused)'
解决方案
您正在寻找的选项是:
-Dcom.sun.management.jmxremote.host=...
它已在 jdk 1.8.0_101 周围添加,因此使用 1.8.0_171 就可以了。
编辑:port
需要设置
-Dcom.sun.management.jmxremote.port=...
为此工作。
此外,正如您在此处使用的那样-Dcom.sun.management.jmxremote.rmi.port=...
,您需要禁用 SSL 或为 rmi 使用一个端口,为 jmx 使用一个端口。
一个你的用例,你可以有:
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.host=..."
或类似的东西
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=true"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=7200"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.host=..."
推荐阅读
- typeerror - 3 p5 草图尚未加载:TypeError {}
- java - 多态性。复制数组的问题
- wpf - Squirrel.Windows 增量更新不起作用
- typescript - 如何描述从 .ts 文件导出为函数的 webpack 配置类型?
- python - 尝试使用列表实现斐波那契数列的迭代解决方案时出现问题
- json.net - 无法创建 ITask 类型的实例。类型是接口或抽象类,不能实例化
- javascript - 如何将对象键设置为打字稿中另一个对象的值?
- c++ - c++字符串全局变量不能正常赋值
- mysql - Unexpected result in WHERE clause on AI ID field
- python - 如何在python中重载构造函数?