你好,游客 登录 注册 搜索
背景:
阅读新闻

MongoDB从3.0.7升级到MongoDB3.2

[日期:2015-12-21] 来源:Linux社区  作者:ligaofeng [字体:大 中 小]

mongodb3.2版本于前天2015-12-08日刚刚发布,下载地址为:https://www.mongodb.org/downloads#production

Starting in 3.2, MongoDB uses the WiredTiger as the default storageengine.

从3.2版本开始,mongodb使用WiredTiger作为默认的存储引擎。

原3.0.7的启动命令为:

# /mnt/local/mongodb/bin/mongod --storageEngine wiredTiger --config /mnt/local/mongodb/bin/mongodb.conf

其中mongodb.conf配置文件的内容为:

port=27017 #端口
dbpath= /mnt/data/mongodb #数据文件存放目录
logpath= /mnt/logs/mongodb/mongodb.log #日志文件存放目录
logappend=true #使用追加的方式写日志
fork=true #以守护程序的方式启用,即在后台运行
maxConns=500 #最大同时连接数
bind_ip=127.0.0.1 #只允许通过本机访问
noauth=true #不启用验证

备份现有数据库(数据库名为ddc,备份到/mnt/wwwroot目录下)

# /mnt/local/mongodb/bin/mongodump -h 127.0.0.1 -d ddc -o /mnt/wwwroot/ddc.dmp

下载3.2.0版本(我的操作系统为CentOS6.6)

# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.0.tgz

# tar zxvf mongodb-linux-x86_64-rhel62-3.2.0.tgz

# ps aux | grep mongod

# kill -2 进程号

# mv /mnt/local/mongo /mnt/local/mongo_bak

# mv mongodb-linux-x86_64-rhel62-3.2.0 /mnt/local/mongodb

# cp /mnt/local/mongo_bak/bin/mongodb.conf /mnt/local/mongodb/bin/

删除原先的数据库文件(由于3.0.7当初安装时没有启用wiredTiger存储引擎,而3.2默认的为wiredTiger,不兼容3.0.7的默认的mmapv1存储引擎,故先备份原先的数据后再删除原先的数据目录下的文件)

# rm -rf /mnt/data/mongodb/*
# echo >/mnt/logs/mongodb/mongodb.log

启动3.2,注意:加上--storageEngine wiredTiger参数,mongodb.conf与3.0.7一样。

# /mnt/local/mongodb/bin/mongod --storageEngine wiredTiger --config /mnt/local/mongodb/bin/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 7737
child process started successfully, parent exiting

检查当前mongodb是否启用了WiredTiger存储引擎

# WIREDTIGER_CONFIGURED=`ps -ef|grep mongod|grep -i storageengine|grep -ic wiredtiger`
# echo ${WIREDTIGER_CONFIGURED}

如果返回为1则说明当前系统中运行着一个以WiredTiger为存储引擎的mongod

导入原数据库

# /mnt/local/mongodb/bin/mongo
MongoDB shell version: 3.2.0
connecting to: test
Server has startup warnings:
2015-12-10T02:06:21.286+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is
not recommended.
2015-12-10T02:06:21.286+0800 I CONTROL  [initandlisten]
> use ddc

> exit

# /mnt/local/mongodb/bin/mongorestore -h 127.0.0.1 -d ddc /mnt/wwwroot/ddc.dmp/ddc

更多MongoDB相关教程见以下内容:

CentOS 编译安装 MongoDB与mongoDB的php扩展 http://www.linuxidc.com/Linux/2012-02/53833.htm

CentOS 6 使用 yum 安装MongoDB及服务器端配置 http://www.linuxidc.com/Linux/2012-08/68196.htm

Ubuntu 13.04下安装MongoDB2.4.3 http://www.linuxidc.com/Linux/2013-05/84227.htm

MongoDB入门必读(概念与实战并重) http://www.linuxidc.com/Linux/2013-07/87105.htm

Ubunu 14.04下MongoDB的安装指南 http://www.linuxidc.com/Linux/2014-08/105364.htm

《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF] http://www.linuxidc.com/Linux/2012-07/66735.htm

Nagios监控MongoDB分片集群服务实战 http://www.linuxidc.com/Linux/2014-10/107826.htm

基于CentOS 6.5操作系统搭建MongoDB服务 http://www.linuxidc.com/Linux/2014-11/108900.htm

MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-12/126591.htm

linux
相关资讯       MongoDB升级 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款