【发布时间】:2017-12-20 19:32:18
【问题描述】:
我通过运行以下命令来设置 Cassandra 容器:
这将从 docker hub 拉取 cassandra docker 镜像并使用 cassandra 启动一个容器
docker run --name cassandraDb -d --publish-all=true cassandra:3.11
我可以通过运行以下命令来查看它:
docker images
docker ps -a
docker exec -i -t cassandraDb sh -c 'nodetool status'
这是我的 Node.js 路由的代码,当我点击它时,我得到了继续错误:
res.send(client.connect()
.then(() => {
console.log('Connected');
console.log(Object.keys(client.metadata.keyspaces));
return client.shutdown();
})
/* tslint:disable-next-line */
.catch((err): any => {
console.error('There was an error when connecting', err);
return client.shutdown();
}));
错误:
There was an error when connecting { [Error: All host(s) tried for query failed. First host tried, 172.17.0.2:9042: Error: Connection timeout. See innerErrors.]
innerErrors:
{ '172.17.0.2:9042':
{ [Error: Connection timeout]
message: 'Connection timeout',
info: 'Cassandra Driver Error' } },
info: 'Represents an error when a query cannot be performed because no host is available or could be reached by the driver.',
message: 'All host(s) tried for query failed. First host tried, 172.17.0.2:9042: Error: Connection timeout. See innerErrors.' }
我对 Cassandra 或 Docker 没有太多经验,所以我不确定为什么我的应用没有连接到数据库,可能是端口未对传入请求开放,但我不知道如何我会检查或更改它。
【问题讨论】:
标签: node.js docker cassandra cassandra-3.0