Failed: psg.cabinet: error creating indexes for psg.cabinet: createIndex error: exception: unsupported geo index version { 2dsphereIndexVersion : 2dsphereIndexVersion: 3 }, only support versions: [1,2]
這是我同步線(xiàn)上的mongo資料報(bào)錯(cuò)的, 線(xiàn)上用的3.2.4 ,我觀察發(fā)現(xiàn)這個(gè)集合的索引是
{
"v" : 1,
"key" : {
"location.loc" : "2dsphere"
},
"name" : "location.loc_2dsphere",
"ns" : "psg.cabinet",
"2dsphereIndexVersion" : 3
}
然後我同步到本地的時(shí)候就報(bào)上面的錯(cuò),我的Mongo版本是 3.2.0,但加索引後是
{
"v" : 1,
"key" : {
"location.loc" : "2dsphere"
},
"name" : "location.loc_2dsphere",
"ns" : "psg.cabinet",
"2dsphereIndexVersion" : 2
}
請(qǐng)問(wèn)下 這裡的 2dsphereIndexVersion 怎麼去改3
光陰似箭催人老,日月如移越少年。
{2dsphereIndexVersion: 3}
是MongoDB 3.2開(kāi)始支持的新版本,3.2默認(rèn)使用這個(gè)版本創(chuàng)建2dsphere
索引。如果你建立索引時(shí)使用的不是這個(gè)版本,只能說(shuō)明你使用的版本不是3.2。請(qǐng)先檢查這一點(diǎn)。
另外原則上講不應(yīng)該把新版本的資料庫(kù)恢復(fù)到舊版本上(雖然不一定會(huì)造成問(wèn)題),所以你本地使用的mongodb版本應(yīng)該至少比線(xiàn)上要新。
關(guān)於version 3和version 2的區(qū)別有興趣可以看看這篇blog。