MongoDB Cluster Setup Steps

Source: Internet
Author: User

Set up a MongoDB cluster many times, each time will be or more, or less some of the hell of the problem, write this blog for later reference.

This is based on the mongodb3.0 to build the cluster, the construction steps are as follows:

1. Setting the operating system environment

echo "Never" > "/sys/kernel/mm/transparent_hugepage/enabled" echo "Never" > "/sys/kernel/mm/transparent_ Hugepage/defrag "Ulimit-n 64000

2. Modification of configuration Files [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} Add the domain name resolution for the IP address that corresponds to each shard server

3. Adding shards

>>mongo Admin>>db.runcommand ({addshard: "shardone.mongodb.local:27018", Name: "Shardone"})--Add Shard >&G T;db.runcommand ({addshard: "shardtwo.mongodb.local:27018", Name: "Shardtwo"}) >>db.runcommand ({addshard: " shardthree.mongodb.local:27018 ", Name:" Shardthree "})

As far as possible, the Shard server avoids the change of IP address of the server in the way of domain name resolution

4. Start the Shard and add the slice key to the database

>>db.runcommand ({"enablesharding": "Mc_visit"}) >>db.runcommand ({"Shardcollection": "Mc_visit.mc_ Visit "," key ": {" Visitdate ":-1," Virus ": 1}})

5, no data in the case of modified tablet key

>>use Config>>db.collections.find ()--View all tab keys >>db.chunks.find ()--view blocks of existing shards


MongoDB Cluster Setup Steps

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.