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

一键部署MongoDB集群Windows版

时间:2017-04-21 17:24:05      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:font   term   art   journal   集群   storage   bpa   add   slave   

由于周末在家手头没有虚拟机,所以在windows下单机完毕部署要求,并编写bat执行脚本。
1、创建配置文件及相关文件夹
总的启动脚本例如以下(startmc.bat):
rem m1
start mongod.exe --config=../config/m1/s1_1
start mongod.exe --config=../config/m1/s1_2
start mongod.exe --config=../config/m1/c1_1
start mongod.exe --config=../config/m1/a1_1
start mongod.exe --config=../config/m1/a1_2

rem m2
start mongod.exe --config=../config/m2/s2_1
start mongod.exe --config=../config/m2/s2_2
start mongod.exe --config=../config/m2/c2_1
start mongod.exe --config=../config/m2/a2_1
start mongod.exe --config=../config/m2/a2_2

rem m3
start mongod.exe --config=../config/m3/s3_1
start mongod.exe --config=../config/m3/s3_2
start mongod.exe --config=../config/m3/c3_1
start mongod.exe --config=../config/m3/a3_1
start mongod.exe --config=../config/m3/a3_2


start mongos.exe --config=../config/m1/s1
start mongos.exe --config=../config/m2/s2
start mongos.exe --config=../config/m3/s3
2、配置文件
配置文件分别分为几个集群目录,分别为m1、m2、m3
每一个目录下分别包括了两个分片(s*_1,s*_2)、一个config(c*_1)、一个mongos(s*)、两个仲裁节点(a*_1,a*_2)(以m1为例,其它两个目录相应log及db文件不一样,port号分别加1000):
a1_1(注意Windows下没有fork。所以在bat中使用start建立不同进程):
dbpath=../data/db/a1_1
logpath=../data/a1_1.log
port=8451
shardsvr=true
replSet=shard1
logappend=true
oplogSize=2048
storageEngine=wiredTiger
nojournal=true
a1_2:
dbpath=../data/db/a1_2
logpath=../data/a1_2.log
port=8452
shardsvr=true
replSet=shard2
logappend=true
oplogSize=2048
storageEngine=wiredTiger
nojournal=true
c1_1:
dbpath=../data/db/c1_1
logpath=../data/c1_1.log
port=8441
configsvr=true
logappend=true
oplogSize=2048
storageEngine=wiredTiger
nojournal=true
s1:
logpath=../data/s1.log
port=8440
chunkSize=100
logappend=true
configdb=localhost:8441,localhost:8541,localhost:8641
s1_1:
dbpath=../data/db/s1_1
logpath=../data/s1_1.log
port=8442
shardsvr=true
replSet=shard1
logappend=true
oplogSize=2048
storageEngine=wiredTiger
nojournal=true
s1_2:
dbpath=../data/db/s1_2
logpath=../data/s1_2.log
port=8443
shardsvr=true
replSet=shard2
logappend=true
oplogSize=2048
storageEngine=wiredTiger
nojournal=true


3、进行分片对应设置
use admin
config = {_id: ‘shard1‘, members:[{_id:0, host: ‘localhost:8442‘},{_id:1, host:‘localhost:8542‘},{_id:2, host:‘localhost:8642‘,slaveDelay:7200,priority:0},{_id:3, host:‘localhost:8451‘,arbiterOnly:true},{_id:4, host:‘localhost:8551‘,arbiterOnly:true},{_id:5, host:‘localhost:8651‘,arbiterOnly:true}]};
rs.initiate(config);
config = {_id: ‘shard2‘, members:[{_id:0, host: ‘localhost:8443‘},{_id:1, host:‘localhost:8543‘},{_id:2, host:‘localhost:8643‘,slaveDelay:7200,priority:0},{_id:3, host:‘localhost:8452‘,arbiterOnly:true},{_id:4, host:‘localhost:8552‘,arbiterOnly:true},{_id:5, host:‘localhost:8652‘,arbiterOnly:true}]};
rs.initiate(config);

use admin
db.runCommand( { addshard:"shard1/localhost:8442,localhost:8542",name:"s1"} );
db.runCommand( { addshard:"shard2/localhost:8443,localhost:8543",name:"s2"} );
db.runCommand( { listshards : 1 } )
3、文件夹结构及执行情况
配置文件文件夹(m1为例):
技术分享
技术分享
文件记录log
技术分享
技术分享
db目录
技术分享
技术分享
执行程序(15+3个进程)
技术分享技术分享
技术分享技术分享
分片情况:
技术分享

一键部署MongoDB集群Windows版

标签:font   term   art   journal   集群   storage   bpa   add   slave   

原文地址:http://www.cnblogs.com/tlnshuju/p/6744580.html

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