Installing MongoDB operating instructions in Linux
MongoDB Configuration
- 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
- First download the appropriate 64-bit Linux version of mondb from the official website, the download URL is:
http://www.mongodb.org
- 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)
- /usr/local/mongodb
- /usr/local/mongodb/data/
- /usr/local/mongodb/log/
After the above is established, create a log file in the log folder both: Mongodb.log
- 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
- 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