阿里云mongodb物理备份还原

阿里云的文档地址 :

https://help.aliyun.com/document_detail/62408.html?spm=a2c4g.11186623.6.634.fwCNio

https://help.aliyun.com/document_detail/58329.html 

阿里云要求mongo版本3.2以上 我在本地windows搞了一顿没有搞ok(关键是现在的都是ssl版本的mongo启动各种报错而且没有资料查), 遂找了台linux服务器记录如下

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.15.tgz

tar -zxvf mongodb-linux-x86_64-rhel70-3.4.15.tgz -C /mongo/

tar -zxvf hins1_data_20180519130838.tar.gz -C /mongo/data/

cd /mongo

bin/mongo --config mongo.conf

mongo.conf内容(阿里云官网的内容 路径我改了下 )

 systemLog:
     destination: file
     path: /path/to/mongo/mongod.log
     logAppend: true
 security:
     authorization: enabled
 storage:
     dbPath: /path/to/mongo/data
     directoryPerDB: true
 net:
     http:
         enabled: false
     port: 27017
     unixDomainSocket:
         enabled: false
 processManagement:
     fork: true
     pidFilePath: /path/to/mongo/mongod.pid

cd bin

还原整个库

./mongodump -o data

./mongorestore --host 192.168.1.1 data

以上为全部内容记录

一下为平常用mongo导入导出的一些命令

cd /website/mongo/mongo/bin

./mongo --host 127.0.0.1:19891

./mongod --dbpath=/website/mongo/data/db --port=19891 --fork --logpath=/website/mongo/data/logs/mongo.log

单个库

/website/mongo/mongo/bin/mongodump --port 19891 -d db1 -o db1

./mongorestore --host dds-2-pub.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p passwd dump/ 

单个collection

./mongoexport -h dds-2-pub.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p passwd -d db1 -c collect1 -o db1c1

./mongoimport -h 127.0.0.1:19891 -d db1 -c collection1 --type json --file db1c1

 

实际恢复例子

 mongodump --host 1.1.1.1:27401 -d qh -o databak

mongorestore -h 127.0.0.1:27017 -d qh -o databak/qh  

还原有时候不需要-o

转载于:https://www.cnblogs.com/qtong/p/9074292.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值