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

 

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

可以至少通过以下2种方法 验证:

1、在Linux/OSX上执行如下的命令

 

 

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

 

 

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

 

2、在Linux/OSX上执行如下的命令

 

echo "db.serverStatus()"| mongo|grep wiredTiger

若返回信息中有wiredTiger,则说明该mongo连接到了一个启用了wiredTiger存储引擎的mongod.

注意对于启用了wiredTiger的文件路径–dbpath,无法再使用默认mmapv1存储引擎打开,例如:

 

ac:mongodata maclean$ mongod --storageEngine wiredTiger --dbpath  /Users/maclean/mongodata
2015-05-06T11:35:32.372+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=4G,session_max=20000,eviction=(threads_max=4),statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2015-05-06T11:35:32.997+0800 I CONTROL  [initandlisten] MongoDB starting : pid=16590 port=27017 dbpath=/Users/maclean/mongodata 64-bit host=ac.local
2015-05-06T11:35:32.998+0800 I CONTROL  [initandlisten] db version v3.0.2
2015-05-06T11:35:32.998+0800 I CONTROL  [initandlisten] git version: nogitversion
2015-05-06T11:35:32.998+0800 I CONTROL  [initandlisten] build info: Darwin yosemitevm.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-05-06T11:35:32.998+0800 I CONTROL  [initandlisten] allocator: system
2015-05-06T11:35:32.999+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/Users/maclean/mongodata", engine: "wiredTiger" } }
2015-05-06T11:35:33.045+0800 I NETWORK  [initandlisten] waiting for connections on port 27017


如上启用了--storageEngine wiredTiger 可以正常运行



如果用mmapv1引擎则报错

ac:mongodata maclean$ mongod --storageEngine mmapv1 --dbpath  /Users/maclean/mongodata
2015-05-06T11:36:34.037+0800 I STORAGE  [initandlisten] exception in initAndListen: 28574 Cannot start server. Detected data files in /Users/maclean/mongodata created by storage engine 'wiredTiger'. The configured storage engine is 'mmapv1'., terminating
2015-05-06T11:36:34.037+0800 I CONTROL  [initandlisten] dbexit:  rc: 100

Comment

*

沪ICP备14014813号

沪公网安备 31010802001379号