mongoDB的讀書筆記(via3.0)(00)_【概覽】(02)_mongoDB3.0中的mongod啟動方式小試牛刀,_mongodb3.0mongod

來源:互聯網
上載者:User

mongoDB的讀書筆記(via3.0)(00)_【概覽】(02)_mongoDB3.0中的mongod啟動方式小試牛刀,_mongodb3.0mongod
mongod啟動

本來想寫Replica的非測試模式的叢集架構的,但是實在是手痒痒,把mongoDB的3.0給download下來了,看了一兩眼文檔後決定還是先大概寫一點點關於啟動的話題,之後寫Replica的時候基本上就用mongoDB 3.0的方式+YAML的 配置方式來做了。

mongod利用mmapv1啟動

這個是default的啟動方式。mongod的啟動參數多如牛毛,本來想有空總結一下的,我勒個去的,有些估計這輩子也用不到的情境也不知道如何寫,等我再考慮一下再說吧。

準備設定檔
storage:   dbPath: C:\datam\db   engine: mmapv1

注意,engine這個地方可以不寫哦,預設就是mmapv1。其餘那幾十個參數先不寫了太多了。

啟動
C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf

執行上面的命令後:

2015-03-06T23:50:20.794+0800 I CONTROL  [initandlisten] MongoDB starting : pid=14116 port=27017 dbpath=C:\datam\db 64-bit host=yanglu2015-03-06T23:50:20.798+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R22015-03-06T23:50:20.799+0800 I CONTROL  [initandlisten] db version v3.0.02015-03-06T23:50:20.800+0800 I CONTROL  [initandlisten] git version: a841fd6394365954886924a35076691b4d1491682015-03-06T23:50:20.802+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1j-fips 15 Oct 20142015-03-06T23:50:20.803+0800 I CONTROL  [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_492015-03-06T23:50:20.804+0800 I CONTROL  [initandlisten] allocator: system2015-03-06T23:50:20.805+0800 I CONTROL  [initandlisten] options: { config: "C:\MongoDB3\Server\3.0\etc\conf\config.conf", storage: { dbPath: "C:\datam\db", engine: "mmapv1" } }2015-03-06T23:50:20.916+0800 I JOURNAL  [initandlisten] journal dir=C:\datam\db\journal2015-03-06T23:50:20.918+0800 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed2015-03-06T23:50:20.953+0800 I JOURNAL  [durability] Durability thread started2015-03-06T23:50:20.954+0800 I JOURNAL  [journal writer] Journal writer thread started2015-03-06T23:50:21.167+0800 I INDEX    [initandlisten] allocating new ns file C:\datam\db\local.ns, filling with zeroes...2015-03-06T23:50:21.564+0800 I STORAGE  [FileAllocator] allocating new datafileC:\datam\db\local.0, filling with zeroes...2015-03-06T23:50:21.565+0800 I STORAGE  [FileAllocator] creating directory C:\datam\db\_tmp2015-03-06T23:50:21.570+0800 I STORAGE  [FileAllocator] done allocating datafile C:\datam\db\local.0, size: 64MB,  took 0.002 secs2015-03-06T23:50:21.590+0800 I NETWORK  [initandlisten] waiting for connectionson port 27017

哇啦啦,跑起來了。這個在3.0以前也這樣,沒啥特殊的。

mongod利用WiredTiger啟動

這個是需要指定的啟動方式。

準備設定檔
storage:   dbPath: C:\dataw\db   engine: wiredTiger

注意,engine這個地方設定的是wiredTiger哦。

啟動
C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf

執行上面的命令後:

C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf2015-03-06T23:59:56.445+0800 I CONTROL  [initandlisten] MongoDB starting : pid=14076 port=27017 dbpath=C:\dataw\db 64-bit host=yanglu2015-03-06T23:59:56.449+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R22015-03-06T23:59:56.449+0800 I CONTROL  [initandlisten] db version v3.0.02015-03-06T23:59:56.449+0800 I CONTROL  [initandlisten] git version: a841fd6394365954886924a35076691b4d1491682015-03-06T23:59:56.450+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1j-fips 15 Oct 20142015-03-06T23:59:56.450+0800 I CONTROL  [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_492015-03-06T23:59:56.451+0800 I CONTROL  [initandlisten] allocator: system2015-03-06T23:59:56.453+0800 I CONTROL  [initandlisten] options: { config: "C:\MongoDB3\Server\3.0\etc\conf\config.conf", storage: { dbPath: "C:\dataw\db", engine: "wiredTiger" } }2015-03-06T23:59:56.457+0800 I STORAGE  [initandlisten] wiredtiger_open config:create,cache_size=3G,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-03-06T23:59:56.942+0800 I NETWORK  [initandlisten] waiting for connectionson port 27017
Storage format的影響

上面我啟動兩個mongod使用的是:
C:\datam\db : mmapv1模式
C:\dataw\db : wiredTiger模式
兩個不同的檔案夾,使用的兩個不同的儲存模式,mongoDB的3.0中強調,當指定的dbpath使用的儲存引擎和你的engine不一致的時候,mongoDB是拒絕啟動的哦。

–storageEngine string
Default: mmapv1

New in version 3.0.0.

Specifies the storage engine for the mongod database. Valid options include mmapv1 and wiredTiger.

If you attempt to start a mongod with a storage.dbPath that contains data files produced by a storage engine other than the one specified by –storageEngine, mongod will refuse to start.

mmapv1上面啟動wiredTiger

我們試試對C:\datam\db 使用wiredTiger的引擎:

storage:   dbPath: C:\datam\db   engine: wiredTiger

結果:

C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf2015-03-07T00:07:04.052+0800 I CONTROL  [initandlisten] MongoDB starting : pid=11576 port=27017 dbpath=C:\datam\db 64-bit host=yanglu2015-03-07T00:07:04.056+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R22015-03-07T00:07:04.056+0800 I CONTROL  [initandlisten] db version v3.0.02015-03-07T00:07:04.056+0800 I CONTROL  [initandlisten] git version: a841fd6394365954886924a35076691b4d1491682015-03-07T00:07:04.057+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1j-fips 15 Oct 20142015-03-07T00:07:04.057+0800 I CONTROL  [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_492015-03-07T00:07:04.058+0800 I CONTROL  [initandlisten] allocator: system2015-03-07T00:07:04.059+0800 I CONTROL  [initandlisten] options: { config: "C:\MongoDB3\Server\3.0\etc\conf\config.conf", storage: { dbPath: "C:\datam\db", engine: "wiredTiger" } }2015-03-07T00:07:04.062+0800 I STORAGE  [initandlisten] exception in initAndListen: 28574 Cannot start server. Detected data files in C:\datam\db created by storage engine 'mmapv1'. The configured storage engine is 'wiredTiger'., terminating2015-03-07T00:07:04.063+0800 I CONTROL  [initandlisten] dbexit:  rc: 100

2015-03-07T00:07:04.062+0800 I STORAGE [initandlisten] exception in initAndList
en: 28574 Cannot start server. Detected data files in C:\datam\db created by sto
rage engine ‘mmapv1’. The configured storage engine is ‘wiredTiger’., terminatin
g

上面已經很明確寫出了我們錯誤地在mmapv1的上面使用wiredTiger的引擎,無法啟動。

wiredTiger上面啟動mmapv1

我們試試對C:\dataw\db 使用mmapv1的引擎:

storage:   dbPath: C:\dataw\db   engine: mmapv1
C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf2015-03-07T00:10:09.777+0800 I CONTROL  [initandlisten] MongoDB starting : pid=15152 port=27017 dbpath=C:\dataw\db 64-bit host=yanglu2015-03-07T00:10:09.781+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R22015-03-07T00:10:09.784+0800 I CONTROL  [initandlisten] db version v3.0.02015-03-07T00:10:09.784+0800 I CONTROL  [initandlisten] git version: a841fd6394365954886924a35076691b4d1491682015-03-07T00:10:09.789+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1j-fips 15 Oct 20142015-03-07T00:10:09.790+0800 I CONTROL  [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_492015-03-07T00:10:09.792+0800 I CONTROL  [initandlisten] allocator: system2015-03-07T00:10:09.793+0800 I CONTROL  [initandlisten] options: { config: "C:\MongoDB3\Server\3.0\etc\conf\config.conf", storage: { dbPath: "C:\dataw\db", engine: "mmapv1" } }2015-03-07T00:10:09.796+0800 I STORAGE  [initandlisten] exception in initAndListen: 28574 Cannot start server. Detected data files in C:\dataw\db created by storage engine 'wiredTiger'. The configured storage engine is 'mmapv1'., terminating2015-03-07T00:10:09.798+0800 I CONTROL  [initandlisten] dbexit:  rc: 100

結果可想而知,真的是不可以。

つづく・・・

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.