docker run -it -p 9201:9200 --network elastic --name es2 elasticsearch:8.7.1
没有任何问题,几秒之后就会出现
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
但是 docker-compose.yml
version: "3.9"
services:
logstash:
image: logstash:8.7.1
container_name: logstash
networks:
- elastic
ports:
- "5044:5044"
volumes:
- ./elk/pipeline:/usr/share/logstash/pipeline:rw,Z
restart: unless-stopped
depends_on:
- kibana
kibana:
image: kibana:8.7.1
container_name: kibana
networks:
- elastic
ports:
- "5601:5601"
restart: always
elasticsearch:
image: elasticsearch:8.7.1
container_name: elasticsearch
deploy:
resources:
reservations:
memory: 4GB
networks:
- elastic
ports:
- "9200:9200"
restart: no
networks:
elastic:
name: elastic
external: true
这样子启动的 elasticsearch 就会无限打印
{"@timestamp":"2023-06-02T12:25:51.290Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.19.0.3:9200, remoteAddress=/172.19.0.2:42386}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[bb66f54e0118][transport_worker][T#2]","log.logger":"org.elasticsearch.http.netty4.Netty4HttpServerTransport","elasticsearch.cluster.uuid":"7sT8niyaQeqs2oZAn8TLLg","elasticsearch.node.id":"jg-nmYbcQZmdM5Jfy_fMfw","elasticsearch.node.name":"bb66f54e0118","elasticsearch.cluster.name":"docker-cluster"}
然后几分钟后就ERROR: Elasticsearch exited unexpectedly,为什么,我无法理解了,还没有任何的 error 日志 它要是显示启动成功的那两个绿勾勾再无限打印 warning 也就算了,可是压根启动不成功
一开始我以为是 docker compose 启动过程中 kibana 不停给 elasticsearch 发 http 导致启动失败,但是 depends-on 完全不起作用,甚至我将 docker compose yml 删了只剩 elasticsearch 一个服务还是不行 但是 docker run ...就没有那串日志,所以难道 docker compose 在启动的时候,docker engine 不停给 elasticsearch 发什么 http 吗,healthcheck?? 这我该咋办啊
1
Yourshell 2023-06-02 21:09:30 +08:00
有没有可能是内存给少了
|
2
hingle 2023-06-02 21:12:48 +08:00
docker run 端口是 9201 ,docker compose 端口是 9200 ,端口被占用了?
|
3
wganbleuthall OP @Yourshell 不应该啊 给了 4g
|
4
wganbleuthall OP @hingle 两个容器
|
5
caomingjun 2023-06-02 21:24:00 +08:00 via Android
我感觉不像 healthcheck ,healthcheck 一般是从容器内部发起的
其实日志输出里有 remoteAddress=/172.19.0.2:42386 ,你搞清楚这个 ip 和端口号上跑的啥玩意不就知道了 |
6
w07128597 2023-06-02 21:26:06 +08:00 via iPhone
我遇到过,默认内存太低了,启动成功后立马就挂了,增加 es 的堆内存就好了,在环境变量中设置
|
7
chotow 2023-06-02 21:54:03 +08:00
docker inspect elasticsearch 可以查看退出原因,我试了下,是因为 OOM
|