gpt4 book ai didi

java - Cassandra docker - 无法通过 JMX 连接

转载 作者:行者123 更新时间:2023-11-30 10:48:08 26 4
gpt4 key购买 nike

我很难通过 JMX 连接到 docker 容器内的 Cassandra。我在 AWS 中运行(这意味着我获得了 NATted IP)。以下是我尝试过的方法:

  1. 创建 jmxremote.password 文件
  2. 添加了 jmxremote.password 文件以启用 jmx 连接。我从中创建图像的 Dockerfile:

FROM cassandra:latest

COPY ./jmxremote.password /etc/cassandra/jmxremote.password

RUN chmod 400 /etc/cassandra/jmxremote.password

COPY ./jmxremote.password /etc/java-8-openjdk/management/jmxremote.password

  1. 我使用上面的 docker 文件构建了镜像
  2. 运行容器:

    docker run -P -d -e "JVM_OPTS=-Djava.rmi.server.hostname=10.0.1.12" -e "LOCAL_JMX=no" -e

这会引发以下异常:

java.rmi.ConnectException: Connection refused to host: 10.0.1.12; nested exception is: 
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2432)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:308)
at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:368)
at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:313)
at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:294)

Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 9 more

  1. 我尝试将 cassandra.yaml 文件中的 listen_address 设置为我的主机 IP (10.0.1.12),因为这默认设置为 docker IP。同样的结果
  2. 我也尝试在启动容器时设置环境变量“CASSANDRA_START_RPC=true”,但我遇到了同样的问题

有人可以就过去几天完全阻止我的这个问题提供指示或帮助吗?提前感谢您抽出时间分享您的知识。

干杯,苏朵儿

最佳答案

我像这样关闭了 jmx 身份验证:

jetty 文件:

FROM cassandra

RUN sed -i 's/JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=true"/JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"/g' /etc/cassandra/cassandra-env.sh

RUN sed -i '/password/d' /etc/cassandra/cassandra-env.sh

docker-compose.yml:

environment:
- LOCAL_JMX=no
- JVM_EXTRA_OPTS=-Djava.rmi.server.hostname=127.0.0.1

关于java - Cassandra docker - 无法通过 JMX 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35931053/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com