MongoDB Installation and Configuration

Source: Internet
Author: User

1. Download and install

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz

Tar zxf mongodb-linux-x86_64-3.0.6.tgz

MV Mongodb-linux-x86_64-3.0.6/usr/local/mongodb

2. Create a data directory that must be created or fail to start.

Mkdir-p/data/db

Start:

/usr/local/mongodb/bin/mongod--dbpath=/usr/local/server/mongodb/data--logpath=/usr/local/server/mongodb/logs-- Logappend--port=27017--fork

3. Parameter interpretation

--dbpath database path (data file)--logpath log file path--master specified as the primary machine--slave specified as the IP address of the master machine--source the--logappend log file at the end of the add--port Enable port number--fork run in the background--only specify which database to replicate--slavedelay the interval from replication detection--auth whether authentication rights are required to log on (user name and password) 4. CLI management interface into the database

/usr/local/mongodb/bin/mongo
MongoDB Shell version:3.0.6
Connecting To:test
>2+2

4

If the database appears as unable to connect, then is a data directory under the Mongod.lock file problem, you can use the following repair command, Mongod--repair view logstail-f logs

2017-06-11t00:12:09.875+0800 I NETWORK [Initandlisten] connection accepted from 127.0.0.1:54624 #13 (1 connection now OPEN )
2017-06-11t00:12:09.880+0800 I ACCESS [conn13] unauthorized not authorized on Admin to execute command {getLog: "STARTUPW Arnings "}


2017-06-11t00:12:28.804+0800 I NETWORK [Initandlisten] connection accepted from 10.10.2.13:63225 #14 (2 connections now OP En
2017-06-11t00:12:28.805+0800 I NETWORK [Initandlisten] connection accepted from 10.10.2.13:63227 #15 (3 connections now OP En
2017-06-11t00:12:28.805+0800 I NETWORK [Initandlisten] connection accepted from 10.10.2.13:63226 #16 (4 connections now OP En
2017-06-11t00:12:28.808+0800 I NETWORK [conn14] End Connection 10.10.2.13:63225 (3 connections now OPEN)
2017-06-11t00:12:28.831+0800 I NETWORK [conn15] End Connection 10.10.2.13:63227 (2 connections now OPEN)
2017-06-11t00:12:29.717+0800 I NETWORK [Conn16] End Connection 10.10.2.13:63226 (1 connection now OPEN)

(1 connection now OPEN) #表明一个来自本机的连接

5. Create a database

> Use AAA #创建
Switched to DB AAA

> DB #查看
Aaa

6.MongoDB Backup (Mongodump) and recovery (Mongorestore)

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.