1
version: "3"
services:
  elk-elasticsearch-8:
    container_name: elk-elasticsearch-8
    image: elasticsearch:8.5.3
    restart: always
    ports:
      - "9201:9200"
      # - "9201:9201"
      - "9301:9300"
      # - "9301:9301"
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g" # 限制 es 的内存大小,不然会吃掉 10GB+ 的 RAM
    # volumes:
    #   - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml # kibana 其实是支持中文的,只要在 /usr/share/kibana/config/kibana.yml 加一行 i18n.locale: "zh-CN"
    #   # - ./volumes/elk-elasticsearch/:/usr/share/elasticsearch/data/

  elk-kibana-8:
    container_name: elk-kibana-8
    image: kibana:8.5.3
    restart: always
    ports:
      - "5602:5601"
    # environment:
    #   - ELASTICSEARCH_HOSTS=http://192.168.38.191:9200
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml # kibana 其实是支持中文的,只要在 /usr/share/kibana/config/kibana.yml 加一行 i18n.locale: "zh-CN"

直接运行不行,elasticsearch8 会有警告,拒绝 http 连接

{"@timestamp":"2023-10-07T09:05:26.039Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56138}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#1]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}
{"@timestamp":"2023-10-07T09:05:26.042Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56154}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#2]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}
{"@timestamp":"2023-10-07T09:05:26.044Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56160}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#3]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}
{"@timestamp":"2023-10-07T09:05:26.047Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56168}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#4]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}
{"@timestamp":"2023-10-07T09:05:26.111Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56172}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#5]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}
{"@timestamp":"2023-10-07T09:05:26.114Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56184}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#6]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}
{"@timestamp":"2023-10-07T09:05:26.117Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.21.1.2:9200, remoteAddress=/172.21.1.3:56188}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[be67cbab018b][transport_worker][T#7]","log.logger":"org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport","elasticsearch.cluster.uuid":"0-u_wyYFRPejs1VRJgd3bw","elasticsearch.node.id":"-EwVSPqnRpCO22gN8zqScg","elasticsearch.node.name":"be67cbab018b","elasticsearch.cluster.name":"docker-cluster"}

解决办法:

version: "3"
services:
  elk-elasticsearch-8:
    container_name: elk-elasticsearch-8
    image: elasticsearch:8.5.3
    restart: always
    ports:
      - "9200:9200"
      # - "9201:9201"
      - "9300:9300"
      # - "9301:9301"
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g" # 限制 es 的内存大小,不然会吃掉 10GB+ 的 RAM
    volumes:
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml # kibana 其实是支持中文的,只要在 /usr/share/kibana/config/kibana.yml 加一行 i18n.locale: "zh-CN"
    #   # - ./volumes/elk-elasticsearch/:/usr/share/elasticsearch/data/

  elk-kibana-8:
    container_name: elk-kibana-8
    image: kibana:8.5.3
    restart: always
    ports:
      - "5601:5601"
    # environment:
    #   - ELASTICSEARCH_HOSTS=http://192.168.38.191:9200
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml # kibana 其实是支持中文的,只要在 /usr/share/kibana/config/kibana.yml 加一行 i18n.locale: "zh-CN"

然后重新创建容器

然后又报错了

{"@timestamp":"2023-10-07T09:17:31.888Z", "log.level": "WARN", "message":"Oct 07, 2023 9:17:31 AM org.apache.lucene.store.MMapDirectory lookupProvider", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"stderr","elasticsearch.node.name":"cee70dffa697","elasticsearch.cluster.name":"docker-cluster-elk8"}
{"@timestamp":"2023-10-07T09:17:31.888Z", "log.level": "WARN", "message":"WARNING: You are running with Java 19. To make full use of MMapDirectory, please pass '--enable-preview' to the Java command line.", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"stderr","elasticsearch.node.name":"cee70dffa697","elasticsearch.cluster.name":"docker-cluster-elk8"}
{"@timestamp":"2023-10-07T09:17:31.896Z", "log.level": "INFO", "message":"using [1] data paths, mounts [[/ (overlay)]], net usable_space [2.7tb], net total_space [2.9tb], types [overlay]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.env.NodeEnvironment","elasticsearch.node.name":"cee70dffa697","elasticsearch.cluster.name":"docker-cluster-elk8"}
{"@timestamp":"2023-10-07T09:17:31.897Z", "log.level": "INFO", "message":"heap size [2gb], compressed ordinary object pointers [true]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.env.NodeEnvironment","elasticsearch.node.name":"cee70dffa697","elasticsearch.cluster.name":"docker-cluster-elk8"}
{"@timestamp":"2023-10-07T09:17:31.901Z", "log.level": "INFO", "message":"node name [cee70dffa697], node ID [oIdZNsd9RRiOHC3YT-jPfw], cluster name [docker-cluster-elk8], roles [transform, data_content, data_warm, master, remote_cluster_client, data, data_cold, ingest, data_frozen, ml, data_hot]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.node.Node","elasticsearch.node.name":"cee70dffa697","elasticsearch.cluster.name":"docker-cluster-elk8"}
{"@timestamp":"2023-10-07T09:17:33.591Z", "log.level":"ERROR", "message":"fatal exception while booting Elasticsearch", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.Elasticsearch","elasticsearch.node.name":"cee70dffa697","elasticsearch.cluster.name":"docker-cluster-elk8","error.type":"org.elasticsearch.ElasticsearchSecurityException","error.message":"failed to load SSL configuration [xpack.security.transport.ssl] - cannot read configured [PKCS12] keystore (as a truststore) [/usr/share/elasticsearch/config/certs/transport.p12] because the file does not exist","error.stack_trace":"org.elasticsearch.ElasticsearchSecurityException: failed to load SSL configuration [xpack.security.transport.ssl] - cannot read configured [PKCS12] keystore (as a truststore) [/usr/share/elasticsearch/config/certs/transport.p12] because the file does not exist\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.ssl.SSLService.lambda$loadSslConfigurations$11(SSLService.java:605)\n\tat java.base/java.util.HashMap.forEach(HashMap.java:1429)\n\tat java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1553)\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.ssl.SSLService.loadSslConfigurations(SSLService.java:601)\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.ssl.SSLService.<init>(SSLService.java:156)\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.XPackPlugin.createSSLService(XPackPlugin.java:465)\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.XPackPlugin.createComponents(XPackPlugin.java:314)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.node.Node.lambda$new$16(Node.java:709)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.plugins.PluginsService.lambda$flatMap$0(PluginsService.java:252)\n\tat java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273)\n\tat java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)\n\tat java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)\n\tat java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)\n\tat java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)\n\tat java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)\n\tat java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)\n\tat java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)\n\tat java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)\n\tat java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.node.Node.<init>(Node.java:724)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.node.Node.<init>(Node.java:318)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.bootstrap.Elasticsearch$2.<init>(Elasticsearch.java:214)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.bootstrap.Elasticsearch.initPhase3(Elasticsearch.java:214)\n\tat org.elasticsearch.server@8.5.3/org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:67)\nCaused by: org.elasticsearch.common.ssl.SslConfigException: cannot read configured [PKCS12] keystore (as a truststore) [/usr/share/elasticsearch/config/certs/transport.p12] because the file does not exist\n\tat org.elasticsearch.sslconfig@8.5.3/org.elasticsearch.common.ssl.SslFileUtil.fileNotFound(SslFileUtil.java:66)\n\tat org.elasticsearch.sslconfig@8.5.3/org.elasticsearch.common.ssl.SslFileUtil.ioException(SslFileUtil.java:37)\n\tat org.elasticsearch.sslconfig@8.5.3/org.elasticsearch.common.ssl.StoreTrustConfig.readKeyStore(StoreTrustConfig.java:98)\n\tat org.elasticsearch.sslconfig@8.5.3/org.elasticsearch.common.ssl.StoreTrustConfig.createTrustManager(StoreTrustConfig.java:82)\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.ssl.SSLService.createSslContext(SSLService.java:473)\n\tat java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)\n\tat org.elasticsearch.xcore@8.5.3/org.elasticsearch.xpack.core.ssl.SSLService.lambda$loadSslConfigurations$11(SSLService.java:603)\n\t... 23 more\nCaused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config/certs/transport.p12\n\tat java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)\n\tat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)\n\tat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)\n\tat java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)\n\tat java.base/java.nio.file.Files.newByteChannel(Files.java:380)\n\tat java.base/java.nio.file.Files.newByteChannel(Files.java:432)\n\tat java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:422)\n\tat java.base/java.nio.file.Files.newInputStream(Files.java:160)\n\tat org.elasticsearch.sslconfig@8.5.3/org.elasticsearch.common.ssl.KeyStoreUtil.readKeyStore(KeyStoreUtil.java:71)\n\tat org.elasticsearch.sslconfig@8.5.3/org.elasticsearch.common.ssl.StoreTrustConfig.readKeyStore(StoreTrustConfig.java:94)\n\t... 27 more\n"}

问题出在 elasticsearch.yml

我修改了 elasticsearch.yml ,修改后如下

cluster.name: "docker-cluster-elk8"
network.host: 0.0.0.0


#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 11-04-2023 09:05:45
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: false

问题就不复存在了

文件权限相关的解决办法参考:https://stackoverflow.com/questions/52897605/elasticsearch-docker-on-travis-fails-with-folder-access-denied

universe_king
3.4k 声望680 粉丝