【问题标题】:Remotely check status of cassandra using nodetool. Error: Connection refused使用 nodetool 远程检查 cassandra 的状态。错误:连接被拒绝
【发布时间】:2019-03-03 18:46:38
【问题描述】:

我正在尝试创建一个 docker compose 设置,它将等待 Cassandra 容器启动,然后再运行要求 Cassandra 在启动之前运行的 JanusGraph 容器。

nodetool 命令似乎是检查 Cassandra 状态的标准方法。这是我首先在 cassandra 容器上运行 nodetool 的内容:

docker exec -it ns-orchestration_data_storage_1 nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens       Owns (effective)  Host ID                               Rack
UN  172.31.0.2  235.53 KiB  256          100.0%            eea17329-6274-45a7-a9fb-a749588b733a  rack1

最后一个标准输出行上的第一个“UN”表示我打算在我的 wait-for-cassandra-and-elasticsearch.sh 脚本中使用的 Up/Normal。但是现在当我尝试在 janusgraph 容器(远程)上运行它时,我得到了这个:

docker exec -it ns-orchestration_data_janusgraph_1 bin/nodetool -h 172.31.0.2 -u cassandra -pw <my-password-here> status
docker exec -it ns-orchestration_data_janusgraph_1 bin/nodetool -h 
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/app/janusgraph-0.3.0-hadoop2/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/app/janusgraph-0.3.0-hadoop2/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
nodetool: Failed to connect to '172.31.0.2:7199' - ConnectException: 'Connection refused (Connection refused)'.

我已经公开了所有 Cassandra 端口,您可以在下面的 docker-compose 文件中看到。

我还看到了this post,我不确定它是否相关。我尝试按照说明进行操作,但仍然遇到相同的错误。

如果有任何建议,我将不胜感激。

文件:docker-compose.yml

version: '3'
services:
  data_janusgraph:
    build:
      context: ../ns-compute-store/db-janusgraph
      dockerfile: Dockerfile.janusgraph
    ports:
      - "8182:8182"
    depends_on:
      - data_storage
      - data_index
    networks:
      - ns-net
  data_storage:
    build:
      context: ../ns-compute-store/db-janusgraph
      dockerfile: Dockerfile.cassandra
    environment:
      - CASSANDRA_START_RPC=true
    ports:
      - "9160:9160"
      - "9042:9042"
      - "7199:7199"
      - "7001:7001"
      - "7000:7000"
    volumes:
      - data-volume:/var/lib/cassandra
    networks:
      - ns-net
  data_index:
    image: elasticsearch:5.6
    ports:
      - "9200:9200"
      - "9300:9300"
    networks:
      - ns-net
networks:
  ns-net:
    driver: bridge
volumes:
  data-volume:

文件:Dockerfile.cassandra

FROM cassandra:3.11
COPY conf/jmxremote.password /etc/cassandra/jmxremote.password
RUN chown cassandra:cassandra /etc/cassandra/jmxremote.password
RUN chmod 400 /etc/cassandra/jmxremote.password
COPY conf/jmxremote.access /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/management/jmxremote.access
RUN chown cassandra:cassandra /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/management/jmxremote.access
RUN chmod 400 /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/management/jmxremote.access
COPY conf/cassandra.yaml /etc/cassandra/cassandra.yaml

文件:Dockerfile.janusgraph

FROM openjdk:8-jre-alpine
RUN mkdir /app
WORKDIR /app
RUN apk update \
    && apk upgrade \
    && apk --no-cache add unzip
RUN wget https://github.com/JanusGraph/janusgraph/releases/download/v0.3.0/janusgraph-0.3.0-hadoop2.zip
RUN unzip janusgraph-0.3.0-hadoop2.zip
RUN apk --no-cache add bash coreutils nmap
RUN apk del unzip
ENV JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=data_storage"
WORKDIR /app/janusgraph-0.3.0-hadoop2
COPY wait-for-cassandra-and-elasticsearch.sh ./
COPY conf/janusgraph-cql-es.properties ./
CMD ["./wait-for-cassandra-and-elasticsearch.sh", "data_storage:9160", "data_index:9200", "./bin/gremlin-server.sh", "./conf/gremlin-server/gremlin-server-berkeleyje.yaml"]

在 Github 存储库中查看完整代码: https://github.com/nvizo/janusgraph-cluster-example

【问题讨论】:

  • 我认为我的问题可能是我试图在 JanusGraph 容器上使用 nodetool 而没有让 JanusGraph 容器先加入 Cassandra 集群。换句话说,nodetool 只显示它所在的集群中的节点的状态。谁能确认一下?

标签: docker cassandra cassandra-3.0 janusgraph


【解决方案1】:

我相信在从 janusgraph 容器运行 nodetool 时,您应该将 cassandra 容器名称称为主机名。大致如下:

docker exec -it ns-orchestration_data_janusgraph_1 bin/nodetool -h data_storage -u cassandra -pw <my-password-here> status

试一试,如果有帮助,请告诉我。

【讨论】:

  • 您能否提供wait-for-cassandra-and-elasticsearch.sh 脚本以及其他必要的文件,例如conf 文件等来构建整个环境?我可以尝试在这里运行它来调试它
  • 谢谢,我在 github 中创建了一个最小示例:github.com/nvizo/janusgraph-cluster-example
猜你喜欢
  • 2016-04-12
  • 2013-08-02
  • 2017-10-05
  • 2011-04-22
  • 2018-11-16
  • 1970-01-01
  • 2023-03-15
  • 2016-02-27
相关资源
最近更新 更多