docker中无法连接到端口9300上的elasticsearch

我在本地机器上通过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。

有人也遇到这个问题,并有任何解决办法? 接下来我想尝试的是在我的机器上安装elasticsearch,但是我认为docker的方式更有价值。

这里也是我的flink代码,并在elasticsearch中创build索引和映射:

 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())); 

curl索引ES:

 curl --request PUT --url http://localhost:9200/twitter-bd 

curl绘制ES:

 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"} } } }' 

创build一个docker -compose文件docker-compose.yml

 version: '2' services: elasticsearch: container_name: elasticsearch image: elasticsearch:2.4.1 # UNCOMMENT BELOW LINES TO HAVE PERSISTAN STORAGE # volumes: # - /var/db/elasticsearch/:/usr/share/elasticsearch/data/ ports: - 9200:9200 - 9300:9300 

docker工人 – 组成up -d

使用9300端口与ES通信

创build内容

curl -XPUT“ http:// localhost:9200 / playground / equipment / 1 ”-d“{”type“:”slide“,”quantity“:2}'

阅读内容

curl -XGET“ http:// localhost:9200 / playground / equipment / 1 ”

如何使用CRUD操作在Elasticsearch中与数据进行交互