码迷,mamicode.com
首页 > 数据库 > 详细

阿里云mongodb物理备份还原

时间:2018-05-23 00:03:58      阅读:852      评论:0      收藏:0      [点我收藏+]

标签:fas   system   而且   html   admin   host   window   sock   database   

阿里云的文档地址 :

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

阿里云mongodb物理备份还原

标签:fas   system   而且   html   admin   host   window   sock   database   

原文地址:https://www.cnblogs.com/qtong/p/9074292.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!