从3.2开始的MongoDB转储,使用3.4还原,错误索引安全=空 [英] MongoDB dump from 3.2, restore with 3.4, error index safe = null

查看:334
本文介绍了从3.2开始的MongoDB转储,使用3.4还原,错误索引安全=空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误(转储MongoDB 3.2)(还原MongoDB 3.4):

I get the following error (dump MongoDB 3.2) (restore MongoDB 3.4):

Failed: ngivr-dev.ledgerhelpers: error creating indexes for ngivr-dev.ledgerhelpers: **createIndex error:** **The field 'safe' is not valid for an index specification.** Specification: **{ unique: true, name: "ledgerId_1", safe: null, ns: "ngivr-dev.ledgerhelpers", background: true, key: { ledgerId: 1 } }**

看起来安全索引为null.但是我如何在MongoDB 3.4中使用它呢? 3.2还可以.

Looks like the safe index is null. But how can i use it with MongoDB 3.4? 3.2 is ok.

推荐答案

safe=true不是索引规范.

在MongoDB的早期版本(低于3.4)中,可以添加额外的索引规范.这些由特定的驱动程序使用.

In previous versions of MongoDB, lower than 3.4, extra indexes specifications can be added. Those were used by specific drivers.

在3.4中,mongodb添加了对索引规范的验证:

In 3.4, mongodb added a validation on indexes specification:

确保指定的索引选项有效.以前的 版本会忽略无效的选项.

Ensuring that the specified index options are valid. Previous versions ignored invalid options.

这就是为什么您会遇到此错误. 恐怕您需要确保3.2版本中的索引没有无效的索引规范,然后执行mongodump.

That's why you have this error. I am afraid you need to ensure that the index in your 3.2 version does not have invalid index specificaitons, and after that do the mongodump.

正如kz_sergey在他的回答中所说,您可以mongorestore使用 --noIndexRestore ,应该可以正常工作.

As kz_sergey says in his answer, you can mongorestore using --noIndexRestore, that should work fine.

这篇关于从3.2开始的MongoDB转储,使用3.4还原,错误索引安全=空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆