laradock 上的 Elasticsearch "laradock_elasticsearch_1 exited with code 1" 错误

Elasticsearch "laradock_elasticsearch_1 exited with code 1" error on laradock

我用的是laradock,但是有问题; 当我 运行 以下命令时:

docker-compose up -d elasticsearch

下载并构建 Elasticsearch 镜像后; return 这个错误。

错误消息:本机控制器进程已停止 - 无法启动新的本机进程

laradock_elasticsearch_1 已退出,代码为 1

"at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116) ~[elasticsearch-cli-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.cli.Command.main(Command.java:79) ~[elasticsearch-cli-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "Caused by: java.lang.IllegalArgumentException: setting [cluster.initial_master_nodes] is not allowed when [discovery.type] is set to [single-node]",
elasticsearch_1        | "at org.elasticsearch.cluster.coordination.ClusterBootstrapService.<init>(ClusterBootstrapService.java:75) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.cluster.coordination.Coordinator.<init>(Coordinator.java:192) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.discovery.DiscoveryModule.<init>(DiscoveryModule.java:146) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.node.Node.<init>(Node.java:622) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.node.Node.<init>(Node.java:278) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.bootstrap.Bootstrap.<init>(Bootstrap.java:216) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:216) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:387) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.11.1.jar:7.11.1]",
elasticsearch_1        | "... 6 more"] }
elasticsearch_1        | uncaught exception in thread [main]
elasticsearch_1        | java.lang.IllegalArgumentException: setting [cluster.initial_master_nodes] is not allowed when [discovery.type] is set to [single-node]
elasticsearch_1        |        at org.elasticsearch.cluster.coordination.ClusterBootstrapService.<init>(ClusterBootstrapService.java:75)
elasticsearch_1        |        at org.elasticsearch.cluster.coordination.Coordinator.<init>(Coordinator.java:192)
elasticsearch_1        |        at org.elasticsearch.discovery.DiscoveryModule.<init>(DiscoveryModule.java:146)
elasticsearch_1        |        at org.elasticsearch.node.Node.<init>(Node.java:622)
elasticsearch_1        |        at org.elasticsearch.node.Node.<init>(Node.java:278)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Bootstrap.<init>(Bootstrap.java:216)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:216)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:387)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
elasticsearch_1        |        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
elasticsearch_1        |        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
elasticsearch_1        |        at org.elasticsearch.cli.Command.main(Command.java:79)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
elasticsearch_1        |        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)
elasticsearch_1        | For complete error details, refer to the log at /usr/share/elasticsearch/logs/laradock-cluster.log
elasticsearch_1        | {"type": "server", "timestamp": "2021-03-11T09:09:39,766Z", "level": "INFO", "component": "o.e.x.m.p.NativeController", "cluster.name": "laradock-cluster", "node.name": "laradock-node", "message": "Native controller process has stopped - no new native processes can be started" }
laradock_elasticsearch_1 exited with code 1

Elasticsearch 配置 (.env)

    elasticsearch:
      build:
        context: ./elasticsearch
        args:
          - ELK_VERSION=${ELK_VERSION}
      volumes:
        - elasticsearch:/usr/share/elasticsearch/data
      environment:
        - cluster.name=laradock-cluster
        - node.name=laradock-node
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - cluster.initial_master_nodes=laradock-node
        - discovery.type=single-node
      ulimits:
        memlock:
          soft: -1
          hard: -1
        nofile:
          soft: 65536
          hard: 65536
      ports:
        - "${ELASTICSEARCH_HOST_HTTP_PORT}:9200"
        - "${ELASTICSEARCH_HOST_TRANSPORT_PORT}:9300"
      depends_on:
        - php-fpm
      networks:
        - frontend
        - backend

我在 docker-compose 配置中添加了以下参数并解决了问题。

- "transport.host=localhost"
- "bootstrap.system_call_filter=false"

docker-compose.yml

### ElasticSearch ########################################
    elasticsearch:
      build:
        context: ./elasticsearch
        args:
          - ELK_VERSION=${ELK_VERSION}
      volumes:
        - elasticsearch:/usr/share/elasticsearch/data
      environment:
        - cluster.name=laradock-cluster
        - node.name=laradock-node
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - cluster.initial_master_nodes=laradock-node
        - "transport.host=localhost"
        - "bootstrap.system_call_filter=false"
      ulimits:
        memlock:
          soft: -1
          hard: -1
        nofile:
          soft: 65536
          hard: 65536
      ports:
        - "${ELASTICSEARCH_HOST_HTTP_PORT}:9200"
        - "${ELASTICSEARCH_HOST_TRANSPORT_PORT}:9300"
      depends_on:
        - php-fpm
      networks:
        - frontend
        - backend