在外部驱动器上存储elasticsearch索引

ffx8fchx  于 2023-04-20  发布在  ElasticSearch
关注(0)|答案(1)|浏览(141)

我想使用Docker来设置一个elasticsearch示例。我希望索引的文档来自一个外部驱动器,索引在另一个外部驱动器上创建(有TB的文档)。
这是我的docker-compose。

version: '3'

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: elasticsearch
    environment:
      - discovery.type=single-node
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - esdata:/usr/share/elasticsearch/data

  python:
    build: .
    container_name: python
    ports:
      - "80:80"
    volumes:
      - input_directory:_
    depends_on:
      - elasticsearch

volumes:
  esdata:
    driver_opts:
        type: "none"
        device: /media/user/usb_disk_name
        o: "bind"

我使用的是ubuntu 22,我的磁盘容量是512 Gb。docker compose up抛出Error response from daemon: failed to mount local volume: mount /media/user/usb_disk_name:/var/lib/docker/volumes/elastic_docker_esdata/_data, flags: 0x1000: no such file or directory。使用sudo,容器被错误137停止,据我所知,这是由于容器内存不足。
有什么想法我可以在docker上实现这个解决方案吗?提前感谢!

35g0bw71

35g0bw711#

我认为您的docker-compose.yml文件缺少esdata卷的挂载点,请尝试通过以下操作更新yml文件:

volumes:
  - type: bind
    source: /media/user/usb_disk_name
    target: /usr/share/elasticsearch/data

在更新中,esdata卷是用local驱动程序定义的。然后docker-compose.yml看起来像这样:

version: '3'

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: elasticsearch
    environment:
      - discovery.type=single-node
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - type: bind
        source: /media/user/usb_disk_name
        target: /usr/share/elasticsearch/data

  python:
    build: .
    container_name: python
    ports:
      - "80:80"
    volumes:
      - input_directory:_
    depends_on:
      - elasticsearch

volumes:
  esdata:
    driver: local

相关问题