一键部署MongoDB集群Windows版
时间:2021-07-01 10:21:17
帮助过:155人阅读
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