- MongoDB Administrator’s Guide
- Cyrus Dasadia
- 304字
- 2021-07-02 15:47:44
How it works...
As WiredTiger is the default storage engine for MongoDB 3.2, for this exercise, we explicitly started a MongoDB instance with MMAPv1 storage engine in step 1. In step 2, we stored the db.serverStatus() command's output in a temporary variable to inspect the output of the server's storageEngine key. This helps us see which storage engine our MongoDB instance is running on. In step 3, we switched to database mydb and ran a simple JavaScript function to add 100 documents to a collection called mycol. Next, in step 4, we created a backup directory /data/backup which is passed as a parameter to mongodump utility. We will discuss more about the mongodump utility in Chapter 6, Managing MongoDB Backups.
Once we shutdown the mongod instance, in step 5, we are now ready to start a new instance of MongoDB but this time with WiredTiger storage engine. We follow the basic practice of covering for failure and instead of removing /data/db, we create a new path for this instance (#AlwaysHaveABackupPlan). Our new MongoDB instance is empty, so in step 7 we import the aforementioned backup into the database using the mongorestore utility. As the new MongoDB instance is running WiredTiger storage engine, our backup (which is essentially BSON data) is restored and saved on disk using this storage engine. Lastly, in step 8, we simply inspect the storageEngine key on the db.serverStatus() output and confirm that we are indeed using WiredTiger.
As you can see, this is an overly simplistic example of how to convert MongoDB data from one storage engine format to another. One has to keep in mind that this operation will take a significant amount of time depending on the size of data. However, application downtime can be averted if we were to use a replica set. More on this later.
- C語言程序設(shè)計案例教程
- Android開發(fā)精要
- Java應(yīng)用開發(fā)與實踐
- 重學(xué)Java設(shè)計模式
- iOS應(yīng)用逆向工程(第2版)
- 碼上行動:用ChatGPT學(xué)會Python編程
- Mastering JavaScript Design Patterns(Second Edition)
- 大學(xué)計算機基礎(chǔ)實驗指導(dǎo)
- Microsoft Azure Storage Essentials
- Python算法詳解
- Access 2010數(shù)據(jù)庫應(yīng)用技術(shù)實驗指導(dǎo)與習(xí)題選解(第2版)
- Learning iOS Security
- Learning Unreal Engine Game Development
- 前端架構(gòu)設(shè)計
- MATLAB從入門到精通