一键部署MongoDB集群Windows版
2015-07-19 16:47
771 查看
因为周末在家手头没有虚拟机,所以在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文件不一样,端口号分别加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个进程)
分片情况:
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文件不一样,端口号分别加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初探系列之三:MongoDB用户权限操作
- 学习MongoDB 七: MongoDB索引(索引基本操作)(一)
- MongoDB_3.0.4在WIN7下的安装与配置
- MongoDB C++ Driver 编译参数
- 关于NoSQL之MongoDB的一些总结
- MongoDB安装、配置、启动(MAC)
- mongodb笔记2(基本操作,增删改)
- mongodb笔记1(基本操作,增删改)
- 关于NoSQL之MongoDB的一些总结
- 一些MongoDB集群维护使用方法
- mongodb的安装(window)及java连接测试
- MongoDB集群架构及搭建
- mongoDB操作指令
- CentOS 6.5安装MongoDB
- MongoDB学习之路--命令行的命令操作
- 学习MongoDB 六: MongoDB查询(游标操作、游标信息)(三)
- Mongodb监控命令
- Mongodb分片搭建(单实例)
- 使用YCSB测试MongoDB的微分片性能
- MongoDB的存储结构及对空间使用率的影响