草庐IT

mongodb - mongorestore 不会跳过没有/stopOnError 标志的错误

coder 2023-10-26 原文

我使用 mongo 2.6.4/Windows Server 2012 R2。

Mongodump 生成了两个转储文件:mongodump -d mydb

  • 交易.bson
  • transaction.metadata.json

  • 我尝试通过 mongorestore (2.6.4) 恢复此信息:
    mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb
    但是工具返回错误(进度 ~23%):
    2015-08-17T19:45:51.844+0400 Failed: restore error: mydb.transaction: error restoring from F:\restore\transaction.bson: insertion error: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469')
    所以我决定通过标志来扩展它:
    mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb --drop --noIndexRestore --noOptionsRestore --noobjcheck --filter "{'_id' : { $ne: '528dc7c03599b01214d17469' }}" F:/restore/transaction.bson
    并再次出现相同的错误。

    所以我尝试使用 3.0 版本的 mongorestore:
    mongorestore /host 127.0.0.1 /port 27018 /collection transaction /db mydb /drop /noIndexRestore /noOptionsRestore /keepIndexVersion F:/restore/transaction.bson
    并再次出现相同的错误。

    我希望它有所帮助,因为我没有使用/stopOnError 标志。但事实并非如此。
    它总是以 ~23% 的速度失败。

    这是MongoDB日志的一部分:
    2015-08-17T19:14:32.447+0400 [conn8] Assertion: 10307:Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469') 2015-08-17T19:14:32.532+0400 [conn6] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:181893 181ms 2015-08-17T19:14:32.743+0400 [conn9] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:211264 211ms 2015-08-17T19:14:32.921+0400 [conn7] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:176525 177ms 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\stacktrace.cpp(169) mongo::printStackTrace+0x43 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\log.cpp(127) mongo::logContext+0x9c 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(183) mongo::msgasserted+0xfb 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(174) mongo::msgasserted+0x13 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\dbmessage.cpp(116) mongo::DbMessage::nextJsObj+0x11f 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(898) mongo::receivedInsert+0x18f 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(484) mongo::assembleResponse+0x7c9 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\db.cpp(202) mongo::MyMessageHandler::process+0x111 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\net\message_server_port.cpp(210) mongo::PortMessageServer::handleIncomingMsg+0x671 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(185) boost::'anonymous namespace'::thread_start_function+0x21 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314) _callthreadstartex+0x17 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292) _threadstartex+0x7f 2015-08-17T19:14:36.250+0400 [conn8] KERNEL32.DLL BaseThreadInitThunk+0xd 2015-08-17T19:14:36.250+0400 [conn8] 2015-08-17T19:14:36.255+0400 [conn8] insert mydb.transaction keyUpdates:0 exception: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469') code:10307 numYields:0 0ms
    我想从这个文件中读取数据,但它很大(18 Gb)。
    如果会跳过一些记录也没关系。

    有谁知道如何解决这个问题?

    最佳答案

    mongodump最好转储整个数据库。如果您只想处理一个集合,请尝试导出 transaction收藏与 mongoexport喜欢 mongoexport --collection transaction --db mydb --out transaction.json并使用 mongoimport --collection transaction --db mydb --file transaction.json 导入它.
    如果您正在恢复一个完整的转储并且它因某个集合而失败,那么您可以使用以下标志 --excludeCollection transaction 在没有违规集合的情况下进行恢复。

    关于mongodb - mongorestore 不会跳过没有/stopOnError 标志的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32055177/

    有关mongodb - mongorestore 不会跳过没有/stopOnError 标志的错误的更多相关文章

    1. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

      大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

    2. ruby - 难道Lua没有和Ruby的method_missing相媲美的东西吗? - 2

      我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/

    3. ruby-on-rails - rails 目前在重启后没有安装 - 2

      我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

    4. ruby - Highline 询问方法不会使用同一行 - 2

      设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案

    5. ruby - 在没有 sass 引擎的情况下使用 sass 颜色函数 - 2

      我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re

    6. ruby-on-rails - 项目升级后 Pow 不会更改 ruby​​ 版本 - 2

      我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby​​版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby​​版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘

    7. ruby-on-rails - 跳过状态机方法的所有验证 - 2

      当我的预订模型通过rake任务在状态机上转换时,我试图找出如何跳过对ActiveRecord对象的特定实例的验证。我想在reservation.close时跳过所有验证!叫做。希望调用reservation.close!(:validate=>false)之类的东西。仅供引用,我们正在使用https://github.com/pluginaweek/state_machine用于状态机。这是我的预订模型的示例。classReservation["requested","negotiating","approved"])}state_machine:initial=>'requested

    8. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

      我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

    9. ruby-on-rails - 如何在 Rails View 上显示错误消息? - 2

      我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c

    10. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

      我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

    随机推荐