Home  >  Article  >  Database  >  ubuntu mongodb安装及备份与恢复

ubuntu mongodb安装及备份与恢复

WBOY
WBOYOriginal
2016-06-07 16:26:36926browse

使用命令 apt-key adv keyserver keyserver.ubuntu.com recv 7F0CEB10 然后编辑源: vi?/etc/apt/sources.list 增加一行: deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen 然后更新并安装: apt-get update apt-get install mongo

使用命令

apt-key adv –keyserver keyserver.ubuntu.com –recv 7F0CEB10

然后编辑源:

vi?/etc/apt/sources.list

增加一行:

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

然后更新并安装:

apt-get update

apt-get install mongodb-10gen

这样安装下来就是最新稳定版本。

导出数据库:

mongodump -h localhost –db database_name -o /home/backup

注意-o参数是目录,然后恢复数据:

mongorestore -h localhost –db database_name –directoryperdb?/home/backup

由于导出后的数据库是多个.bson文件 ,可以打包方便保存或传输:

tar -zcvf ?./dump-name.tar.gz ?/home/backup

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn