1. Download
MongoDB offers Linux release 64-bit installation package download address: https://www.mongodb.com/download-center#community
2. Installation
1 tar-zxvf mongodb-linux-x86_64-3.0.6.tgz # decompression
2
3 mv mongodb-linux-x86_64-3.0.6//usr/local/ MongoDB # Copies the unpacked package to the specified directory
The MongoDB executable is in the bin directory, so you can add it to the path:
Export Path=<mongodb-install-directory>/bin: $PATH
<mongodb-install-directory> The installation path for your MongoDB. such as the /usr/local/mongodb of this article. Create a database directory
MongoDB data is stored in the DB directory of the data directory, but this directory is not created automatically during the installation process, so you will need to manually create a data directory and create a DB directory in the data directory.
In the following example, we create the data directory in the root directory (/).
Note:/data/db is the MongoDB default startup database path (--dbpath).
Mkdir-p/data/db
Start the service side
Enter the installation directory/usr/local/mongodb/bin,
./mongod #启动服务端
Remote Client Links
1. Because MongoDB uses the default short time 27017, but the Linux firewall is blocked 27017 port access, so you need to open the Linux firewall 27017 ports
Vi/etc/sysconfig/iptables #查看防火墙配置表
Modified to read as follows:
#特别提示: Many netizens add these two rules to the last line of the firewall configuration, which causes the firewall to start failing, the correct one should be added to the default 22 port under the Rule
# Firewall configuration written by System-config-firewall
# Manual Customization of this file is not recommended.
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m state–state Establish Ed,related-j ACCEPT
-a input-p icmp-j ACCEPT-
a input-i lo-j ACCEPT
-a input-m state–state new-m TCP- P tcp–dport 22-j ACCEPT
-a input-m state–state new-m tcp-p tcp–dport 27017-j ACCEPT
-A input-m state–s Tate new-m tcp-p tcp–dport 3306-j ACCEPT-a input-j reject–reject-with
-a icmp-host-prohibited Reject–reject-with icmp-host-prohibited
Finally reboot the firewall for the configuration to take effect
Finally, you can use your remote client to access MongoDB
. \mongo 192.168.*.***:27017