cqlsh到Cassandra“无法连接”,在容器中,在docker-machine VM上

时间:2016-02-18 03:13:16

标签: cassandra osx-mavericks cqlsh docker-machine

我们试图在容器中运行Cassandra(2.2.0),在Mac上的另一个容器中运行cqlsh(5.0.1)。它适用于Linux笔记本电脑但无法在Mac上连接(10.9.5)。 Mac上的失败(以下是在Linux上工作)是:

# Start Cassandra in a Docker container
docker run --detach --name cassandra1 -p 9042:9042 poklet/cassandra
# Connect to Cassandra using cqlsh
docker run -it --rm --net container:cassandra1 poklet/cassandra cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

docker run -it --rm --net container:cassandra1 poklet/cassandra cqlsh cassandra1
Connection error: ('Unable to connect to any servers', {'cassandra1': error(111, "Tried connecting to [('172.17.0.10', 9042)]. Last error: Connection refused")})

docker run -it --rm --net container:cassandra1 poklet/cassandra cqlsh 172.17.0.10
Connection error: ('Unable to connect to any servers', {'172.17.0.10': error(111, "Tried connecting to [('172.17.0.10', 9042)]. Last error: Connection refused")})

我们想验证问题是特定于cqlsh还是仅仅是端口问题 我们使用curl连接到同一端口(在mac上)的web服务器,而不是尝试将cqlsh连接到cassandra。我们停下了容器并且:

# started a container with a webserver on port 9042:
docker run -it --name cassandra1 -p 9042:9042 ubuntu
python -m SimpleHTTPServer 9042
# and a container to represent “cqlsh”:
docker run -it --rm --net container:cassandra1 ubuntu /bin/bash

并且能够在“clqsh”容器(curl localhost:9042curl cassandra1:9042curl 172.17.0.9:9042)上成功执行以下命令,以表明它不是端口问题。

我们认为这是docker-machine VM上的cqlsh特定问题。

1 个答案:

答案 0 :(得分:0)

假设您在本地计算机上安装了cassandra。

示例:

  

$ docker-machine ip default

     

192.168.0.10

     

$ cqlsh 192.168.0.10

相关问题