MONGO Installation Deployment

Source: Internet
Author: User
Tags mongodb mongodb download create database

MongoDB Download Address: https://www.mongodb.org/downloads Linux Installation deployment:

1. Download: #wgethttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.1.tgz

2, Decompression: #tar –zxvfmongodb-linux-x86_64-3.2.1.tgz

#mv Mongodb-linux-x86_64-3.2.1/usr/local/mongodb

3. Add PATH: #exportPATH =/usr/local/mongodb/bin: $PATH

4. Create database directory: #mkdir –p/data/db

5. Start MongoDB Service:

#mongod If the database directory is not/data/db, you can specify it by-dbpath

You can also create a startmongo.sh script that starts with a background process, with the following script contents

Cd/usr/local/mongodb/bin

./mongod &

6. Using the command to connect MongoDB: #cd/usr/local/mongodb/bin

#./mongo

7, Web user interface: MongoDB provides a simple HTTP user interface, if you want to enable, you need to increase the-rest parameter at startup

#./mongod–dbpath=/data/db–rest WinDOS Deployment installation: Slightly MONGO cluster configuration

1, Replica set cluster (replica cluster), the advantage of this kind of cluster is high availability, prevent single point of failure.

The prerequisite is that you have downloaded MONGO and completed setting the environment variable

Create a mongo_18000.conf file

Port = 18000

DBPath =/data/mongodb/18000

LogPath =/data/mongodb/18000.log

Logappend = True

Directoryperdb = True

Journal = True

Fork = True

Replset = myrs

Oplogsize = 1024

Create a mongo_18001.conf file

Port = 18001

DBPath =/data/mongodb/18001

LogPath =/data/mongodb/18001.log

Logappend = True

Directoryperdb = True

Journal = True

Fork = True

Replset = myrs

Oplogsize = 1024

Parameter description:

DBPath: Storing Data Directory

LogPath: Log Data Directory

Pidfilepath:pid file

KeyFile: Used to validate files between nodes, content must be consistent, permissions 600

DIRECTORYPERDB: Whether the database is stored in a directory

Logappend: Log Append method storage

Replset:replica Set's name

BIND_ID:MONGODB Bound IP Address

Port: Ports

Auth: Whether to turn on authentication

Oplogsize: Setting the size of the Oplog (MB)

Fork: Daemon Run, create process

Moprealloc: Whether data file pre-allocation is disabled

Maxconns: Maximum number of connections, default 2000

Create a startup file startmongors.sh

Mongod-f/usr/local/mongodb/mongo_18000.conf &

Mongod-f/usr/local/mongodb/mongo_18001.conf &

Start mongodb:#./startmongors.sh

Configured on the primary node: #mongo 127.0.0.1 18000

>use Admin

> cfg={_id: "myrs", Members:[{_id:0,host: ' 127.0.0.1:18000 ', priority:1},{_id:1,host: ' 127.0.0.1:18001 ', priority : 2}]}

> rs.initiate (CFG)

>rs.status ()

2. master-Slave mode cluster

3. Shard Mode Cluster

4. Shard + Replica Cluster

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.