MongoDB Distributed Cluster

Source: Internet
Author: User
Tags install openssl mongodb openssl

Introduction: Large data volume and throughput of the database will be a single-machine performance of a large pressure, a large number of data query will be a single CPU exhausted, the large amount of data on the single-machine storage pressure, and eventually exhaust the system's memory, the pressure transferred to disk IO. -Advantages: 1. Using shards reduces the number of requests that each shard needs to process. 2. Using sharding reduces the data stored for each shard. -The composition of the MongoDB Shard cluster: Shard (shard server), config server (configuration servers), route (routing server)-Shard server: Storage Data-Configuration server: Manage Shard server- Routing server: Installing mongodb3.2 as a front-end route-------------------------------------------------------------------------------------- : Install Openssl-devel and unzip to/opt for easy management of MONGO and Mongod, make a link ' yum install Openssl-devel-ytar zxvf ' mongodb-linux-x86_64-3.2.1. Tgz-c/opt/mv mongodb-linux-x86_64-3.2.1//usr/local/mongodbln-s/usr/local/mongodb/bin/mongo/usr/bin/mongoln-s/ Usr/local/mongodb/bin/mongod/usr/bin/mongod "-Create four instances of data files and log files ' mkdir-p/data/mongodb/mongodb{1,2,3,4}mkdir/ Data/mongodb/logstouch/data/mongodb/logs/mongodb{1,2,3,4}.logchmod-r 777/data/mongodb/logs/*.log
```
-Set ulimit-u and ulimit-n values greater than 20000 "ulimit-n 25000ulimit-u 25000"
---------------------------------------------------------------------------------Configuration server ' cd/usr/local/mongodb/ bin///In the bin directory vim mongodb1.confport=37017          //Add the following content dbpath=/data/mongodb/mongodb1logpath=/data/mongodb/logs/ Mongodb1.loglogappend=truefork=truemaxconns=5000storageengine=mmapv1configsvr=true
Mongod-f/usr/local/mongodb/bin/mongodb1.conf  //Start service sysctl-w Vm.zone_reclaim_mode=0echo never >/sys/kernel/ Mm/transparent_hugepage/enabledecho never >/sys/kernel/mm/transparent_hugepage/defrag//allocating memory from other nodes when there is not enough memory on a node
------------------------------------------------------------------------------The Shard server ' #mongodb2. confcp-p mongodb1.conf Mongodb2.confvim mongodb2.conf    //mongodb2.conf configuration port=47017    //port number is 47017dbpath=/data/ MONGODB/MONGODB2  //Data file Logpath=/data/mongodb/logs/mongodb2.log  //log file logappend=truefork=truemaxconns= 5000storageengine=mmapv1shardsvr=true#mongodb3.confcp-p mongodb1.conf Mongodb3.confvim mongodb3.confport=47018   //Port is 47018dbpath=/data/mongodb/mongodb3logpath=/data/mongodb/logs/mongodb3.loglogappend=truefork= truemaxconns=5000storageengine=mmapv1shardsvr=true# Open Two services mongod-f mongodb2.confmongod-f mongodb3.conf "
---------------------------------------------------------------------------Start the routing server "./mongos--port 27017--fork --logpath=/usr/local/mongodb/bin/route.log--configdb 192.168.235.204:37017--chunksize 1   //Must be in/usr/local/ Mongodb/bin "'
---------------------------------------------------------------------------Enable Shard server ' mongomongos> show Dbsmongos> sh.status ()  //shards empty, no shard server mongos> sh.addshard ("192.168.177.133:47017")// Add a 47017-Port shard server mongos> sh.addshard ("192.168.177.133:47018")  //Add 47018-Port shard server mongos> sh.status () "
--------------------------------------------------------------------------
-Shard function add a database to create data in the collection
"' Mongos> sh.enablesharding (" school ")   #启用数据库分片
Mongos> Db.info.createIndex ({"id": 1})   #对info表创建索引
Mongos> sh.shardcollection ("School.info", {"id": 1})  #表分片
Mongos> Sh.status ()
```

MongoDB Distributed Cluster

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.