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: