Download and unzip the MongoDB file. Put the extracted files under/opt/(store directory to install their own habits)
# wget Http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz
# tar-zxvfmongodb-linux-x86_64-2.0.4.tgz
# MV Mongodb-linux-x86_64-2.0.4.tgz mongodb2.0.4 (for convenience, make it more concise from the name)
Create MongoDB-stored data files, days files (mongodb_db, mongodb_logs)
# CD/
#mkdir Mongodbdata
#cd Mongodbdata
#mkdir mongodb_db
#mkdir Mongodb_logs
-  
Enter the Mongodb2.0.4/bin directory you just unzipped, start MongoDB, specify the output path
#cd/opt/ Mongodb2.0.4/bin
#./ Mongod--dbpath= / mongodbdata/mongodb_db--logpath= / mongodbdata/mongodb_ Logs/mongodb.log--logappend&
"All output going to:/mongodbdata/mongodb_logs/mongodb.log" appears after execution
Check whether the port is started, port: 27017
# NETSTAT-LANP | grep 27017
TCP 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 560/mongod UNIX 2 [ ACC] STREAM LISTENING 128435 560/mongod/tmp/mongodb-27017.sock
Started successfully.
- 5
5th: The MongoDB client can be used to connect to the database. Go to the Bin directory and execute MONGO
#./mongo
MongoDB Shell version:2.0.4connecting to:test
>use Mongo_test Creating a library
>db.createcollection ("test") CREATE table
# #后台运行
--fork --logpath=/srv/infra/mongodb/mongodbdata/mongodb_logs/mongodb.log--logappend&
Linux Installation MongoDB