程序员人生 网站导航

mongoDB的读书笔记(via3.0)(00)_【概览】(02)_mongoDB3.0中的mongod启动方式小试牛刀

栏目:数据库应用时间:2015-04-03 07:55:50

mongod启动

本来想写Replica的非测试模式的集群架构的,但是实在是手痒痒,把mongoDB的3.0给download下来了,看了1两眼文档后决定还是先大概写1点点关于启动的话题,以后写Replica的时候基本上就用mongoDB 3.0的方式+YAML的 配置方式来做了。

mongod利用mmapv1启动

这个是default的启动方式。mongod的启动参数多如牛毛,本来想有空总结1下的,我勒个去的,有些估计这辈子也用不到的场景也不知道如何写,等我再斟酌1下再说吧。

准备配置文件

storage: dbPath: C:datamdb engine: mmapv1

注意,engine这个地方可以不写哦,默许就是mmapv1。其余那几10个参数先不写了太多了。

启动

C:MongoDB3Server3.0in>mongod -f C:MongoDB3Server3.0etcconfconfig.conf

履行上面的命令后:

2015-03-06T23:50:20.794+0800 I CONTROL [initandlisten] MongoDB starting : pid=1 4116 port=27017 dbpath=C:datamdb 64-bit host=yanglu 2015-03-06T23:50:20.798+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/W indows Server 2008 R2 2015-03-06T23:50:20.799+0800 I CONTROL [initandlisten] db version v3.0.0 2015-03-06T23:50:20.800+0800 I CONTROL [initandlisten] git version: a841fd63943 65954886924a35076691b4d149168 2015-03-06T23:50:20.802+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1j-fips 15 Oct 2014 2015-03-06T23:50:20.803+0800 I CONTROL [initandlisten] build info: windows sys. getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Servic e Pack 1') BOOST_LIB_VERSION=1_49 2015-03-06T23:50:20.804+0800 I CONTROL [initandlisten] allocator: system 2015-03-06T23:50:20.805+0800 I CONTROL [initandlisten] options: { config: "C:M ongoDB3Server3.0etcconfconfig.conf", storage: { dbPath: "C:datamdb", engi ne: "mmapv1" } } 2015-03-06T23:50:20.916+0800 I JOURNAL [initandlisten] journal dir=C:datamdb journal 2015-03-06T23:50:20.918+0800 I JOURNAL [initandlisten] recover : no journal fil es present, no recovery needed 2015-03-06T23:50:20.953+0800 I JOURNAL [durability] Durability thread started 2015-03-06T23:50:20.954+0800 I JOURNAL [journal writer] Journal writer thread s tarted 2015-03-06T23:50:21.167+0800 I INDEX [initandlisten] allocating new ns file C :datamdblocal.ns, filling with zeroes... 2015-03-06T23:50:21.564+0800 I STORAGE [FileAllocator] allocating new datafile C:datamdblocal.0, filling with zeroes... 2015-03-06T23:50:21.565+0800 I STORAGE [FileAllocator] creating directory C:da tamdb\_tmp 2015-03-06T23:50:21.570+0800 I STORAGE [FileAllocator] done allocating datafile C:datamdblocal.0, size: 64MB, took 0.002 secs 2015-03-06T23:50:21.590+0800 I NETWORK [initandlisten] waiting for connections on port 27017

哇啦啦,跑起来了。这个在3.0之前也这样,没啥特殊的。

mongod利用WiredTiger启动

这个是需要指定的启动方式。

准备配置文件

storage: dbPath: C:datawdb engine: wiredTiger

注意,engine这个地方设置的是wiredTiger哦。

启动

C:MongoDB3Server3.0in>mongod -f C:MongoDB3Server3.0etcconfconfig.conf

履行上面的命令后:

C:MongoDB3Server3.0in>mongod -f C:MongoDB3Server3.0etcconfconfig.conf 2015-03-06T23:59:56.445+0800 I CONTROL [initandlisten] MongoDB starting : pid=1 4076 port=27017 dbpath=C:datawdb 64-bit host=yanglu 2015-03-06T23:59:56.449+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/W indows Server 2008 R2 2015-03-06T23:59:56.449+0800 I CONTROL [initandlisten] db version v3.0.0 2015-03-06T23:59:56.449+0800 I CONTROL [initandlisten] git version: a841fd63943 65954886924a35076691b4d149168 2015-03-06T23:59:56.450+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1j-fips 15 Oct 2014 2015-03-06T23:59:56.450+0800 I CONTROL [initandlisten] build info: windows sys. getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Servic e Pack 1') BOOST_LIB_VERSION=1_49 2015-03-06T23:59:56.451+0800 I CONTROL [initandlisten] allocator: system 2015-03-06T23:59:56.453+0800 I CONTROL [initandlisten] options: { config: "C:M ongoDB3Server3.0etcconfconfig.conf", storage: { dbPath: "C:datawdb", engi ne: "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=(wai t=60,log_size=2GB),statistics_log=(wait=0), 2015-03-06T23:59:56.942+0800 I NETWORK [initandlisten] waiting for connections on port 27017

Storage format的影响

上面我启动两个mongod使用的是:
C:datamdb : mmapv1模式
C:datawdb : wiredTiger模式
两个不同的文件夹,使用的两个不同的存储模式,mongoDB的3.0中强调,当指定的dbpath使用的存储引擎和你的engine不1致的时候,mongoDB是谢绝启动的哦。

------分隔线----------------------------
------分隔线----------------------------

最新技术推荐