Mongodb installation and Verification

Source: Internet
Author: User
Tags create mongodb

Mongodb installation and Verification
Installation plan:
System Environment: Centos-6.5
Software: mongodb-linux-x86_64-2.6.5.tgz
: Http://www.mongodb.org/downloads
Installation machine: 10.10.10.110
Upload location:/data
Software installation path:/usr/local/mongodb
Data storage location:/data/mongodb
Log storage location:/var/log/mongodb. log
Disable iptable, ip6tables, and selinux
Prerequisites:
1. Check whether mongodb has been installed
[Root @ ~] # Rpm-qa | grep mongodb
[Root @ vstar ~] # Service mongodb status
2. Create a user, install the required directory, and authorize
[Root @ ~] # Groupadd mongodb
[Root @ ~] # Useradd-g mongodb-s/sbin/nologin-M mongodb
[Root @ data] # mkdir-p/data/mongodb

[Root @ data] # chown-R mongodb: mongodb/data/mongodb

[Root @ data] # mkdir-p/var/log/mongodb

[Root @ data] # chown-R mongodb: mongodb/var/log/mongodb

Installation:
[Root @ ~] # Cd/data/
[Root @ data] # tar-zxvf mongodb-linux-x86_64-2.6.5.gz
[Root @ data] # mv mongodb-linux-x86_64-2.6.5/usr/local/mongodb
[Root @ data] # cd/usr/local/mongodb/
[Root @ mongodb] # chown-R mongodb: mongodb *
Configuration:
Add a boot entry for mongodb to CentOS
[Root @ vstar mongodb] # vi/etc/rc. d/rc. local
/Usr/local/mongodb/bin/mongod -- dbpath =/data/mongodb/-- logpath/var/mongodb/logs/log. log-fork
Start Method 1:
[Root @ mongodb] #/usr/local/mongodb/bin/mongod -- dbpath =/var/mongodb/data -- logpath/var/mongodb/logs/log. log-fork
The -- fork option indicates that MongoDB is run as a background service process.
The following information indicates that the installation is completed and started successfully:
Forked process: 18394
All output going to:/var/mongodb/logs/log. log
Start Method 2:

Create mongodb. conf

# Vi/etc/mongodb. conf

dbpath=/data/mongodblogpath=/var/log/mongodb/mongodb.loglogappend=tureport=27017rest=truefork=true

When calling mongodb, the-f option is usually used with the mongodb. conf file.

# Mongod-f mongodb. conf

You can also add this command to/etc/rc. local to enable mongodb to start up;

Test and verification
Method 1: Command Line
# Terminate a server process
Db. user. shutdownServer ()
# Entering the mongodb shell mode
[Root @ data] #/usr/local/mongodb/bin/mongo
MongoDB shell version: 2.6.5
Connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help ".
For more comprehensive documentation, see
Http://docs.mongodb.org/
Questions? Try the support group
Http://groups.google.com/group/mongodb-user
Method 2: web Interface
When you access http: // ip: 27017, this message is displayed.
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
It is actually a euphemism to tell you that you should access this port: http: // ip: 28017
If you have a root account, you can directly enter the root account and password for normal access!

Related commands:

# Viewing the Database List

> Show dbs
Admin (empty)
Local 0.078 GB
# Switching/creating a database (the current database is automatically created when a set (table) is created)
Use admin;
# Adding users
Db. addUser ("jacson", "111111", true)
# Change Password (Change Password for an existing user)
Db. addUser ("jacson", "123456 ");
# Display the current db status
Db. stats ();
# Current db version
> Db. version (); db. version ();
2.6.5
# 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": "jacson", "company": "navinfo "})
# Insert data cyclically
For (var I = 1; I <= 10; I ++) db. user. save ({"fname": "jacson" + I, "company": "navinfo" + I });
Up to 10000 inserts can be simulated.
For (var I = 1; I <= 10000; I ++) db. user. save ({"fname": "jacson" + I, "company": "navinfo" + I });
# Querying data
Db. user. find ()

Related Article

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.