1. download and decompress the mongodb file. Put the decompressed file under/opt/(the storage directory is used to the installation) # wgethttp: // #1. download and decompress the mongodb file. Put the decompressed file under/opt/(store the directory and install the file as needed)
# 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, it is more concise from the name)
2,
Create data files and date files stored in mongodb (mongodb_db, mongodb_logs)
# Cd/
# Mkdir mongodbdata
# Cd mongodbdata
# Mkdir mongodb_db
# Mkdir mongodb_logs
3,
Enter the decompressed mongodb2.0.4/bin directory, start mongodb, and 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
4,
Check whether the port is enabled. The port is 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: you can use the mongodb client to connect to the database. Go to the bin directory and run mongo.
#./Mongo
MongoDB shell version: 2.0.4connecting to: test
> Use cmd_test to create a database
> Db. createCollection ("test") create a table