1. Download installation package
wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-3.0.1.tgz?_ga=1.96171865.475907078.1449151064
Because this MongoDB website downloads very slow, so I did not download through the wget way, I was downloading directly under my window to copy over.
Unzip the compressed package after the download is complete
Tar zxvf mongodb-linux-x86_64-3.0.1.tgz
[root@localhost ~]# cd/home/lk/Download
[root@localhost downloads]# ll
total dosage 342016
-rw-rw-r--. 1 lk 107582174 October 09:37 apache-servicemix-6.0.0.zip
-rw-rw-r--. 1 lk lk 9130958 October 17 12:02 apache-tomcat-8.0.28.tar.gz
-rw-rw-r--. 1 lk 7250317 October 17 16:10 flash-plugin-11.2.202.540-release.x86_64.rpm
-rw-rw-r--. 1 lk 181238643 October 17 10:47 jdk-8u60-linux-x64.tar.gz
-rw-r--r--. 1 root 1032 December 5 11:35 mongodb-linux-x86_64-2.6.0.tgz
-rw-r--r--. 1 root 39554547 December 4 00:41 mongodb-linux-x86_64-3.0.1.gz
-rw-r--r--. 1 root root 885562 November 22:59 nginx-1.9.7.tar.gz
-rw-r--r--. 1 root root 4560208 July 9 20:42 openssl-1.0.1p.tar.gz
[root@localhost download]# tar zxvf mongodb-linux-x86_64-3.0.1.gz
2. Installation Preparation
MV mongodb-linux-x86_64-3.0.1/opt/deploy/mongodb-3.0.1
Creating database folders and log files
mkdir/opt/deploy/mongodb-3.0.1/mongodb/data/db
Touch/opt/deploy/mongodb-3.0.1/mongodb/logs
3. Startup mode setting
3.1 starts with Config
port=27017 #端口号 <pre name= "code" class= "HTML" ><span style= "font-family: ' Helvetica neue ', Helvetica, Arial, Sans-serif; " >dbpath=/opt/deploy/mongodb-3.0.1/mongodb/data/db</span>
Logpath=/opt/deploy/mongodb-3.0.1/mongodb/logsfork=true #设置后台运行logappend =true #日志输出方式shardsvr =truedirectoryperdb =true#auth=true #开启认证
3.2 Boot up
/opt/deploy/mongodb-3.0.1/bin/mongod--dbpath=/opt/deploy/mongodb-3.0.1/mongodb/data/db--logpath=/opt/deploy/ Mongodb-3.0.1/mongodb/logs--logappend--bind_ip=0.0.0.0--port=27017--auth--fork
4. Start Stop MongoDB
./mongod--config/opt/deploy/mongodb-3.0.1/mongodb.conf #启动MongoDB
./mongo
/mongo 127.0.0.1:27017/ Admin--eval "Db.shutdownserver ()" #关闭MongoDB
5. Remote Connection
MONGO 192.168.32.129:27017/admin-u admin-p Admin
If a connection timeout occurs or a 27017 interface fails to connect, ping IP is successful, then we should think of:
1. The bind_ip default in the MongoDB configuration file is 127.0.0.1, and the default is that only this computer can connect. At this point, you need to configure the BIND_IP to 0.0.0.0, which means that any IP connections are accepted. But after the change is still not allowed, then we execute the following 2
2, the firewall blocked 27017 ports. Because in RED7 or CentOS7, the command to turn off the firewall is changed to: Systemctl stop Firewalld, and then you can really turn off the firewall feature. Remote Connection MongoDB successful.