Installing Mongodb under Linux

Source: Internet
Author: User
Tags mongodb like

The installation of MongoDB under Linux should be simple, but there is a small point to note, which is why I wrote this blog.

First download the latest stable version to its official website, extract to the directory, such as/usr/local/mongodb

Create the Data folder and the logs (touch logs) log file under MongoDB.

Installation steps
    • Enter the/usr/local directory
    • Cd/usr/local

    • Create a MongoDB folder as the installation destination folder
      mkdir MongoDB

    • Unzip the file and move it to the MongoDB folder
      TAR-ZXVF mongodb-linux-x86_64-2.6.7.tgz

    • Move all files under the extracted folder to the MongoDB folder
      CD MONGODB-LINUX-X86_64-2.6.7MV */usr/local/mongodb

    • Create a Data folder to hold the file, create a logs file to store it
      Cd/usr/local/mongodbmkdir Datatouch Logs

    • Change directory Permissions

    • chown `id -u` /data/db

    • Cd..
    • Chown ' Id-u '/mongo

    • Start MongoDB Service
      CD Bin./mongod-dbpath=/usr/local/mongodb/data-logpath=/usr/local/mongodb/logs

    • Background service startup

    • ./mongod-dbpath=/usr/local/mongodb/data-logpath=/usr/local/mongodb/logs--fork
    • Background permissions Start
    • ./mongod-dbpath=/usr/local/mongodb/data-logpath=/usr/local/mongodb/logs--fork--auth
Now MongoDB will be able to start the success. If it is already started, it can be terminated first, and so on after the configuration is restarted.

Note that the above we started MongoDB are manually use Mongod to start, so after shutting down the computer, the next time it did not start, so it has to be started manually, so in order to avoid this tedious work, you can put Mongod into the service from the startup item,  In this way, when the computer opens the Mongod service is started.   To edit the/etc/rc.local, add the following code and save it. 1. #add mongondb Service
2.rm-rf/data/mongodb_data/* &&/usr/local/mongodb/bin/mongod--dbpath=/data/mongodb_data/--logpath=/data/  Mongodb_log/mongodb.log--logappend& We restart the computer and see if MongoDB is started, restart can be directly using the MONGO command to log in, and finally found that it can be successful. Also, we use the MONGO command to log in to MongoDB and go to the directory where the MONGO command is located and execute./mongo, is that a bit of a problem? Therefore, we can simplify this by copy the command file to/usr/bin so that the MONGO command can be used in any directory.
Netstat-anp
Find the PID of MongoDB like 3303
Kill-9 3303
To end the process

Installing Mongodb under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.