MongoDB High-availability cluster setup

Source: Internet
Author: User

The cluster architecture diagram is as follows:

Cluster approximate file structure: (192.168.137.101 nodes)

Build 3 Replica Sets first

Rs1/mongod.conf

rs1/start.sh

Rs2/mongod.conf

The back resembles ...

MONGO 192.168.137.101:10001/admin

conf = {_id: "Rs1", Members:[{_id:0,host: "127.0.0.1:10001", Priority:2},{_id:1,host: "127.0.0.1:20001", priority:1},{ _id:2,host: "127.0.0.1:30001", Arbiteronly:true}]}

Rs.initiate (CONF)

Rs.status ()

To open the configuration node

Building a Routing node

Shard Configuration

conf = {addshard: "rs1/192.168.137.101:10001,192.168.137.102:10001,192.168.137.103:10001", Name: "Rs1"}

conf = {addshard: "rs2/192.168.137.101:20001,192.168.137.102:20001,192.168.137.103:20001", Name: "Rs2"}

conf = {addshard: "rs3/192.168.137.101:30001,192.168.137.103:30001,192.168.137.103:30001", Name: "Rs3"}

Db.runcommand ({listshards:true});

Db.runcommand ({enablesharding: "TestDB"}); Db.runcommand ({shardcollection: "Testdb.table1", key: {id:1}})

Use TestDB; for (var i = 1; I <= 100000; i++) Db.table1.save ({id:i, "test1": "Testval1"}); Db.table1.stats ();

Attached configuration: Http://pan.baidu.com/s/14NGGQ

MongoDB High-availability cluster setup

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.