MongoDB installation and configuration notes _mongodb

Source: Internet
Author: User
Tags mkdir mongodb port number

1. Copy MongoDB to the specified server

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

Copy Code code as follows:

[root@shnhdx17-165 ~]# scp-r root@10.3.18.80:/data/web/dxm/mongodb/mongodb-linux-x86_64-2.4.5 data/web/

Will copy the MongoDB directory to the ~/data/web directory of the 10.11.17.165 server.

2. Establish data, log directory

Go to the MongoDB root directory, create a new data directory to store the information, create a new log directory, and then create a new log file in the directory, such as Mongodb.log.

Copy Code code as follows:

[root@shnhdx17-165 mongodb]# mkdir data

[root@shnhdx17-165 mongodb]# mkdir logs

[root@shnhdx17-165 mongodb]# CD logs

[root@shnhdx17-165 logs]# Touch Mongodb.log

3. Create a configuration file

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

Copy Code code as follows:

PORT=27017 "represents the port number and defaults to 27017 if not specified"

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

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

Logappend=true "Log files are automatically cumulative, not overwritten"

4. Start the MongoDB service (according to the configuration file)

Execute command

Copy Code code as follows:

[root@shnhdx17-165 mongodb]#./bin/mongod-f mongodb.conf

The following message appears:
Copy Code code as follows:

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

5. Use the client to connect to the database

Reopen a terminal and switch to the MongoDB directory

Copy Code code as follows:

[root@shnhdx17-164 ~]# CD Data/web/mongodb

And then enter
Copy Code code as follows:

[root@shnhdx17-164 mongodb]# Bin/mongo localhost:27017

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 are 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 from start (optional)

Set up automatic boot MongoDB

Copy Code code as follows:

[root@shnhdx17-165 ~]# echo "/root/data/web/mongodb/bin/mongod-f/root/data/web/mongodb/mongodb.conf-fork" >> /etc/rc.local

Setting environment variables
Copy Code code as follows:

VI ~/.bash_profile

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

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.