{"id":7365,"date":"2018-05-03T10:03:01","date_gmt":"2018-05-03T02:03:01","guid":{"rendered":"http:\/\/rmohan.com\/?p=7365"},"modified":"2018-05-03T10:03:01","modified_gmt":"2018-05-03T02:03:01","slug":"centos-7-mongodb-3-4","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7365","title":{"rendered":"CentOS 7  MongoDB 3.4"},"content":{"rendered":"<p>nstall MongoDB 3.4 process on yum\u00a0under\u00a0<a title=\"CentOS\" href=\"http:\/\/www.linuxidc.com\/topicnews.aspx?tid=14\" target=\"_blank\" rel=\"noopener\">CentOS<\/a>\u00a07 system.<\/p>\n<p>The first step to see if there is a MongoDB configuration yum source<\/p>\n<p>Switch to the yum directory cd \/etc\/yum.repos.d\/<\/p>\n<p>View the file ls<\/p>\n<p>The second part does not exist to add yum source<\/p>\n<p>Create the file touch mongodb-3.4.repo<\/p>\n<p>Edit this file vi mongodb-3.4.repo<\/p>\n<p>content:<\/p>\n<p>Cat \/etc\/yum.repos.d\/mongodb-3.4.repos<\/p>\n<p>[mongodb-org-3.4]<\/p>\n<p>Name=MongoDB Repository<\/p>\n<p>Baseurl=https:\/\/repo.mongodb.org\/yum\/\u00a0<a title=\"RedHat\" href=\"http:\/\/www.linuxidc.com\/topicnews.aspx?tid=10\" target=\"_blank\" rel=\"noopener\">RedHat<\/a>\u00a0\/$releasever\/mongodb-org\/3.4\/x86_64\/<\/p>\n<p>Gpgcheck=1<\/p>\n<p>Enabled=1<\/p>\n<p>Gpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-3.2.asc<\/p>\n<p><strong>You can modify gpgcheck=0 here to save gpg verification<\/strong><\/p>\n<p>Update all packages before installation: yum update (optional operation)<\/p>\n<p>Then install: yum install -y mongodb-org<\/p>\n<p>Check the mongo installation location whereis mongod<\/p>\n<p>Check the modified configuration file: vi \/etc\/mongod.conf<\/p>\n<p>Start mongod :systemctl start mongod.service<\/p>\n<p>Stop mongod :systemctl stop mongod,service<\/p>\n<p><strong>External network access needs to shut down the firewall:<\/strong><\/p>\n<p>CentOS 7.0 uses firewall as the firewall by default, and it is changed to iptables firewall.<\/p>\n<p>Close the firewall:<\/p>\n<p>Systemctl stop firewalld.service #stop firewall<\/p>\n<p>Systemctl disable firewalld.service #Disable firewall startup<\/p>\n<p>Use mongodb : mongo 192.168.60.102:27017<\/p>\n<p>&gt;use admin<\/p>\n<p>&gt;show dbs<\/p>\n<p>&gt;show collections<\/p>\n<p>After restarting Mongodb, log in to the admin account and create a super-privileged user<\/p>\n<p>Use admin<\/p>\n<p>db.createUser({user:&#8217;root&#8217;,pwd:&#8217;root&#8217;,roles:[{ &#8220;role&#8221; : &#8220;root&#8221;, &#8220;db&#8221; : &#8220;admin&#8221; }]});<\/p>\n<p><strong>Configuration<\/strong><\/p>\n<p>Fork=true ## allows programs to run in the background<\/p>\n<p>#auth=true ## Start Authentication<\/p>\n<p>Logpath=\/data\/db\/mongodb\/logs\/mongodb.log logappend=true # Write log mode: set to true to append.\u00a0The default is to override dbpath=\/data\/db\/mongodb\/data\/ ## data storage directory<\/p>\n<p>Pidfilepath=\/data\/db\/mongodb\/logs\/mongodb.pid # Process ID. If not specified, there will be no PID file when starting.\u00a0Default default.<\/p>\n<p>Port=27017<\/p>\n<p>#bind_ip=192.168.2.73 # Bind addresses.\u00a0The default is 127.0.0.1. You can only change the data directory storage mode by setting the local connection # to true. Each database file is stored in a different folder in the DBPATH specified directory.\u00a0# With this option, MongoDB can be configured to store data on different disk devices to increase write throughput or disk capacity.\u00a0The default is false.\u00a0# suggest to configure sub-options from the beginning<\/p>\n<p>Directoryperdb=true # Disable log # Enable the operation log for the journal to ensure write consistency and data consistency. Create a journal directory in the dbpath directory<\/p>\n<p>Nojournal = true ##<\/p>\n<p>Max connections # The maximum number of connections.\u00a0Default: Depends on system (ie ulimit and file descriptor) restrictions.\u00a0# MongoDB does not limit its own connection.\u00a0When the setting is greater than the system limit, it is invalid and the system limit prevails.\u00a0# Set the value of this value higher than the size of the connection pool and the total number of connections to prevent connections at peak times.\u00a0# Note: This value cannot be set greater than 20000.\u00a0maxConns=1024<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nstall MongoDB 3.4 process on yum under CentOS 7 system.<\/p>\n<p>The first step to see if there is a MongoDB configuration yum source<\/p>\n<p>Switch to the yum directory cd \/etc\/yum.repos.d\/<\/p>\n<p>View the file ls<\/p>\n<p>The second part does not exist to add yum source<\/p>\n<p>Create the file touch mongodb-3.4.repo<\/p>\n<p>Edit this file vi mongodb-3.4.repo<\/p>\n<p>content:<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7365"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7365"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7365\/revisions"}],"predecessor-version":[{"id":7366,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7365\/revisions\/7366"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}