简体   繁体   English

如何将 Elasticsearch 迁移到新服务器?

[英]How to migrate Elasticsearch to a new server?

The old server will remove, that Elasticsearch version is v6.8, the new server installed same version.旧服务器将删除,即 Elasticsearch 版本为 v6.8,新服务器安装相同版本。 Now, I'll migrate all data to the new server.现在,我将所有数据迁移到新服务器。 Is my operation correct?我的操作正确吗?

  1. Old server: elasticsearch.yml add path.repo , for example旧服务器: elasticsearch.yml添加path.repo ,例如
path.repo:["/data/backup"]
  1. Restart Elasticsearch services重启 Elasticsearch 服务

  2. Old server旧服务器

curl -H "Content-Type: application/json" 
    -XPUT  http://192.168.50.247:9200/_snapshot/my_backup 
    -d '{ "type": "fs", "settings": 
    { "location": "/data/backup","compress": true }}'
  1. Create backup创建备份
curl -XPUT http://192.168.50.247:9200/_snapshot/my_backup/news0618
  1. Restore database(new server ip:192.168.10.49 ):恢复数据库(新服务器ip:192.168.10.49):
curl -XPOST http://192.168.10.49:9200/_snapshot/my_backup/news0618/_restore

Are these operations can migrate all the data?这些操作是否可以迁移所有数据?

If you are using fs as a snapshot repository location then it will not work as your new instance is hosted on different host it will not have access to your old hosts file system.如果您使用fs作为快照存储库位置,那么它将无法工作,因为您的新实例托管在不同的主机上,它将无法访问您的旧主机文件系统。 You need to use any shared location like volume mounts, S3 or Azure blob etc.您需要使用任何共享位置,如卷挂载、S3 或 Azure blob 等。

You should use reindexing rather than snapshot and restore .您应该使用reindexing而不是snapshot and restore Its pretty simpler.它相当简单。 Refer this link for remote reindexing:请参阅此链接以进行远程重新索引:

Steps:脚步:

  1. Whitelist remote host in elasticsearch.yaml using the reindex.remote.whitelist property in your new Elasticsearch instance:白名单远程主机在elasticsearch.yaml使用reindex.remote.whitelist在新Elasticsearch实例的属性:

     reindex.remote.whitelist: "192.168.50.247:9200"
  2. Restart new Elasticsearch instance.重启新的 Elasticsearch 实例。

  3. Reindexing:重新索引:

     curl -X POST "http://192.168.10.49:9200/_reindex?pretty" -H 'Content-Type: application/json' -d' { "source": { "remote": { "host": "http://192.168.50.247:9200" }, "index": "source-index-name", "query": { "match_all": {} } }, "dest": { "index": "dest-index-name" } } '

Refer this link for reindexing many indices请参阅此链接以重新索引许多索引

Warning: The destination should be configured as wanted before calling _reindex .警告:在调用_reindex之前,应根据需要配置目标。 Reindex does not copy the settings from the source or its associated template. Reindex 不会从源或其关联模板复制设置。 Mappings, shard counts, replicas, and so on must be configured ahead of time.映射、分片计数、副本等必须提前配置。

Hope this helps!希望这可以帮助!

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

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