Install mongodb on centous

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.