Install mongodb2.6 and centosmongodb2.6 on centos 6.5

Source: Internet
Author: User

Install mongodb2.6 and centosmongodb2.6 on centos 6.5

Preface:

System Version: Centos-6.5-x86_64

* ** It is best to compile and install the mongodb 2.6 System Using Centos 64-bit to better utilize the performance of mongodb.


1. Prepare and download the source file (Binary Version)

[Root @ centos ~] # Wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.1.tgz

[Root @ centos ~] # Tar-zvxf mongodb-linux-x86_64-2.6.1.tgz

[Root @ centos ~] # MMV mongodb-linux-x86_64-2.6.1 usr/local/mongo/mongodb

Configure the path environment variable below to ensure that the bin directory of mongodb is included in the path environment variable.

2 configure PATH

[Root @ centos ~] # Vim/etc/profile

Add the following content:

# Set for mongodb
Export MONGODB_HOME =/usr/local/mongo/mongodb
Export PATH = $ MONGODB_HOME/bin: $ PATH

Save and exit

Verify that environment variables take effect

[Root @ centos ~] # Mongod-version

3. Create a directory for storing data and logs

3.1 create a directory

[Root @ centos ~] # Mkdir-p/data/mongodb/journal

[Root @ centos ~] # Mkdir-p/data/mongodb/log

3.2 Create a log file

[Root @ centos ~] # Touch/data/mongodb/log/mongodb. log

3.3 create a configuration file

[Root @ centos ~] # Vim/etc/mongodb. conf

Enter the following content, save and return
Dbpath =/data/mongodb
Logpath =/data/mongodb/log/mongodb. log
Logappend = true
Port = 27017
Fork = true
Noauth = true
Nojournal = true
Smallfiles = true
Noprealloc = true

4. Run the mongod service after the restart.

[Root @ centos ~] # Mongod-f/etc/mongodb. conf

 

5. test whether the service is normal.

5.1 open another terminal and enter the management background as an administrator

[Root @ centos ~] # Mongo admin

> Show dbs;

# Switching/creating a database (the current database is automatically created when a set (table) is created)
Use admin;
# Adding users
Db. addUser ("zhoulf", "123456", true)
# Change Password (Change Password for an existing user)
Db. addUser ("zhoulf", "zhoulf ");
# Display the current db status
Db. stats ();
# Current db version
Db. version ();
# Deleting the currently used database
Db. dropDatabase ();
# View the address of the linked machine of the current db
Db. getMongo ();
# Simple data insertion
Db. user. insert ({"fname": "zhoulf", "company": "navinfo "})
# Insert data cyclically
For (var I = 1; I <= 10; I ++) db. user. save ({"fname": "zhoulf" + I, "company": "navinfo" + I });
# Querying data
Db. user. find ()


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.