设为首页 收藏本站
查看: 1964|回复: 0

[经验分享] mongodb 的备份和还原

[复制链接]

尚未签到

发表于 2015-7-8 11:43:02 | 显示全部楼层 |阅读模式
  
1.使用
  导出:mongodump -h 10.0.0.12:10006 -d test
导入:mongorestore -h 10.0.0.11:10006 -d test  dump/test/
2.命令的手册
  NAME
       mongodump - the Mongo dump tool
                            mongo转存工具
SYNOPSIS
       mongodump [OPTIONS]
DESCRIPTION
       mongodump is a tool to output a binary representation of a database.  It is mostly used for doing hot backups of a database.
       mongodump是一个把数据库以二进制形式导出的工具。它主要用来热备数据库。
OPTIONS
       --help show usage information
              使用帮助
       -h, --host HOST
              server to connect to (default HOST=localhost)
              连接的服务器
       -d, --db DATABASE
              database to use
              使用的数据库
       -c, --c COLLECTION
              collection to use
              使用的表
       -o, --out FILE
              output file, if not specified, stdout is used
              输出文件,如果不指定,就使用标准输出
       --dbpath PATH
              directly access mongod data files in this path, instead of connecting to a mongod instance
              取代连接mongo的实现,直接访问数据库文件。
COPYRIGHT
       Copyright 2007-2009 10gen
SEE ALSO
       For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
       更多信息看mongodb的wiki,http://www.mongodb.org.
AUTHOR
       Kristina Chodorow
NAME
       mongorestore - the Mongo restoration tool
                               Mongo恢复工具
DESCRIPTION
       mongorestore is a tool to use the output from mongodump to restore a database.
       mongorestore 是使用mongodump导出的内容来恢复一个数据库
OPTIONS
       --help show usage information
              展示使用的帮助信息
       --version
              show version information
              展示版本信息,(-v不能用)
       -h, --host HOST
              server to connect to (default HOST=localhost)
              要连接的服务器(默认 HOST=localhost),
       -port arg
              server port. Can also use --host hostname:port
              服务器端口,也能使用 --host hostname:port(也能是 -h)
       --ipv6 enable IPv6 support (disabled by default)
              支持IPv6功能(默认不开启)
       -u|--username USERNAME
              specify user to log in as
              登录用户名
       -p|--password PASSWORD
              specify password of user (notice there is no space)
              登录密码(没有空格)
       -d, --db DATABASE
              database to use
              要使用的数据库
       -c, --c COLLECTION
              collection to use
              使用的表
       --dbpath PATH
              directly access mongod data files in this path, instead of connecting to a mongod instance
              访问mongod数据文件的目录,取代连接mongod的方式
       --directoryperdb
              if dbpath specified, each db is in a separate directory
              如果dbpath设置了,每个数据库都在一个独立的目录
       --objcheck
              validate object before inserting
              插入数据之前先验证对象
       --filter arg
              filter to apply before inserting
              插入数据之前先过滤
       --drop drop each collection before import
              引入之前先删除每个表。
       --oplogReplay
              Replays the oplog after restoring the dump to ensure that the current state of the database reflects the point-in-time backup captured with the “mongodump --oplog” command.
              恢复导出日志的录制操作日志,确保当前的数据库的状态,还原从某个点使用“mongodump --oplog”命令抓获的数据。
COPYRIGHT
       Copyright 2007-2011 10gen
SEE ALSO
       For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org
AUTHOR
       Kristina Chodorow
3.命令的介绍
  mongodump is a utility for creating a binary export of the contents of a database. Consider using this utility as part an effective backup strategy. Use in conjunction with mongorestore to provide restore functionality.
mongodump是将数据库内容导出二进制的输出,是一个有效的备份策略。结合 mongostore得到一个功能。
If you use the mongodump tool from the 2.2 distribution to create a dump of a database, you can restore that dump only to a 2.2 database.
如果使用mongodump工具的操作的数据库是2.2,那么只能导入2.2的数据库。
To connect to a replica set, use the --host argument with a setname, followed by a slash and a comma separated list of host names and port numbers.
如果连接到一个复制集,使用 --host 参数+主机集合,使用斜杠和一个逗号分隔主机。举例:
mongodump --host repl0/mongo0.example.net,mongo0.example.net:27018,mongo1.example.net,mongo2.example.net

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-84461-1-1.html 上篇帖子: mongodb.conf 下篇帖子: Mongodb的一些基本概念
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表