首页 / 数据库 / MySQL / MongoDB从3.0.7升级到MongoDB3.2
mongodb3.2版本于前天2015-12-08日刚刚发布,下载地址为:https://www.mongodb.org/downloads#productionStarting 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.htmCentOS 6 使用 yum 安装MongoDB及服务器端配置 http://www.linuxidc.com/Linux/2012-08/68196.htmUbuntu 13.04下安装MongoDB2.4.3 http://www.linuxidc.com/Linux/2013-05/84227.htmMongoDB入门必读(概念与实战并重) http://www.linuxidc.com/Linux/2013-07/87105.htmUbunu 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.htmNagios监控MongoDB分片集群服务实战 http://www.linuxidc.com/Linux/2014-10/107826.htm基于CentOS 6.5操作系统搭建MongoDB服务 http://www.linuxidc.com/Linux/2014-11/108900.htmMongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里本文永久更新链接地址