嵌套的 Elasticsearch 快照:RepositoryException 位置与 path.repo 指定的任何位置都不匹配,因为此设置为空

Elasticsearch snapshot nested: RepositoryException location doesn't match any of the locations specified by path.repo because this setting is empty

我 运行 elk stack on top of docker using this docker compose:

...
elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION}
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
      - node.name=elasticsearch
      - discovery.seed_hosts=elasticsearch,es02
      - discovery.zen.minimum_master_nodes=1

      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - ELASTIC_PASSWORD=changeme
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9201:9200

    networks:
      - elk
...

在 kibana 开发控制台中,当我发送放置请求进行备份时,出现以下错误:

PUT /_snapshot/my_backup
{
"type": "fs",
"settings": {
"location": "/backup/my_backup"
}
}

错误:

{
"error": "RepositoryException[[my_backup] failed to create repository]; nested: CreationException[Guice creation errors:\n\n1) Error injecting constructor, org.elasticsearch.repositories.RepositoryException: [my_backup] location [/backup/my_backup] doesn't match any of the locations specified by path.repo because this setting is empty\n at org.elasticsearch.repositories.fs.FsRepository.(Unknown Source)\n while locating org.elasticsearch.repositories.fs.FsRepository\n while locating org.elasticsearch.repositories.Repository\n\n1 error]; nested: RepositoryException[[my_backup] location [/backup/my_backup] doesn't match any of the locations specified by path.repo because this setting is empty]; ",
"status": 500
}

您可以在您的环境中添加path.repo:

elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION}
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
      - node.name=elasticsearch
      - discovery.seed_hosts=elasticsearch,es02
      - discovery.zen.minimum_master_nodes=1
      # - node.master=true
      # - node.data=true
      # - network.host=0.0.0.0
      # # - http.port=9201

      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - ELASTIC_PASSWORD=changeme
      - path.repo=/backup/my_backup
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9201:9200

    networks:
      - elk