
MongoDB所数据都存储数据目录默认/data/db/(WindowsC:\data\db\)启MongoDB用--dbpath指定我自设置数据存储目录
备份MongoDB数据:要简单创建数据存储目录副本直接copy份
恢复MongoDB数据:MongoDB启用--dbpath指定数据存储目录副本位置
服务器运行情况直接copy风险能copy数据已经遭破坏种式创建数据目录副本需要关闭MongoDB服务器前提数据目录存储关闭刻数据快照服务器重新启前复制目录作备份
,
1、导出某个库的所有集合
语法(大括号里面的代表可选):
mongodump -h host -d dbname -o directory [ --port port -u username -p password --authenticationDatabase admin ]
例子1(不需认证):
mongodump -h localhost -d study -o C:UsersxxxDesktop
例子2(需要认证):
mongodump -h localhost -d study -o C:UsersxxxDesktop --port 27017 -u root -p 123456 --authenticationDatabase admin
2、导入所有集合到某个库
语法(大括号里面的代表可选):
mongorestore -h dbhost -d dbname dbdirectory [ --port port -u username -p password --authenticationDatabase admin ]
例子1(不需认证):
mongorestore -h localhost -d testing C:UsersxxxDesktopstudy
例子2(需要认证):
mongorestore -h localhost -d testing C:UsersxxxDesktopstudy --port 27017 -u root -p 123456 --authenticationDatabase admin
改为./mongorestore --port 27100 /data/backup/mongodb
2、error RS102 too stale to catch up
主从同步的时候执行rs.status()查看的RS102错误。由于在启动的时候指定 --oplogSize=128,(主节点的oplog日志大小,单位为M,更改oplog大小时,删除local.*,然后加 --oplogSize=* 重新启动即可,*代表大小)在对主库大数据插入的时候,可能会出现来不及同步到从库的现象。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)