一鍵部署MongoDB叢集Windows版,mongodb叢集

來源:互聯網
上載者:User

一鍵部署MongoDB叢集Windows版,mongodb叢集
因為周末在家手頭沒有虛擬機器,所以在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/s32、設定檔設定檔分別分為幾個叢集檔案夾,分別為m1、m2、m3每個檔案夾下分別包含了兩個分區(s*_1,s*_2)、一個config(c*_1)、一個mongos(s*)、兩個仲裁節點(a*_1,a*_2)(以m1為例,其他兩個檔案夾對應log及db檔案不一樣,連接埠號碼分別加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=truec1_1:
dbpath=../data/db/c1_1
logpath=../data/c1_1.log
port=8441
configsvr=true
logappend=true
oplogSize=2048
storageEngine=wiredTiger
nojournal=trues1: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 adminconfig = {_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 admindb.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個進程)
分區情況:

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

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.