ddev + elasticsearch 最新版本的问题

Troubles with ddev + elasticsearch latest version

我在 DDEV 上尝试启动我的 ES 容器时遇到了一些麻烦。

我已经下载 official dockerfile from drud repository 并做了一些更改(版本、最大节点等),如您所见:

version: '3.6'
services:
  elasticsearch:
    container_name: ddev-${DDEV_SITENAME}-elasticsearch
    hostname: ${DDEV_SITENAME}-elasticsearch
    image: elasticsearch:6.8.0
    ports:
      - "9200"
      - "9300"
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - VIRTUAL_HOST=$DDEV_HOSTNAME
      - HTTP_EXPOSE=9200
      - node.max_local_storage_nodes=20
    ulimits:
      memlock:
        soft: -1
        hard: -1
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      - elasticsearch:/usr/share/elasticsearch/data
      - ".:/mnt/ddev_config"
  web:
    links:
      - elasticsearch:elasticsearch

volumes:
  elasticsearch:
    name: "${DDEV_SITENAME}-elasticsearch"

所以,当我 运行 ddev 启动时容器没有启动,因为我已经从 5.6 迁移到 6.8.0

输出

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. OpenJDK 64-Bit Server VM warning: UseAVX=2 is not supported on this CPU, setting it to UseAVX=1 [2020-03-04T17:32:31,770][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to create node environment at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.0.jar:6.8.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.0.jar:6.8.0] Caused by: java.lang.IllegalStateException: Failed to create node environment at org.elasticsearch.node.Node.(Node.java:299) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.node.Node.(Node.java:266) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Bootstrap.(Bootstrap.java:212) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.0.jar:6.8.0] ... 6 more Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes/1 at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?] at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389) ~[?:?] at java.nio.file.Files.createDirectory(Files.java:692) ~[?:?] at java.nio.file.Files.createAndCheckIsDirectory(Files.java:799) ~[?:?] at java.nio.file.Files.createDirectories(Files.java:785) ~[?:?] at org.elasticsearch.env.NodeEnvironment.lambda$new[=11=](NodeEnvironment.java:273) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.env.NodeEnvironment$NodeLock.(NodeEnvironment.java:206) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:270) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.node.Node.(Node.java:296) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.node.Node.(Node.java:266) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Bootstrap.(Bootstrap.java:212) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.0.jar:6.8.0]

顺便说一句,我正在使用 docker compose 3.6 版,因为 ddev 最新版本强制您使用它

您遇到此错误

.8.0.jar:6.8.0] ... 6 more Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes/1 at

这意味着您有一些权限问题,请检查文件的权限

    - elasticsearch:/usr/share/elasticsearch/data
      - ".:/mnt/ddev_config"

也许您还需要重新创建或迁移数据