mongo从2.2.2用mongodump导数据到2.4.6时报下面的错。
Wed Sep 18 11:42:49 5662540036/5670385368 99% (bytes)Wed Sep 18 11:42:52 5667244236/5670385368 99% (bytes)
9301940 objects found
Wed Sep 18 11:42:54 Creating index: { key: { _id: 1 }, ns: "dms.DataInfo", name: "_id_" }
Wed Sep 18 11:42:58 Creating index: { key: { dataId: 1, name: "dataId_index" }, ns: "dms.DataInfo", name: "dataId_1_name_dataId_index", background: "true" }
Wed Sep 18 11:42:58 ERROR: Error creating index dms.DataInfo: 16734 err: "Unknown index plugin 'dataId_index' in index { dataId: 1, name: "dataId_index" }"
数据导完了,但在创建索引时报了上面的错误。而且之前从2.2.2导到2.2.2是没问题的。
查看索引:
> db.DataInfo.getIndexes();db.DataInfo.getIndexes();[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "dms.DataInfo",
"name" : "_id_"
}
]
正常情况应该创建6条索引。
直接创建
> db.DataInfo.ensureIndex({"dataId":1,"name":"dataId_index"},{"background":"true"});{
"err" : "Unknown index plugin 'dataId_index' in index { dataId: 1.0, name: \"dataId_index\" }",
"code" : 16734,
"n" : 0,
"connectionId" : 7,
"ok" : 1
}
报同样的错误
分析原因:
原因,版本不兼容。2.4与2.2。在2.4认为上面的书写格式不正确。
http://docs.mongodb.org/manual/release-notes/2.4-index-types/
解决方法:
将上面创建索引的语句修改:
> db.DataInfo.ensureIndex({"dataId":1},{name:"dataId_index"},{"background":"true"});手工创建所有索引。
后台log如下:
Wed Sep 18 22:32:12.475 [conn7] build index dms.DataInfo { dataId: 1.0 }
Wed Sep 18 22:32:22.659 [conn7] Index: (1/3) External Sort Progress: 3000000/9301940 32%
Wed Sep 18 22:32:32.000 [conn7] Index: (1/3) External Sort Progress: 6263600/9301940 67%
Wed Sep 18 22:32:40.950 [conn7] external sort used : 10 files in 28 secs
Wed Sep 18 22:32:59.848 [conn7] Index: (2/3) BTree Bottom Up Progress: 1689000/9301940 18%
Wed Sep 18 22:33:09.000 [conn7] Index: (2/3) BTree Bottom Up Progress: 3671000/9301940 39%
Wed Sep 18 22:33:19.802 [conn7] Index: (2/3) BTree Bottom Up Progress: 6014000/9301940 64%
Wed Sep 18 22:33:19.939 [initandlisten] connection accepted from 192.168.112.91:52403 #24 (4 connections now open)
Wed Sep 18 22:33:22.930 [conn24] end connection 192.168.112.91:52403 (3 connections now open)
Wed Sep 18 22:33:28.885 [initandlisten] connection accepted from 192.168.112.91:52425 #25 (4 connections now open)
Wed Sep 18 22:33:29.000 [conn7] Index: (2/3) BTree Bottom Up Progress: 8040300/9301940 86%
Wed Sep 18 22:33:33.615 [conn7] done building bottom layer, going to commit
Wed Sep 18 22:33:50.043 [conn7] build index done. scanned 9301940 total records. 97.568 secs
Wed Sep 18 22:33:50.045 [conn7] insert dms.system.indexes ninserted:1 keyUpdates:0 locks(micros) w:97568483 97568ms