In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what are the steps of Mongodb data migration". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Requirements: need to migrate mongodb data from one linux to another linux
Example: a migrates to B
Scheme:
You can complete the task with two commands:
Export of data: mongoexport
Data import: mongoimport
Specific steps:
Export:
1. Find the directory where the mongoexport of A's mongodb is located.
For example: cd / usr/local/mongodb/bin
two。 Export the data, execute the command:. / mongoexport-d DataBaseName-c CollectionName-o XXX.dat
Where DataBaseName is the database name, CollectionName is the collection name, and XXX.dat is the exported name
The exported XXX.dat will be in the same directory as mongoexport.
For example:. / mongoexport-d Student-c StudentInfo-o StudentInfo.dat
Export the collection StudentInfo under the database Student to the same directory as mongoexport and name it StudentInfo.dat
3. Follow the steps above to export all collections, and the export is complete.
Import:
4. To move the exported collection data to the same directory as mongoimport on server B, you can use the command:
Sudo mv / tmp/XXX.dat / db/mongo/bin (move XXX.dat to / db/mongo/bin directory)
5. Find the directory where the mongoimport of B is located: cd / db/mongo/bin
6. Import the data and execute the command:
. / mongoimport-h 127.0.0.1:port-u xxx- p xxx-d DataBaseName-c CollectionName XXX.dat
Where DataBaseName is the database name, CollectionName is the collection name, and XXX.dat is the imported collection
For example:
. / mongoimport-h 127.0.0.1 zhangsan 27017-u zhangsan-p zhangsan-d Student-c StudentInfo StudentInfo.dat
-h 127.0.0.1 purl 27017: connect locally, port number is 27017
-u zhangsan: user name is zhangsan
-p zhangsan: password is zhangsan
-d Student-c StudentInfo StudentInfo.dat: import StudentInfo.dat into the database name Student and the collection name StudentInfo.
Migration complete.
This is the end of the content of "what are the steps for Mongodb data migration". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.