MongoDB Reading Notes (via3.0) (00) _ [Overview] (02) _ mongoDB3.0 mongod startup method test, _ mongodb3.0mongod
Mongod startup
I originally wanted to write the non-test mode cluster architecture of Replica, but it was really tricky to download 3.0 of mongoDB, after reading one or two documents, I decided to write a little bit about the startup topic first, and then I used the mongoDB 3.0 + YAML configuration method to write Replica.
Mongod is started with mmapv1
This is the default startup method. The startup parameters of mongod are too many. I would like to summarize them for some time. I am not sure how to write them in some scenarios that I would not be able to use in my life, let me try again later.
Prepare the configuration file
storage: dbPath: C:\datam\db engine: mmapv1
Note: The engine can be left empty. The default value is mmapv1. The remaining 10 parameters are not written too much.
Start
C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf
After executing the preceding command:
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
Wow, it's running. This was also the case before 3.0, with nothing special.
Mongod is started with WiredTiger
This is the startup method that needs to be specified.
Prepare the configuration file
storage: dbPath: C:\dataw\db engine: wiredTiger
Note that wiredTiger is set in the engine.
Start
C:\MongoDB3\Server\3.0\bin>mongod -f C:\MongoDB3\Server\3.0\etc\conf\config.conf
After executing the preceding command:
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
Impact of Storage format
The above two sdks are used:
C: \ datam \ db: mmapv1 Mode
C: \ dataw \ db: wiredTiger Mode
Two different folders use two different storage modes. mongoDB 3.0 emphasizes that when the storage engine used by the specified dbpath is inconsistent with your engine, mongoDB is not started.
-StorageEngine string
Default: mmapv1
New in version 3.0.0.
Specifies the storage engine for the specified D database. Valid options include mmapv1 and wiredTiger.
If you attempt to start a stored D 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.
Start wiredTiger on mmapv1
Let's try to use wiredTiger engine for C: \ datam \ db:
storage: dbPath: C:\datam\db engine: wiredTiger
Result:
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 'wiredtider'., terminatin
G
The above clearly states that we mistakenly use the wiredTiger engine on mmapv1 and it cannot be started.
Start mmapv1 on wiredTiger
Let's try to use the mmapv1 engine for C: \ dataw \ db:
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
The results can be imagined.
There are already too many other...