【发布时间】:2018-03-29 07:56:01
【问题描述】:
我正在本地机器上通过 docker 运行 elasticsearch,并且可以通过端口 9200 上的 REST API 正常访问它。
Apache flink 用于通过端口 9300 与 elasticsearch 通信。
我的目标是通过接收器将数据从 apache flink 放到 elasticsearch,但是在每次执行我的程序时,我都会收到 java 错误:
Elasticsearch client is not connected to any Elasticsearch nodes!
我运行容器的 docker 命令如下所示:
docker run --rm -d -p 9200:9200 -p 9300:9300 -p 5601:5601 --name es-kibana nshou/elasticsearch-kibana
我还尝试通过“-p 0.0.0.0:9300:9300”打开端口 9300 或使用官方 docker 容器进行弹性搜索。
是否有人也遇到过这个问题并有解决方案?接下来我想尝试的是在我的机器上本地安装elasticsearch,但我认为docker方式更有价值。
这里也是我的flink代码以及elasticsearch中索引和映射的创建:
List<InetSocketAddress> transports = new ArrayList<>();
transports.add(new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 9300));
tweets.addSink(new ElasticsearchSink<Tuple2<String, Integer>>(
config,
transports,
new ESSink()));
用于索引 ES 的卷曲:
curl --request PUT --url http://localhost:9200/twitter-bd
用于映射 ES 的 curl:
curl --request PUT
--url http://localhost:9200/twitter-bd/_mapping/twitter-wordcount \
--header 'content-type: application/json' \
--data '{
"twitter-wordcount": {
"properties": {
"word": {"type": "string"},
"cnt": {"type": "integer"}
}
}
}'
【问题讨论】:
-
从你的主机上,elasticsearch 在 localhost:9300 上可用,也许你应该将地址更改为 localhost:transports.add(new InetSocketAddress(InetAddress.getByName("localhost"), 9300));
标签: docker elasticsearch apache-flink