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

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
主站蜘蛛池模板: 南充市| 郑州市| 扶绥县| 花莲市| 资中县| 仙桃市| 宿迁市| 连山| 英山县| 健康| 荔浦县| 综艺| 云阳县| 富裕县| 宁德市| 安化县| 仪征市| 巴东县| 师宗县| 尚志市| 长宁县| 西宁市| 松桃| 营口市| 西城区| 岳普湖县| 颍上县| 建水县| 蒙山县| 岳西县| 双鸭山市| 禹州市| 海阳市| 正镶白旗| 呼伦贝尔市| 邓州市| 沭阳县| 邻水| 稷山县| 休宁县| 神木县|