Steps for building a MongoDB Cluster

Source: Internet
Author: User
Tags install mongodb

Steps for building a MongoDB Cluster

I have built a mongodb cluster many times, and there will be more or less problems each time. I will write this article for future reference. This is to build a cluster based on mongodb3.0. The steps are as follows:

1. Set the Operating System Environment
Echo "never"> "/sys/kernel/mm/transparent_hugepage/enabled"
Echo "never"> "/sys/kernel/mm/transparent_hugepage/defrag"
Ulimit-n 64000

2. modify the configuration file [mongod. conf]
Shards configuration: port = 27018, directoryperdb = true, bind_ip = 0.0.0.0
Config configuration: port = 27019, bind_ip = 0.0.0.0
Monogs configuration: mongos -- configdb 192.168.12.150: 27019 -- logpath/var/log/mongodb/mongos. log -- pidfilepath/var/run/mongodb/mongos. pid -- logappend -- logRotate reopen -- fo
Hosts configuration: {shardone. mongodb. local, shardtwo. mongodb. local, shardthree. mongodb. local} adds domain name resolution for the IP address corresponding to each slice Server

3. Add parts
> Mongo admin
> Db. runCommand ({addshard: "shardone. mongodb. local: 27018", name: "shardone"}) -- add parts
> Db. runCommand ({addshard: "shardtwo. mongodb. local: 27018", name: "shardtwo "})
> Db. runCommand ({addshard: "shardthree. mongodb. local: 27018", name: "shardthree "})

Partition servers should resolve domain names as much as possible to avoid future Server IP address changes

4. Start sharding and add a partition key to the database.
> Db. runCommand ({"enablesharding": "mc_visit "})
> Db. runCommand ({"shardcollection": "mc_visit.mc_visit", "key": {"visitdate":-1, "virus": 1 }})

5. Modify the partition key if no data exists
> Use config
> Db. collections. find () -- view all the partition keys
> Db. chunks. find () -- view existing parts

MongoDB 3.0 official version released and downloaded

CentOS compilation and installation of MongoDB

CentOS compilation and installation of php extensions for MongoDB and mongoDB

CentOS 6 install MongoDB and server configuration using yum

Install MongoDB2.4.3 in Ubuntu 13.04

MongoDB beginners must read (both concepts and practices)

MongoDB Installation Guide for Ubunu 14.04

MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

Nagios monitoring MongoDB sharded cluster service practice

Build MongoDB Service Based on CentOS 6.5 Operating System

MongoDB details: click here
MongoDB: click here

This article permanently updates the link address:

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.