手机版
你好,游客 登录 注册
背景:
阅读新闻

MongoDB数据库文档大全

[日期:2012-03-24] 来源:Linux社区  作者:wangkuifeng0118 [字体:大 中 小]

MongoDB的数据恢复工具 mongorestore

查看test库中的表

  1. > show collections
  2. system.indexes
  3. User

删除user表

  1. > db.user.drop();
  2. True

  3. > show collections
  4. System.indexes

现在利用mongorestore表恢复刚才利用 mongodump备份的数据

  1. [falcon@www.fwphp.cn  ~/mongodb/bin]$ ./mongorestore --help
  2. usage: ./mongorestore [options] [directory or filename to restore from]
  3. options:
  4.   --help                  produce help message
  5.   -h [ --host ] arg       mongo host to connect to
  6.   -d [ --db ] arg         database to use
  7.   -c [ --collection ] arg collection to use (some commands)
  8.   -u [ --username ] arg   username
  9.   -p [ --password ] arg   password
  10.   --dbpath arg            directly access mongod data files in this path,
  11.                           instead of connecting to a mongod instance
  12.   -v [ --verbose ]        be more verbose (include multiple times for more
  13.                           verbosity e.g. -vvvvv)

  14. [falcon@www.fwphp.cn  ~/mongodb/bin]$ ./mongorestore -d test -c user test/test/user.bson
  15. connected to: 127.0.0.1
  16. test/test/user.bson
  17.          going into namespace [test.user]

  18.          100000 objects

User表中的10w条记录已经恢复

  1. > show collections
  2. system.indexes
  3. user
  4. > db.user.find();
  5. { "_id" : ObjectId("4b9c8db08ead0e3347000000"), "uid" : 1, "username" : "Falcon.C-1" }
  6. { "_id" : ObjectId("4b9c8db08ead0e3347010000"), "uid" : 2, "username" : "Falcon.C-2" }
  7. { "_id" : ObjectId("4b9c8db08ead0e3347020000"), "uid" : 3, "username" : "Falcon.C-3" }
  8. { "_id" : ObjectId("4b9c8db08ead0e3347030000"), "uid" : 4, "username" : "Falcon.C-4" }
  9. { "_id" : ObjectId("4b9c8db08ead0e3347040000"), "uid" : 5, "username" : "Falcon.C-5" }
  10. .................
  11. has more

mongodb还提供了HTTP查看运行 状态及restfull的接口
默认的访问端口 是28017linux
相关资讯       MongoDB 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款