Setup MongoDB

MongoDB (from "humongous") is an open-source document database, and the leading NoSQL database

A. Install MongoDB

  1. Configure the package management system (YUM)

    Create a /etc/yum.repos.d/mongodb.repo file to hold the following configuration information for the MongoDB repository:

    If you are running a 64-bit system, use the following configuration:

    [mongodb]
    name=MongoDB Repository
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
    gpgcheck=0
    enabled=1
    

    If you are running a 32-bit system, which is not recommended for production deployments, use the following configuration:

    [mongodb]
    name=MongoDB Repository
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
    gpgcheck=0
    enabled=1
    
  2. Install the MongoDB packages and associated tools

    When you install the packages, you choose whether to install the current release or a previous one. This step provides the commands for both.

    To install the latest stable version of MongoDB, issue the following command:

    sudo yum install mongodb-org
    

    To install a specific release of MongoDB, specify each component package inpidually and append the version number to the package name, as in the following example that installs the 2.6.1` release of MongoDB:

    sudo yum install mongodb-org-2.6.1 mongodb-org-server-2.6.1 mongodb-org-shell-2.6.1 mongodb-org-mongos-2.6.1 mongodb-org-tools-2.6.1
    

    You can specify any available version of MongoDB. However yum will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, pin the package. To pin a package, add the following exclude directive to your /etc/yum.conf file:

    exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
    

B. Run MongoDB

  1. Configure SELinux

    You must configure SELinux to enable access to the relevant ports (e.g. 27017) for SELinux, allow MongoDB to start on Centos systems.

  2. Configure to remote connect

    The default /etc/mongodb.conf configuration file supplied by the 2.6 series has "bind_ip set to "127.0.0.1" by default.

    Comment out line bind_ip=127.0.0.1 to listen on all interfaces.

  3. Start MongoDB

    sudo service mongod start
    
  4. Verify that MongoDB has started successfully

    You can verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log.

    You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:

    sudo chkconfig mongod on
    
  5. Stop MongoDB

    sudo service mongod stop
    
  6. Restart MongoDB

    sudo service mongod restart
    

    You can follow the state of the process for errors or important messages by watching the output in the /var/log/mongo/mongod.log file.

Comments

Popular posts from this blog

Reduce TIME_WAIT Socket Connections