简体   繁体   English

无法连接到本地 datastax cassandra 在 docker 中运行

[英]Cannot connect to local datastax cassandra running in docker

I executed this docker command to run instance of datastax cassandra:我执行了这个 docker 命令来运行 datastax cassandra 的实例:

docker run -p 9042:9042 -e DS_LICENSE=accept --rm --name my-dse -d datastax/dse-server:6.8.2 -s

Then this to run instance of the datastax studio:然后运行datastax studio的实例:

docker run -e DS_LICENSE=accept --link my-dse --name my-studio -p 9091:9091 -d datastax/dse-studio

When I open the browser at http://localhost:9091 to create the connection, I get this error:当我在http://localhost:9091打开浏览器以创建连接时,出现此错误:

All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1:9042] Cannot connect))

I checked the cassandra instance running in docker and I can connect using cqlsh:我检查了在 docker 中运行的 cassandra 实例,我可以使用 cqlsh 进行连接:

$ docker exec -it my-dse bash -c "cqlsh -u cassandra -p cassandra"
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 6.8.0 | DSE 6.8.2 | CQL spec 3.4.5 | DSE protocol v2]
Use HELP for help.
cassandra@cqlsh> 

This is based on the instructions here: https://www.datastax.com/blog/2019/03/running-dse-microsoft-windows-using-docker这是基于此处的说明: https://www.datastax.com/blog/2019/03/running-dse-microsoft-windows-using-docker

Instead of 127.0.0.1:9092 or localhost:9042 you either need to specify my-dse:9042 or your_machine_ip:9042 .您需要指定my-dse:9042your_machine_ip:9042而不是127.0.0.1:9092localhost:9042 your_machine_ip:9042 The main problem is that for every Docker image, the localhost is uniq to that container, and in the Studio container there is no DSE process listening on the port 9042主要问题是对于每个 Docker 镜像,本地主机是该容器的 uniq,并且在 Studio 容器中没有 DSE 进程监听端口 9042

Try querying the IP Address of the container running the my-dse container using the following command from a command prompt: docker inspect my-dse |尝试使用命令提示符下的以下命令查询运行 my-dse 容器的容器的 IP 地址: docker 检查 my-dse | FINDSTR "IPAddress" .查找“IP 地址” You should be able to use that IP address as the Host in the DataStax Studio connection.您应该能够使用该 IP 地址作为 DataStax Studio 连接中的主机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM