使用nodetool远程检查cassandra的状态错误:连接被拒绝

xxb16uws  于 2021-06-15  发布在  Cassandra
关注(0)|答案(1)|浏览(300)

我正在尝试创建一个docker compose安装程序,它将等待cassandra容器启动后再运行janusgraph容器,该容器要求cassandra在启动前运行。
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”表示up/normal,我打算在wait-for-cassandra-and-elasticsearch.sh脚本中使用它。但现在,当我尝试在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文件中看到。
我也看到这个帖子,我不确定是相关的。我试着按照指示去做,但还是犯了同样的错误。
如有任何建议,我将不胜感激。
文件: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

erhoui1w

erhoui1w1#

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

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

试试看,如果有帮助就告诉我。

相关问题