官术网_书友最值得收藏!

How to do it...

  1. Start the mongod daemon to explicitly use MMAPv1 storage engine:
/data/mongodb/bin/mongod --dbpath /data/db --storageEngine mmapv1
  1. 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
}
  1. 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
  1. Exit the shell and perform a full backup using mongodump command:
mkdir /data/backup
mongodump -o /data/backup --host localhost:27017
  1. Now shutdown the mongod process.
  2. 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
  1. Let's restore the previous backup to this new instance:
mongorestore /data/backup/
  1. 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
主站蜘蛛池模板: 房山区| 本溪| 湟中县| 上栗县| 洞口县| 咸宁市| 介休市| 隆子县| 昭觉县| 静海县| 大关县| 泸州市| 邓州市| 缙云县| 朝阳县| 丹寨县| 宣城市| 安西县| 宁津县| 中方县| 乌拉特中旗| 女性| 镇赉县| 鹤峰县| 科尔| 故城县| 邵武市| 东明县| 石首市| 宁阳县| 宣化县| 乐山市| 四平市| 志丹县| 洞口县| 青海省| 许昌县| 惠水县| 嫩江县| 泸西县| 集贤县|