我有一个Elasticsearch 7.6.1 Docker容器,我想在9400,9500端口上运行。
这是我使用的docker run命令。
docker run -d --name elasticsearch761v2 -v /data/dump/:/usr/share/elasticsearch/data
-p 9400:9400 -p 9500:9500 -e "discovery.type=single-node" elasticsearch:7.6.1
哪个给出以下输出。
docker ps -a | grep elastic
idofcontainer elasticsearch:7.6.1 "/usr/local/bin/docke" 18 minutes ago Up 4 minutes
9200/tcp, 0.0.0.0:9400->9400/tcp, 9300/tcp, 0.0.0.0:9500->9500/tcp elasticsearch761v2
我还将elasticsearch.yml设置设置为以下。
[root@idofcontainer config]# vi elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
transport.tcp.port: 9400
我也为上述端口添加了Iptable条目。
此容器的日志为:-
{"type": "server", "timestamp": "2020-04-06T08:25:22,684Z", "level": "INFO", "component": "o.e.c.r.a.AllocationService", "cluster.name": "docker-cluster", "node.name": "4196b5b23",
"message": "Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[.kibana_task_manager_1][0], [.kibana_1][0]]]).", "cluster.uuid": "gx7s8R_PTUK4lFPPGBZA", "node.id": "XfLZnNNnQnAOHJnWdDQg" }
Curl输出是这样的:-
curl http://eserver:9400/_cat
This is not an HTTP port
因此,我的kibana也无法访问ES服务器。 我将kibana.yml设置为指向上述端口。
Kibana.yml
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: ["http://eserver:9400/"]
xpack.monitoring.ui.container.elasticsearch.enabled: true
此kibana容器的日志。
{"type":"log","@timestamp":"2020-04-06T08:49:14Z","tags":["warning","elasticsearch","admin"],"pid":7,"message":"Unable to revive connection: http://eserver:9400/"}
{"type":"log","@timestamp":"2020-04-06T08:49:14Z","tags":["warning","elasticsearch","admin"],"pid":7,"message":"No living connections"}
答案 0 :(得分:1)
您已经定义了自定义传输端口9400
,并在curl
命令中将其用作HTTP端口来检查Elastic server,该错误消息明确指出了。
这不是HTTP端口
如前所述,您希望在9400和9500上运行Elastic,然后需要使用以下命令将默认HTTP端口9200 正确绑定到9500。
docker run -d --name elasticsearch761v2 -v /data/dump/:/usr/share/elasticsearch/data
-p 9400:9400 -p 9500:9200 -e "discovery.type=single-node" elasticsearch:7.6.1
请注意,唯一需要进行的更改是-p 9500:9200
,之后,您可以使用curl http://eserver:9500
,即使用HTTP端口来检查ES服务器。