docker - Elastic search AccessDeniedException[/usr

我正在尝试使用 nfs mount 作为我的 elasticsearch 数据目录,之前我使用的是主机存储。 但是当我尝试启动我的容器时,我遇到了下面提到的错误:

 ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes/0];
es02    | Likely root cause: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes/0
es02    |   at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
es02    |   at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
es02    |   at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
es02    |   at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:388)
es02    |   at java.base/java.nio.file.Files.createDirectory(Files.java:694)
es02    |   at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:801)
es02    |   at java.base/java.nio.file.Files.createDirectories(Files.java:787)
es02    |   at org.elasticsearch.env.NodeEnvironment.lambda$new$0(NodeEnvironment.java:275)
es02    |   at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:212)
es02    |   at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:272)
es02    |   at org.elasticsearch.node.Node.<init>(Node.java:362)
es02    |   at org.elasticsearch.node.Node.<init>(Node.java:289)

我之前使用 docker-compose 时我的集群工作正常,当我使用主机存储时,但当我尝试切换到 NFS 存储时,我遇到了上述错误。 下面是我的 docker-compose 文件:

version: '3.3'
volumes:
  data:
    driver: local
    driver_opts:
       type: nfs
       device: ":/data1/elasticsearch_data"
       o: addr=10.10.15.46,rw
#volumes:
#  repo:
#    driver: local
#    driver_opts:
#       type: none
#       device: /apm_backup
#       o: bind
#
services:
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
    container_name: es02
    volumes:
      - data:/usr/share/elasticsearch/data
#      - ./unicast_hosts.txt:/usr/share/elasticsearch/config/unicast_hosts.txt
    environment:
      - node.name=es02
      - node.master=true
      - node.data=true
      - cluster.name=apm-docker-cluster
      - discovery.seed_hosts=es01
#      - discovery.seed_providers=file
      - cluster.initial_master_nodes=es01,es02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms10g -Xmx10g"
      - XPACK_SECURITY_ENABLED=false
#      - path.repo=/apm_backup
#    command: ["elasticsearch", "-Elogger.level=DEBUG"]
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    restart: "unless-stopped"
    logging:
      driver: 'json-file'
      options:
          max-size: '2m'
          max-file: '5'
    ports:
      - 9200:9200
      - 9300:9300
    extra_hosts:
      - "es01:10.10.26.27"
      - "es02:10.10.26.111"
      - "es03:10.10.26.111"
    network_mode: "host"
    labels:
      org.label-schema.group: "APM-monitoring"
    healthcheck:
      test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://es02:9200/"]
      retries: 10
      interval: 10s

This is my directory permission and location

到目前为止我尝试过的:

chown 1000:1000 elasticsearch_data(照片中提到的 vimzy 用户的 1000 uid)。

我在 docker-compose 中尝试过priviliged=true。 除此之外,还尝试了多种方法来解决权限被拒绝的问题。

任何帮助...

最佳答案

此错误是由于指定路径上的权限问题而发生的。

将路径从/usr/share/elasticsearch/data更改为/var/lib/elasticsearch/data

它会起作用的!

关于docker - Elastic search AccessDeniedException[/usr/share/elasticsearch/data/nodes/0] -- 拒绝访问错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65668188/

相关文章:

java - Java 是否根据结果假定类型?

amazon-web-services - `amplify push` 失败 - 属性 : Str

python - 如何从时间序列数据中选择前 n 列而不是在 pandas 中使用 nlargest

c++ - 重构为枚举以枚举类阴影命名空间

python - 如何连接来自 3 个小整数的字节以生成由 Python 中的这些字节表示的更大数字

c# - 使用 MVVM 绑定(bind) : Property not found in Xama

react-native - react native : Refresh Controll not

r - 如何在 R 中的数据框中重新编码数据

javascript - 句号、单词和冒号的正则表达式

arrays - 检查列表和数组是否相等 F#