Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to migrate data from elasticsearch and mongodb

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to migrate the data of elasticsearch and mongodb". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to migrate elasticsearch and mongodb data".

The tool needed for data migration in elasticsearch is elasticsearch-dump. We can directly use docker to pull the image.

Docker pull taskrabbit/elasticsearch-dump

Suppose the ip of the elasticsearch we want to export and the address of the index are http://192.168.192.197:9200/index_stores, the imported ip and the address are http://192.168.192.190:9200/index_stores,. If the index does not exist in the elasticsearch on http://192.168.192.190, we need to introduce the index information first.

Docker run-- rm-ti taskrabbit/elasticsearch-dump-- input= http://192.168.192.197:9200/index_stores-- output= http://192.168.192.190:9200/index_stores-- type=mapping

The data of the index will be introduced after the introduction is completed.

Docker run-- rm-ti taskrabbit/elasticsearch-dump-- input= http://192.168.192.197:9200/index_stores-- output= http://192.168.192.190:9200/index_stores-- type=data

At this point, all the data can be searched on 192.168.192.190.

The migration of mongodb needs to export files and import files.

First of all, of course, log in to mongodb, because I installed it here with docker, and I didn't set the user name or password.

Installed as follows (version 3.4)

Docker pull mongo:3.4

Create a mongo-data folder in your data disk and put it in the / home directory

Mkdir / home/mongo-data

Start the mongodb instance

Docker run-- restart= "always"-d-- name mymo-p 27017 always 27017-v / home/mongo-data:/data/db-v / etc/localtime:/etc/localtime mongo:3.4-- storageEngine wiredTiger

Docker exec-it mymo mongo

Query library

> show databases

Admin 0.000GB

Evaluate 0.000GB

Local 0.000GB

We're going to use evaluate.

> use evaluate

Switched to db evaluate

> show tables

Evaluate

Quit

Exit

Execution

Docker exec-it mymo mongoexport-d evaluate-c evaluate-o. / data/db/evaluate.json

Here-d is the specified library,-c is the specified table (also called collection in mongodb),-o is the output file, and here is the internal path of the container, because we specified the mapping of the external path-v / home/mongo-data:/data/db at startup, at this time we can find the evaluate.json file in / homg/mongo-data, put the file under the / home/mongo-data folder of the server of the mongodb to be imported, and execute

Docker exec-it evaluate mongoimport-d evaluate-c evaluate-- file. / data/db/evaluate.json

The data can be moved to the server we need.

Thank you for your reading, the above is the content of "how to migrate the data of elasticsearch and mongodb". After the study of this article, I believe you have a deeper understanding of how to migrate the data of elasticsearch and mongodb, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report