{"id":1137,"date":"2018-09-23T11:27:27","date_gmt":"2018-09-23T02:27:27","guid":{"rendered":"https:\/\/lab4ict.com\/system\/?p=1137"},"modified":"2023-04-16T10:46:00","modified_gmt":"2023-04-16T01:46:00","slug":"ubuntu-18-04-lts-desktop%e3%81%abmongodb%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab","status":"publish","type":"post","link":"https:\/\/lab4ict.com\/system\/archives\/1137","title":{"rendered":"MongoDB 4.0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01\uff08Ubuntu Server 18.04\uff09"},"content":{"rendered":"<p>Ubuntu 18.04 LTS Desktop\u306bMongoDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002MongoDB\u306f\u3001\u30c7\u30fc\u30bf\u3092JSON\u5f62\u5f0f\u3067\u6271\u3046\u306e\u3067\u3001Web API\u3068\u306e\u76f8\u6027\u304c\u3088\u3044\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u3059\u3002<br \/>\n<!--more--><\/p>\n<h2>\u4f7f\u7528\u3057\u305f\u74b0\u5883<\/h2>\n<ul>\n<li>Ubuntu 18.04 LTS Desktop (18.04.1)<\/li>\n<li>MongoDB 4.0.2 (MongoDB Repository)<\/li>\n<li>MongoDB 3.6.3 (Ubuntu Repository)<\/li>\n<\/ul>\n<h2>MongoDB\u3092MongoDB\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>\u6700\u65b0\u7248\u306e4.0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u306b\u306f\u3001MongoDB\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u767b\u9332\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>MongoDB\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u306b\u516c\u958b\u9375\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo apt-key adv --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4\r\n<\/pre>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u7528\u306e\u30ea\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ echo &quot;deb &#x5B; arch=amd64 ] https:\/\/repo.mongodb.org\/apt\/ubuntu bionic\/mongodb-org\/4.0 multiverse&quot; | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-4.0.list\r\n<\/pre>\n<p>\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30ea\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo apt-get update\r\n<\/pre>\n<p>\u6700\u65b0\u306e\u5b89\u5b9a\u7248\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo apt-get install -y mongodb-org\r\n<\/pre>\n<h3>MongoDB\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306b\u3064\u3044\u3066<\/h3>\n<p>\u4ee5\u964d\u3001apt-get\u30b3\u30de\u30f3\u30c9\u3067\u6700\u65b0\u5316\u3067\u304d\u307e\u3059\u304c\u3001\u4e0d\u7528\u610f\u306a\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,3,4,5]; title: ; notranslate\" title=\"\">\r\necho &quot;mongodb-org hold&quot; | sudo dpkg --set-selections\r\necho &quot;mongodb-org-server hold&quot; | sudo dpkg --set-selections\r\necho &quot;mongodb-org-shell hold&quot; | sudo dpkg --set-selections\r\necho &quot;mongodb-org-mongos hold&quot; | sudo dpkg --set-selections\r\necho &quot;mongodb-org-tools hold&quot; | sudo dpkg --set-selections\r\n<\/pre>\n<h3>MongoDB\u306e\u8d77\u52d5<\/h3>\n<p>MongoDB\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002\u30b3\u30de\u30f3\u30c9\u306f\u3001systemctl\u30b3\u30de\u30f3\u30c9\u3067\u306f\u306a\u304f\u3001service\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3001\u30b5\u30fc\u30d3\u30b9\u540d\u306f\u3001mongodb\u3067\u306f\u306a\u304f\u3001mongod\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n$ sudo service mongod start\r\n$ sudo service mongod status\r\n\u25cf mongod.service - MongoDB Database Server\r\n   Loaded: loaded (\/lib\/systemd\/system\/mongod.service; disabled; vendor preset: enabled)\r\n   Active: active (running) since Sun 2018-09-23 12:27:54 JST; 7s ago\r\n     Docs: https:\/\/docs.mongodb.org\/manual\r\n Main PID: 7286 (mongod)\r\n   CGroup: \/system.slice\/mongod.service\r\n           \u2514\u25007286 \/usr\/bin\/mongod --config \/etc\/mongod.conf\r\n<\/pre>\n<p>\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo cat \/var\/log\/mongodb\/mongod.log\r\n2018-09-23T12:04:10.318+0900 I CONTROL  &#x5B;initandlisten] MongoDB starting : pid=5946 port=27017 dbpath=\/var\/lib\/mongodb 64-bit host=vircli001\r\n2018-09-23T12:04:10.318+0900 I CONTROL  &#x5B;initandlisten] db version v4.0.2\r\n...\r\n<\/pre>\n<h3>MongoDB shell\u304b\u3089\u306e\u63a5\u7d9a<\/h3>\n<p>mongo\u30b3\u30de\u30f3\u30c9\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002MongoDB shell\u3068MongoDB server\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u8868\u793a\u3055\u308c\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\">\"\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ mongo\r\nMongoDB shell version v4.0.2\r\nconnecting to: mongodb:\/\/127.0.0.1:27017\r\nMongoDB server version: 4.0.2\r\n...\r\n&gt; quit()\r\n<\/pre>\n<h3>MongoDB\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u78ba\u8a8d<\/h3>\n<p>MongoDB\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ cat \/etc\/mongod.conf\r\n# mongodb.conf\r\n\r\n# Where to store the data.\r\ndbpath=\/var\/lib\/mongodb\r\n\r\n#where to log\r\nlogpath=\/var\/log\/mongodb\/mongodb.log\r\n\r\nlogappend=true\r\n\r\nbind_ip = 127.0.0.1\r\n#port = 27017\r\n...\r\n<\/pre>\n<h3>MongoDB\u306e\u505c\u6b62<\/h3>\n<p>MongoDB\u306e\u505c\u6b62\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo service mongod stop\r\n<\/pre>\n<h3>MongoDB\u306e\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>MongoDB\u306e\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806\u3067\u3059\u3002\u4e0d\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3084\/var\u914d\u4e0b\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3082\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,3,4]; title: ; notranslate\" title=\"\">\r\n$ sudo apt-get purge mongodb-org*\r\n$ sudo apt-get autoremove\r\n$ sudo rm -r \/var\/log\/mongodb\r\n$ sudo rm -r \/var\/lib\/mongodb\r\n<\/pre>\n<h2>MongoDB\u3092Ubuntu\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>MongoDB\u3092Ubuntu\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u624b\u9806\u3067\u3059\u3002MongoDB\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3088\u308a\u5bb9\u6613\u3067\u3059\u304c\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u308b\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u30013.6.3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>MongoDB\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>MongoDB\u3092\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo apt install mongodb\r\n<\/pre>\n<h3>MongoDB\u306e\u8d77\u52d5\u78ba\u8a8d<\/h3>\n<p>MongoDB\u304c\u8d77\u52d5\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002MongoDB\u306f\u3001systemctl\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30fc\u30d3\u30b9\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ sudo systemctl status mongodb\r\n\u25cf mongodb.service - An object\/document-oriented database\r\n   Loaded: loaded (\/lib\/systemd\/system\/mongodb.service; enabled; vendor preset: enabled)\r\n   Active: active (running) since Sun 2018-09-23 10:55:45 JST; 2min 15s ago\r\n     Docs: man:mongod(1)\r\n Main PID: 3876 (mongod)\r\n    Tasks: 23 (limit: 4915)\r\n   CGroup: \/system.slice\/mongodb.service\r\n           \u2514\u25003876 \/usr\/bin\/mongod --unixSocketPrefix=\/run\/mongodb --config \/etc\/mongodb.conf\r\n\r\n<\/pre>\n<h3>MongoDB shell\u304b\u3089\u306e\u63a5\u7d9a<\/h3>\n<p>mongo\u30b3\u30de\u30f3\u30c9\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002MongoDB shell\u3068MongoDB server\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u8868\u793a\u3055\u308c\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\">\"\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ mongo\r\nMongoDB shell version v3.6.3\r\nconnecting to: mongodb:\/\/127.0.0.1:27017\r\nMongoDB server version: 3.6.3\r\n...\r\n&gt; quit()\r\n<\/pre>\n<h3>MongoDB\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u78ba\u8a8d<\/h3>\n<p>MongoDB\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ cat \/etc\/mongodb.conf\r\n# mongodb.conf\r\n\r\n# Where to store the data.\r\ndbpath=\/var\/lib\/mongodb\r\n\r\n#where to log\r\nlogpath=\/var\/log\/mongodb\/mongodb.log\r\n\r\nlogappend=true\r\n\r\nbind_ip = 127.0.0.1\r\n#port = 27017\r\n...\r\n<\/pre>\n<h3>MongoDB\u306e\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>MongoDB\u306e\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806\u3067\u3059\u3002\u4e0d\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3084\/var\u914d\u4e0b\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3082\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,3,4]; title: ; notranslate\" title=\"\">\r\n$ sudo apt purge mongodb\r\n$ sudo apt autoremove\r\n$ sudo rm -r \/var\/log\/mongodb\r\n$ sudo rm -r \/var\/lib\/mongodb\r\n<\/pre>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>\u672c\u7a3f\u3067\u306f\u3001Ubuntu\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089MongoDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u305f\u3002\u672c\u683c\u7684\u306b\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001DB\u9818\u57df\u306e\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u5909\u66f4\u7b49\u3001\u5b9f\u65bd\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001\u304a\u8a66\u3057\u7a0b\u5ea6\u3067\u3042\u308c\u3070\u7c21\u5358\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u4f7f\u7528\u958b\u59cb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u53c2\u8003\u60c5\u5831<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.mongodb.com\/docs\/\" target=\"_blank\" rel=\"noopener\">MongoDB - Documentation<\/a><\/li>\n<li><a href=\"https:\/\/www.mongodb.com\/docs\/manual\/\" target=\"_blank\" rel=\"noopener\">MongoDB Server - Manual<\/a><\/li>\n<\/ul>\n<h2>\u95a2\u9023\u8a18\u4e8b<\/h2>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/9850\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"\u3010\u8a18\u4e8b\u4e00\u89a7\u3011MongoDB\u3092\u4f7f\u3044\u3053\u306a\u3059\uff01\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2018\/09\/eyecatch_mongodb_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">\u3010\u8a18\u4e8b\u4e00\u89a7\u3011MongoDB\u3092\u4f7f\u3044\u3053\u306a\u3059\uff01<\/div><div class=\"substr\">MongoDB\u3092\u4f7f\u3044\u3053\u306a\u3059\u305f\u3081\u306e\u8a18\u4e8b\u4e00\u89a7\u3092\u63b2\u8f09\u3057\u307e\u3059\u3002...<\/div><\/a><\/div>\n<h2>\u53c2\u8003\u66f8\u7c4d\uff08Amazon\uff09<\/h2>\n<p><iframe sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-same-origin\" style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/rcm-fe.amazon-adsystem.com\/e\/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=infotecr-22&language=ja_JP&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=B07BGC4MJ1&linkId=0d0d3ef2181b83931f80739f4cfceb0e\"><\/iframe><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu 18.04 LTS Desktop\u306bMongoDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002MongoDB\u306f\u3001\u30c7\u30fc\u30bf\u3092JSON\u5f62\u5f0f\u3067\u6271\u3046\u306e\u3067\u3001Web API\u3068\u306e\u76f8\u6027\u304c\u3088\u3044\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":9875,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[74,51],"class_list":["post-1137","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb","tag-mongodb","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/1137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/comments?post=1137"}],"version-history":[{"count":3,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/1137\/revisions"}],"predecessor-version":[{"id":10148,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/1137\/revisions\/10148"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media\/9875"}],"wp:attachment":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media?parent=1137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/categories?post=1137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/tags?post=1137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}