{"id":1200,"date":"2011-06-29T02:04:35","date_gmt":"2011-06-28T16:04:35","guid":{"rendered":"http:\/\/www.melvic.info\/?p=1200"},"modified":"2012-04-17T09:17:16","modified_gmt":"2012-04-16T23:17:16","slug":"39-2","status":"publish","type":"post","link":"https:\/\/www.melvic.info\/?p=1200","title":{"rendered":"MongoDB on Windows"},"content":{"rendered":"<p>MongoDB\u306fWindows\u4e0a\u3067\u3082\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002<br \/>\n\u4eca\u56de\uff0c\u4e92\u63db\u6027\u30c6\u30b9\u30c8\u306e\u305f\u3081\uff0c\u6700\u65b0\u7248\uff08\u57f7\u7b46\u6642\u70b9\u30671.8.2\uff09\u3088\u308a\u4e00\u3064\u524d\u306e\u30ea\u30ea\u30fc\u30b9\u3068\u306a\u308b1.6.5\u3092\u8a66\u3059\u305f\u3081\u306b\uff0cWindows\u4e0a\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u53c2\u8003\uff1a\u300cWindows Service\u300d http:\/\/www.mongodb.org\/display\/DOCS\/Windows+Service<!--more--><br \/>\n\u86c7\u8db3\u306a\u304c\u3089\uff0cMongoDB\u306f\u300cA.B.C\u300d\u3068\u3044\u3046\u30d0\u30fc\u30b8\u30e7\u30f3\u30ca\u30f3\u30d0\u30fc\u3092\u4ed8\u3051\u308b\u3002A\u306f\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u756a\u53f7\u30021.0.0\u304c\u6700\u521d\u306eGA\u7248\u3067\u3042\u308b\u304b\u3089\uff0c\u73fe\u5728\u306f\u30e1\u30b8\u30e3\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u756a\u53f7\u306f1\u306e\u307f\u3067\u3042\u308b\u3002<br \/>\nB\u304c\u30ea\u30ea\u30fc\u30b9\u756a\u53f7\u30020\u304b\u3089\u59cb\u307e\u308a\uff0c\u5076\u6570\u7248\u304c\u305d\u306e\u6642\u70b9\u306e\u5b89\u5b9a\u7248\u3002\u5947\u6570\u306f\u958b\u767a\u7248\u3067\u3042\u308b\u3002\u30ea\u30ea\u30fc\u30b9\u304c\u65b0\u3057\u304f\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u306f\uff0c\u65b0\u6a5f\u80fd\u306e\u8ffd\u52a0\u306a\u3069\uff0c\u3042\u308b\u7a0b\u5ea6\u307e\u3068\u307e\u3063\u305f\u5909\u66f4\u304c\u3042\u3063\u305f\u3053\u3068\u3092\u610f\u5473\u3057\uff0c\u65e7\u7248\u306b\u5bfe\u3059\u308b\u4e92\u63db\uff08\u30d0\u30c3\u30af\u30ef\u30fc\u30c9\u30b3\u30f3\u30d1\u30c1\u30d3\u30ea\u30c6\u30a3\u30fc\uff09\u304c\u53d6\u308c\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b\u3068\u3057\u3066\u3044\u308b\u3002<br \/>\nC\u304c\u30ea\u30d3\u30b8\u30e7\u30f3\u756a\u53f7\u3002\u3053\u308c\u306f\u969c\u5bb3\u4fee\u6b63\u306a\u3069\u306e\u7d30\u304b\u3044\u4fee\u6b63\u3002<\/p>\n<p><strong>1. MongoDB\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/p>\n<p>\u3055\u3066\uff0cWindows\u7248\uff0c\u3057\u304b\u3082\u65e7\u30ea\u30ea\u30fc\u30b91.6.5\u3067\u3042\u308b\u304c\uff0c\u307e\u305a\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u30da\u30fc\u30b8\uff08 http:\/\/www.mongodb.org\/downloads \uff09\u304b\u3089\uff0cWindows\u7248\u3092\u63a2\u3057\uff0c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3002\u4eca\u56de\u306fWindows Server 2008 R2\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u305f\u3081\uff0cWindows 64bit\u7248\u3092\u9078\u629e\u3057\u305f\u3002<\/p>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306f\uff0cmongodb-win32-x86_64-1.6.5.zip \u3067\u3042\u308b\u3002\u3061\u306a\u307f\u306b32bit\u7248\u306fx86_64\u306e\u3068\u3053\u308d\u304ci386\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>\u6b21\u306b\u3053\u306eZip\u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3059\u308b\u3002\u4e00\u5fdc\u901a\u5e38\u306e\u30bd\u30d5\u30c8\u306e\u307e\u306d\u3092\u3057\u3066\uff0cC:Program FilesMongoDB \u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u308a\uff0c\u3055\u3089\u306b\u305d\u306e\u4e0b\u306bbin\u30d5\u30a9\u30eb\u30c0\u3082\u4f5c\u308a\uff0c\u305d\u3053\u306b\u300c~.exe\u300d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u3059\u3079\u3066\u30b3\u30d4\u30fc\u3057\u305f\u3002\u305d\u308c\u4ee5\u5916\u306e\u30d5\u30a1\u30a4\u30eb\u306f MongoDB \u30d5\u30a9\u30eb\u30c0\u306e\u4e0b\u306b\u683c\u7d0d\u3057\u305f\u3002<\/p>\n<p>\u7d9a\u3044\u3066\uff0c\u30c7\u30fc\u30bf\u683c\u7d0d\u7528\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u308b\u3002\u79c1\u306e\u30de\u30b7\u30f3\u306f\uff0cD:\u30c9\u30e9\u30a4\u30d6\u304c\u30c7\u30fc\u30bf\u7528\u306eHDD\u30c9\u30e9\u30a4\u30d6\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\uff0c\u3053\u3053\u306b D:MongoDB \u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3002\u3055\u3089\u306b\u3053\u306e\u4e0b\u306bdata\u3068log\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u308a\uff0c\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb\u3068\u30ed\u30b0\u304c\u6df7\u3056\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<p><strong>2. \u52d5\u4f5c\u78ba\u8a8d<\/strong><\/p>\n<p>\u307e\u305a\uff0c\u4e00\u5fdc\u52d5\u4f5c\u78ba\u8a8d\u3092\u3059\u308b\u3002\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u958b\u304d\uff0cC:Program FilesMongoDBbin \u306b\u79fb\u52d5\u3002\u7d9a\u3044\u3066\u4ee5\u4e0b\u3092\u30bf\u30a4\u30d7\u3059\u308b\u3002<\/p>\n<p>mongod &#8211;logpath d:MongoDBlogmongod.log &#8211;logappend &#8211;dbpath d:MongoDBdata &#8211;directoryperdb<\/p>\n<p>\u3059\u3079\u3066\u306e\u51fa\u529b\u306f\uff0c\u3053\u306e d:MongoDBlogmongod.log \u306b\u884c\u3063\u3066\u3057\u307e\u3046\u304c\uff0c\u305d\u306e\u9593\u969b\u306b\u3053\u3046\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u308b\u3002<br \/>\nall output going to: d:MongoDBlogmongod.log<br \/>\n\u3053\u308c\u3067\u5236\u5fa1\u304c\u623b\u3063\u3066\u3053\u306a\u3051\u308c\u3070\uff0cmongod\u304c\u52d5\u304d\u7d9a\u3051\u3066\u3044\u308b\u3068\u601d\u3063\u3066\u3044\u3044\u3060\u308d\u3046\u3002<br \/>\n\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3092\u78ba\u8a8d\u3059\u308b\u3068\uff0c\u6700\u5f8c\u306e2\u884c\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306f\u305a\u3002<\/p>\n<p>[initandlisten] waiting for connections on port 27017<br \/>\n[websvr] web admin interface listenig on port 18017<\/p>\n<p>\u7d9a\u3044\u3066\uff0c\u3082\u3046\u4e00\u3064\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u958b\u304d\uff0c\u5b9f\u969b\u306b\u30c7\u30fc\u30bf\u3092\u5165\u308c\u3066\u307f\u308b\u3002<\/p>\n<p>C:Program FilesMongoDBbin&gt;mongo<br \/>\nMongoDB shell version: 1.6.5<br \/>\nconnecting to: test<br \/>\n&gt; show dbs<br \/>\nadmin<br \/>\nlocal<br \/>\n&gt; use mytest<br \/>\nswitched to db mytest<br \/>\n&gt; db.mycollection.save ( {_id:1, title:&#8221;Yahoo&#8221;, text:&#8221;world!&#8221; } )<\/p>\n<p>\u3053\u3053\u307e\u3067\u4f55\u3082\u8d77\u304d\u306a\u3044\u304c\uff0c\u3053\u308c\u3067mytest\u3068\u3044\u3046\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff0c\u304a\u3088\u3073mycollection\u3068\u3044\u3046\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff08\u30c6\u30fc\u30d6\u30eb\uff09\u304c\u3067\u304d\u3066\u3044\u308b\u306f\u305a\u3002<\/p>\n<p>&gt; show dbs<br \/>\nadmin<br \/>\nlocal<br \/>\nmytest<\/p>\n<p>&gt; show collections<br \/>\nmycollection<br \/>\nsystem.indexes<br \/>\n&gt; db.mycollection.find()<br \/>\n{ &#8220;-d&#8221; : 1, &#8220;title&#8221; : &#8220;Yahoo&#8221;, &#8220;text&#8221; : &#8220;world!&#8221; }<\/p>\n<p>\u30c7\u30fc\u30bf\u3082\u3061\u3083\u3093\u3068\u5165\u3063\u3066\u3044\u305f\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\uff0c\u3053\u306e\u3050\u3089\u3044\u30c6\u30b9\u30c8\u3059\u308c\u3070\u5341\u5206\u3060\u308d\u3046\u3002<\/p>\n<p>&gt; exit<br \/>\nbye<\/p>\n<p>C:Program FilesMongoDBbin&gt;<\/p>\n<p>mongod\u306e\u30d7\u30ed\u30bb\u30b9\u3082Ctrl-C\u3067\u4e00\u65e6\u7d42\u4e86\u3059\u308b\u3002<\/p>\n<p><strong>3. MongoDB\u30b5\u30fc\u30d3\u30b9\u306e\u767b\u9332<\/strong><\/p>\n<p>\u6b21\u306b\uff0c\u3053\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u767b\u9332\u3059\u308b\u3002<br \/>\n\u3053\u308c\u306b\u306f\uff0c\u5148\u307b\u3069\u306emongod\u30b3\u30de\u30f3\u30c9\u306b&#8211;install\u3092\u4ed8\u3051\u3066\u767a\u884c\u3059\u308b\u3060\u3051\u3067\u3044\u3044\u306e\u3060\u304c\uff0cWindows 7\uff0cWindows Server 2008\u306a\u3069\u306e\u5834\u5408\u306f\uff0c\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3092Administrator\u6a29\u9650\u3067\u958b\u59cb\u3057\u306a\u3044\u3068\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u306e\u3067\u6ce8\u610f\u3002<br \/>\n\u305d\u308c\u3068\uff0c\u3053\u306e\u3042\u3068\uff0c\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30fc\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u306b\u3042\u305f\u308a\uff0c\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\uff0c\u5148\u307b\u3069mongod\u30b3\u30de\u30f3\u30c9\u306b\u4e0e\u3048\u305f\u5f15\u6570\u3092\u3059\u3079\u3066\u30d5\u30a1\u30a4\u30eb\u306b\u5165\u308c\u3066\u3057\u307e\u3046\u3002\u3053\u308c\u306b\u3088\u308a\uff0c\u305d\u306e\u5f8c\u306e\u69cb\u6210\u5909\u66f4\u304c\u697d\u306b\u306a\u308b\u3002<\/p>\n<p>\u8a66\u884c\u932f\u8aa4\u306e\u672b\uff0c\u3053\u306e\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306ePath\u540d\u3068\u3057\u3066\uff0c\u7a7a\u767d\u6587\u5b57\u304c\u5165\u308b\u3068\uff0c\u30b5\u30fc\u30d3\u30b9\u8d77\u52d5\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3053\u3068\u304c\u5206\u304b\u3063\u305f\u3002\u3064\u307e\u308a\uff0c&#8221;C:Program Files&#8221;\u306e\u5148\u306b\u306f\u7f6e\u3051\u306a\u3044\uff08\u5f15\u7528\u7b26\u3067\u304f\u304f\u3063\u3066\u3082\u3046\u307e\u304f\u3044\u304b\u306a\u304b\u3063\u305f\uff09\u3002<br \/>\n\u3067\uff0c\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u304c\u76ee\u7684\u306a\u306e\u3067\uff0c\u9069\u5207\u304b\u3069\u3046\u304b\u306f\u3082\u3046\u4e00\u3064\u691c\u8a0e\u306e\u4f59\u5730\u304c\u3042\u308b\u304c\uff0c\u3068\u308a\u3042\u3048\u305a\uff0cD:MongoDB\u30d5\u30a9\u30eb\u30c0\u76f4\u4e0b\u306b\uff0cmongod.conf\u3068\u3044\u3046\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u7f6e\u304f\u3053\u3068\u306b\u3057\u305f\u3002Windows\u7248\u306eZip\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306e\u96db\u5f62\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u306e\u3067\uff0c\u4e2d\u8eab\u306f\u4e00\u304b\u3089\u4f5c\u3089\u306a\u3044\u3068\u306a\u3089\u306a\u3044\u3002<br \/>\n\u3053\u306e\u4e2d\u8eab\u306f\uff0c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p>logpath=D:MongoDBlogmongod.log<br \/>\nlogappend=true<br \/>\ndbpath=D:MongoDBdata<br \/>\ndirectoryperdb=true<\/p>\n<p>\u306a\u304a\uff0cLinux\u7248\u306b\u306f fork=true \u3068\u3044\u3046\u30d1\u30e9\u30e1\u30bf\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5165\u3063\u3066\u3044\u308b\u304c\uff0c\u3053\u308c\u306fWindows\u7248\u3067\u306f\u7121\u52b9\u3067\uff0c\u8d77\u52d5\u6642\u306b\u30a8\u30e9\u30fc\u3068\u306a\u308b\u306e\u3067\uff0c\u5165\u308c\u306a\u3044\u3053\u3068\u3002<\/p>\n<p>\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u767b\u9332\u3059\u308b\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3068\u3057\u3066\u306f\uff0c\u3053\u306e\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092 -f \u30d1\u30e9\u30e1\u30bf\u3067\u6307\u5b9a\u3059\u308b\u3002<\/p>\n<p>C:Program FilesMongoDBbin&gt;mongod -f d:MongoDBmongod.conf &#8211;install<br \/>\nCreating service MongoDB.<br \/>\nService creation successful.<br \/>\nService can be started from the command line via &#8216;net start &#8220;MongoDB&#8221;&#8216;.<\/p>\n<p>C:Program FilesMongoDBbin&gt;<\/p>\n<p>\u3053\u306e\u3042\u3068\uff0c\u6700\u5f8c\u306e\u884c\u306b\u3042\u308b\u3068\u304a\u308a\uff0cnet\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30fc\u30d3\u30b9\u3092\u958b\u59cb\u3057\u3066\u3082\u3044\u3044\u3057\uff0c\u30b5\u30fc\u30d3\u30b9\u753b\u9762\u304b\u3089\u30b5\u30fc\u30d3\u30b9\u3092\u958b\u59cb\u3057\u3066\u3082\u3044\u3044\u3002<\/p>\n<p>\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u8d77\u52d5\u3057\u305f\u3068\u304d\u3068\uff0c\u540c\u69d8\u306e\u30c6\u30b9\u30c8\u3092\u3059\u308c\u3070\uff0c\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u6b63\u3057\u304f\u8d77\u52d5\u3067\u304d\u305f\u304b\u3069\u3046\u304b\u78ba\u304b\u3081\u3089\u308c\u308b\u3002<\/p>\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30fc\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u306f\uff0c\u524d\u56deLinux\u7248\u3067\u8aac\u660e\u3057\u305f\u3082\u306e\u3068\u540c\u3058\u306a\u306e\u3067\uff0c\u5272\u611b\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB\u306fWindows\u4e0a\u3067\u3082\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002 \u4eca\u56de\uff0c\u4e92\u63db\u6027\u30c6\u30b9\u30c8\u306e\u305f\u3081\uff0c\u6700\u65b0\u7248\uff08\u57f7\u7b46\u6642\u70b9\u30671.8.2\uff09\u3088\u308a\u4e00\u3064\u524d\u306e\u30ea\u30ea\u30fc\u30b9\u3068\u306a\u308b1.6.5\u3092\u8a66\u3059\u305f\u3081\u306b\uff0cWindows\u4e0a\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002 \u53c2\u8003\uff1a\u300cWin &hellip; <a href=\"https:\/\/www.melvic.info\/?p=1200\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">MongoDB on Windows<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-1200","post","type-post","status-publish","format-standard","hentry","category-15"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p53KbG-jm","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.melvic.info\/index.php?rest_route=\/wp\/v2\/posts\/1200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.melvic.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.melvic.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.melvic.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.melvic.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1200"}],"version-history":[{"count":3,"href":"https:\/\/www.melvic.info\/index.php?rest_route=\/wp\/v2\/posts\/1200\/revisions"}],"predecessor-version":[{"id":1295,"href":"https:\/\/www.melvic.info\/index.php?rest_route=\/wp\/v2\/posts\/1200\/revisions\/1295"}],"wp:attachment":[{"href":"https:\/\/www.melvic.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.melvic.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.melvic.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}