mongodb3.2版本于前天2015-12-08日刚刚发布,下载地址为:
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
# 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扩展
CentOS 6 使用 yum 安装MongoDB及服务器端配置
Ubuntu 13.04下安装MongoDB2.4.3
《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF]
基于CentOS 6.5操作系统搭建MongoDB服务 uxidc.com/Linux/2014-11/108900.htm