Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to migrate data from elasticsearch and mongodb

Shulou Source: shulou.com Published: 2022-06-02 07:23:33 09月11日 Update

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!

Tags: Data file index learning content address folder server path service information instance container password that is tools ideas situations articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei vpn Shulou Technology Shulou Information