简体   繁体   English

如何在Docker上将数据导入Elasticsearch?

[英]How to import data to Elasticsearch on docker?

I made export from Elasticsearch on one machine and now want to import these data into another machine, where I have Elasticsearch running on docker. 我在一台计算机上从Elasticsearch导出,现在想将这些数据导入另一台计算机,在那里我在docker上运行Elasticsearch。

This is the Elasticsearch-related content in docker-compose file: 这是docker-compose文件中与Elasticsearch相关的内容:

elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.5.0
    environment:
      - cluster.name=my-docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - xpack.security.enabled=false
      - http.host=0.0.0.0
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    cap_add:
      - IPC_LOCK
    volumes:
      - ./src/elastic:/home
    ports:
      - 9200
      - 9300
    networks:
      - my_network

The elastic search container is up and running. 弹性搜索容器已启动并正在运行。 However, I do not know how to import the data. 但是,我不知道如何导入数据。

I found out the IP of Elasticsearch container (specified as XXX.XX.XX.X below) and executed the following command: 我找到了Elasticsearch容器的IP(在下面指定为XXX.XX.XX.X )并执行了以下命令:

curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
  "type": "fs",
  "settings": {
    "location": "/home/test/etk_backup/myproject_backup"
  }
}' "http://XXX.XX.XX.X:9200/_snapshot/myproject_backup"

But got this error: 但是出现了这个错误:

{"error":{"root_cause":[{"type":"repository_exception","reason":"[myproject_backup] location [/home/test/etk_backup/myproject_backup] doesn't match any of the locations specified by path.repo because this setting is empty"}] {“ error”:{“ root_cause”:[{“ type”:“ repository_exception”,“ reason”:“ [myproject_backup] location [/ home / test / etk_backup / myproject_backup]与路径指定的任何位置都不匹配.repo,因为此设置为空“}]

I entered into the container of Elasticsearch and manually specified path.repo in elasticsearch.yml as follows: 我进入Elasticsearch的容器和手动指定path.repoelasticsearch.yml如下:

path-repo: ["/home/test/etk_backup/myproject_backup"]

But got the same error. 但是得到了同样的错误。 How can I solve this issue? 我该如何解决这个问题?

尝试以下方法:

path.repo: ["/home/test/etk_backup/myproject_backup"]

To mention a convenient tool for this: we've been using Elasticdump to copy data from one index to another (typically for developers to have data in their local index). 要提到一个方便的工具:我们一直在使用Elasticdump将数据从一个索引复制到另一个索引(通常供开发人员在其本地索引中存储数据)。 It's not clear if it's still maintained, but it still works for us on ES6.3 目前尚不清楚它是否仍在维护,但在ES6.3上仍然可以使用

You would use it like so: 您可以这样使用它:

$ npm install elasticdump -g
$ elasticdump --input=https://XXX.XX.XX.X:9200/<index> --output /tmp/es-mapping --type=mapping --headers='{"Content-Type": "application/json"}'
$ elasticdump --input=https://XXX.XX.XX.X:9200/<index> --output /tmp/es-data --type=data --headers='{"Content-Type": "application/json"}' [--searchBody '<some query to filter what's being copied>']
$ elasticdump --input /tmp/es-mapping --output https://YYY.YY.YY.Y:9200/<index> --type mapping
$ elasticdump --input /tmp/es-data --output https://YYY.YY.YY.Y:9200/<index> --type data

You probably don't need the intermediate step of saving to a file, but I find it a nice thing to have in cases where you're experimenting locally and need to reload the index when your experiment failed in a destructive manner. 您可能不需要保存到文件的中间步骤,但是当您在本地进行实验并且在实验以破坏性方式失败时需要重新加载索引时,我发现这是一件很不错的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM