- MongoDB Administrator’s Guide
- Cyrus Dasadia
- 187字
- 2021-07-02 15:47:44
How to do it...
- Start the mongod daemon to explicitly use MMAPv1 storage engine:
/data/mongodb/bin/mongod --dbpath /data/db --storageEngine mmapv1
- Start the mongo client and you should be presented with the MongoDB shell. Execute the following commands in the shell:
> var status = db.serverStatus()
> status['storageEngine']
{
"name" : "mmapv1",
"supportsCommittedReads" : false,
"readOnly" : false,
"persistent" : true
}
- Now let's add some random data into it. Run the following JavaScript code to insert 100 documents with random data:
> use mydb
> for(var x=0; x<100; x++){
db.mycol.insert({
age:(Math.round(Math.random()*100)%20)
})
}
> db.mycol.count()
100
- Exit the shell and perform a full backup using mongodump command:
mkdir /data/backup
mongodump -o /data/backup --host localhost:27017
- Now shutdown the mongod process.
- Create a new data directory for the migration and start the mongod daemon with a new storage engine:
mkdir /data/newdb
/data/mongodb/bin/mongod --dbpath /data/newdb --storageEngine wiredTiger
- Let's restore the previous backup to this new instance:
mongorestore /data/backup/
- Start the mongo shell and check your data:
> var status = db.serverStatus()
> status['storageEngine']
{
"name" : "wiredTiger",
"supportsCommittedReads" : true,
"readOnly" : false,
"persistent" : true
}
> use mydb
switched to db mydb
> db.mycol.count()
100
推薦閱讀
- The Complete Rust Programming Reference Guide
- Django+Vue.js商城項(xiàng)目實(shí)戰(zhàn)
- Java加密與解密的藝術(shù)
- Mastering Rust
- Visual C++應(yīng)用開(kāi)發(fā)
- C語(yǔ)言程序設(shè)計(jì)
- Java SE實(shí)踐教程
- 汽車人機(jī)交互界面整合設(shè)計(jì)
- Web程序設(shè)計(jì):ASP.NET(第2版)
- Python+Office:輕松實(shí)現(xiàn)Python辦公自動(dòng)化
- 計(jì)算思維與Python編程
- WCF編程(第2版)
- Learning Apache Thrift
- MATLAB計(jì)算機(jī)視覺(jué)實(shí)戰(zhàn)
- R語(yǔ)言編程基礎(chǔ)