MONGODB Installation and Configuration

Source: Internet
Author: User

1. copy MongoDB to the specified server

To the MongoDB official website http://www.mongodb.org/downloads download MongoDB, unzip and test the directory on the server that needs to be installed, and then configure. For example:

[Email protected] ~]# scp-r [email protected]:/data/web/dxm/mongodb/mongodb-linux-x86_64-2.4.5 data/web/

The MongoDB directory will be copied to the ~/data/web directory of the 10.11.17.165 server.

2. set up data, log directory

Go to the MongoDB root directory, create a new data directory to hold it, create a new log directory to hold the log, and then create a new one in the directory, for example, named Mongodb.log.

[Email protected] mongodb]# mkdir data

[Email protected] mongodb]# mkdir logs

[Email protected] mongodb]# CD logs

[email protected] logs]# Touch Mongodb.log

3.Creating a configuration file

in the MongoDB root directory Create a new profile with any file name, such as mongodb.conf, then add the configuration information in the configuration file:

port=27017 "represents the port number, if not specified, the default is 27017 "

dbpath=/root/data/web/mongodb/data/ "Database Path"

Logpath=/root/data/web/mongodb/logs/mongodb.log " Log Path "

logappend=true "Log files automatically accumulate, not overwrite"

4.Start the MongoDB service (based on the configuration file)

Execute command

[Email protected]5 mongodb]#/bin/mongod-f mongodb.conf

The following message appears:

All output going to:/root/data/web/mongodb/logs/mongodb.log

5.use the client to connect to the database

Re-open a terminal and switch to the MongoDB directory

[Email protected] ~]# CD Data/web/mongodb

then input

[email protected] mongodb]# Bin/mongo localhost:2701 7

MongoDB Shell version:2.4.5

Connecting To:localhost:27017/test

Server has startup warnings:

Fri Nov 8 13:05:59.823 [Initandlisten]

Fri Nov 8 13:05:59.823 [Initandlisten] * * Warning:you is running on a NUMA machine.

Fri Nov 8 13:05:59.823 [Initandlisten] * * We suggest launching mongod like this to avoid performance problems:

Fri Nov 8 13:05:59.823 [Initandlisten] * * Numactl--interleave=all Mongod [Other options]

Fri Nov 8 13:05:59.823 [Initandlisten]

>

The connection was successful.

6. Configure self-boot (optional)set boot auto start MongoDB

[Email protected] ~]# echo "/root/data/web/mongodb/bin/mongod-f/root/data/web/mongodb/mongodb.conf-fork" >>/ Etc/rc.local

Setting environment variables

VI ~/.bash_profile

Path= $PATH: $HOME/bin: $JAVA _home/bin:/root/data/web/mongodb/bin

MONGODB Installation and Configuration

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.