码迷,mamicode.com
首页 > 数据库 > 详细

mongodb高可用集群搭建

时间:2015-03-22 01:39:38      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

集群构架图如下:

技术分享

集群大致文件结构:(192.168.137.101节点)

技术分享

先搭建3个副本集

rs1/mongod.conf

技术分享

rs1/start.sh

技术分享

rs2/mongod.conf

技术分享

后面类似......

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()

开启配置节点

技术分享

技术分享

搭建路由节点

技术分享

技术分享

分片配置

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();

附上配置:http://pan.baidu.com/s/14NGGQ

 

mongodb高可用集群搭建

标签:

原文地址:http://www.cnblogs.com/riordon/p/4356608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!