Linux installation MONGO

Source: Internet
Author: User

Installing MongoDB operating instructions in Linux

MongoDB Configuration

    1. Version Note: This example takes the 64-bit mongdb as an example because the red Hat is installed on the machine. 64-bit operating system The following version is used:

(1) Red Hat Enterprise Linux 6.2 (test application)

(2) mondb:mongodb-linux-x86_64-rhel62-3.0.3

    1. First download the appropriate 64-bit Linux version of mondb from the official website, the download URL is:

http://www.mongodb.org

    1. Pre-Configuration preparation work

Method one: Operate with Linux commands

--Create a MongoDB home directory

# mkdir/usr/local/mongodb/

--Unzip the MongoDB package to the MongoDB home directory

# TAR-XVF mongodb-linux-x86_64-rhel62-3.0.3-c/usr/local/mongodb/

--Create a MongoDB data directory that can be stored in any location. According to the habit, put it in data.

# mkdir/usr/local/mongodb/data/

--Create a MongoDB log directory, which can be stored in any location. According to the habit, put it in log.

# mkdir/usr/local/mongodb/log/

Method Two: Manually unzip the file to create the directory

(1) Manually unzip the file, unzip it as shown below:

(2) Create a table of contents (see the instructions above)

    1. /usr/local/mongodb
    2. /usr/local/mongodb/data/
      1. /usr/local/mongodb/log/

After the above is established, create a log file in the log folder both: Mongodb.log

    1. Configure MongoDB

--Enter the MongoDB command line

# cd/usr/local/mongodb/bin/

#./mongod--dbpath=/usr/local/mongodb/data/--logpath=/usr/local/mongodb/log/mongo.log

(./mongod--dbpath/usr/local/mongodb/data/--logpath/usr/local/mongodb/log/mongodb.log--fork)

#./mongo

MongoDB Shell version:3.0.3

Connecting To:test

# pwd

/usr/local/mongodb/bin

# Vim ~/.bash_profile

# tail-n3!$

Tail-n3 ~/.bash_profile

Path= $PATH: $HOME/bin:/usr/local/mongodb/bin

Export PATH

# source!$

SOURCE ~/.bash_profile

    1. Start MongoDB

(1) Execute under Usr/local/mongodb/bin./mongod--dbpath/usr/local/mongodb/data/

The Connect now open will appear after execution

(2) Open Browser input: http://localhost:27017 Enter appears as shown:

Indicates that the startup was successful. The premise is that the port of Mongdb is: 27017.

Modify Firewall actions

First, in the Linux system to find and open the Edit configuration firewall files,

Execute command: vi/etc/sysconfig/iptables

Second, in the file opened above add a statement:-a input-m state–state new-m tcp-p tcp–dport 27017-j ACCEPT (allow 80 ports through the firewall, here to 27017 Port as an example

Third, add the following firewall rules as follows:

4. Restart the firewall to make the configuration effective

/etc/init.d/iptables restart

Linux installation MONGO

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.