{"id":2170,"date":"2016-07-05T17:14:42","date_gmt":"2016-07-05T21:14:42","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2170"},"modified":"2017-12-12T16:04:59","modified_gmt":"2017-12-12T21:04:59","slug":"install-mongodb-ubuntu16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/","title":{"rendered":"How to install MongoDB on Ubuntu16"},"content":{"rendered":"<h1>How to install MongoDB on Ubuntu16<\/h1>\n<p>MongoDB is a developer and operations-friendly NoSQL database. Its schemaless nature makes getting started simple, as there is no need to establish a data model before persisting documents. Use of a modified JSON dialect speaks a language with which most web developers are familiar. When it is time to scale out, a few simple commands are all that is necessary to create a database cluster, and to distribute documents using a variety of heuristics.<\/p>\n<h2>Getting Started<\/h2>\n<p>To complete this guide, you will need the following:<br \/>\n\u2022 1 Node (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running Ubuntu 16.<br \/>\n\u2022 Root Access to your server<\/p>\n<p>When complete, you&#8217;ll have a single-node Mongo instance that can either be used directly, or integrated into a broader cluster.<\/p>\n<h2>Tutorial<\/h2>\n<p>Start by updating the list of packages, and by applying all current bugfixes and security updates. This step should be performed regularly to keep your system running smoothly and securely.<\/p>\n<p><code>apt-get update && apt-get upgrade<\/code><\/p>\n<p>MongoDB is shipped in its own official package repository. To install it, we&#8217;ll integrate this repository into our system in several steps. We begin by fetching the official GPG keys, which are necessary to ensure that the downloaded packages are correctly signed.<\/p>\n<p><code>apt-key adv --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv EA312927<\/code><\/p>\n<p>Now we add the repository itself directly into sources.list.<\/p>\n<p><code>echo \"deb http:\/\/repo.mongodb.org\/apt\/ubuntu trusty\/mongodb-org\/3.2 multiverse\" | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-3.2.list<\/code><\/p>\n<p>The Ubuntu package system does not yet know what packages are available in the repository we&#8217;ve just added. In order to fix this, we&#8217;ll once again update the packages list.<\/p>\n<p><code>apt-get update<\/code><\/p>\n<p>Having fetched the list of available packages, we&#8217;ll install the MongoDB package itself.<\/p>\n<p><code>apt-get install -y --allow-unauthenticated mongodb-org<\/code><\/p>\n<p>Ubuntu uses Systemd, and we&#8217;ll need to create a script so that the init system integrates with MongoDB.<\/p>\n<p><code>nano \/etc\/systemd\/system\/mongodb.service<\/code><\/p>\n<p>Add this block of text.<\/p>\n<p><code class=\"gris\">[Unit]<br \/>\nDescription=High-performance, schema-free document-oriented database<br \/>\nAfter=network.target<br \/>\n[Service]<br \/>\nUser=mongodb<br \/>\nExecStart=\/usr\/bin\/mongod --quiet --config \/etc\/mongod.conf<br \/>\n[Install]<br \/>\nWantedBy=multi-user.target<\/code><\/p>\n<p>With the unit in place, MongoDB must now be started. It should also be enabled to start on boot, so it is available when the server restarts.<\/p>\n<p><code>systemctl start mongodb.service<br \/>\nsystemctl enable mongodb.service<\/code><\/p>\n<p>Let&#8217;s ensure that Mongo is in fact running. Use this command to check its status. If it failed to start, you should see any relevant failure messages in the displayed logs.<\/p>\n<p><code>systemctl status mongodb<\/code><\/p>\n<p><code class=\"gris\">? mongodb.service - High-performance, schema-free document-oriented database<br \/>\n   Loaded: loaded (\/etc\/systemd\/system\/mongodb.service; disabled; vendor preset: enabled)<br \/>\n   Active: active (running) since Fri 2016-06-24 09:11:53 UTC; 9min ago<br \/>\n Main PID: 15300 (mongod)<br \/>\n    Tasks: 16<br \/>\n   Memory: 86.6M<br \/>\n      CPU: 3.441s<br \/>\n   CGroup: \/system.slice\/mongodb.service<br \/>\n           ??15300 \/usr\/bin\/mongod --quiet --config \/etc\/mongod.conf<\/code><\/p>\n<p>Now we&#8217;ll query Mongo itself for statistics. This will ensure that the database is operating normally.<\/p>\n<p><code>Mongostat<\/code><\/p>\n<p><code class=\"gris\">insert query update delete getmore command % dirty % used flushes  vsize   res qr|qw ar|aw netIn netOut conn                 time<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:23:57Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:23:58Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:23:59Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:00Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:01Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:02Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:03Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:04Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:05Z<br \/>\n    *0    *0     *0     *0       0     1|0     0.0    0.0       0 250.0M 87.0M   0|0   0|0   79b    18k    1 2016-06-24T09:24:06Z<br \/>\ninsert query update delete getmore command % dirty % used flushes  vsize   res qr|qw ar|aw netIn netOut conn                 time<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>Mongo is now installed, running, and configured to launch on boot. The package repository is also integrated, making it easy to install future upgrades. With MongoDB in place, you can now develop against it directly, or perform this guide on another server to build a cluster. If this guide was helpful to you, kindly share it with others who may also be interested. <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to install MongoDB on Ubuntu16 MongoDB is a developer and operations-friendly NoSQL database. Its schemaless nature makes getting started simple, as there is no need to establish a data model before persisting documents. Use of a modified JSON dialect speaks a language with which most web developers are familiar. When it is time to<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-2170","post","type-post","status-publish","format-standard","hentry","category-database","operating_system-ubuntu-16-04"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install MongoDB on Ubuntu16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to install MongoDB on your Ubuntu 16 server. Read now and enjoy your new NoSQL Database !\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install MongoDB on Ubuntu16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to install MongoDB on your Ubuntu 16 server. Read now and enjoy your new NoSQL Database !\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-05T21:14:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-12T21:04:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/\",\"name\":\"How to install MongoDB on Ubuntu16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-07-05T21:14:42+00:00\",\"dateModified\":\"2017-12-12T21:04:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to install MongoDB on your Ubuntu 16 server. Read now and enjoy your new NoSQL Database !\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install MongoDB on Ubuntu16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install MongoDB on Ubuntu16 - Globo.Tech","description":"This tutorial will show you how to install MongoDB on your Ubuntu 16 server. Read now and enjoy your new NoSQL Database !","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/","og_locale":"en_US","og_type":"article","og_title":"How to install MongoDB on Ubuntu16 - Globo.Tech","og_description":"This tutorial will show you how to install MongoDB on your Ubuntu 16 server. Read now and enjoy your new NoSQL Database !","og_url":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/","og_site_name":"Globo.Tech","article_published_time":"2016-07-05T21:14:42+00:00","article_modified_time":"2017-12-12T21:04:59+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/","url":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/","name":"How to install MongoDB on Ubuntu16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-07-05T21:14:42+00:00","dateModified":"2017-12-12T21:04:59+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to install MongoDB on your Ubuntu 16 server. Read now and enjoy your new NoSQL Database !","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-mongodb-ubuntu16\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to install MongoDB on Ubuntu16"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2170"}],"version-history":[{"count":6,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2170\/revisions"}],"predecessor-version":[{"id":4014,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2170\/revisions\/4014"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}