由于周末在家手头没有虚拟机,所以在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

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

db目录

执行程序(15+3个进程)

分片情况:

最新文章

  1. iOS---数据本地化
  2. 网页闯关游戏(riddle webgame)--SQL注入的潘多拉魔盒
  3. nodejs 操作mysql
  4. Jquery实现让滚动条始终保持在最下方
  5. linux经常使用(一)linux 安装配置 jdk之 找不到安装文件文件夹及source /etc/profile 报unexpected end of file 错误 解决
  6. c#关于委托和事件
  7. WinForm 布局,容器、打印和对话框控件
  8. WinForm响应式布局设计实践
  9. javascript学习笔记 --event事件
  10. 总结C语言字符检测函数:isalnum、isalpha...
  11. iTerm2 + oh my zsh +agnoster 打造最强Mac终端
  12. 记一次KUBERNETES/DOCKER网络排障
  13. flask框架----flask中的wtforms使用
  14. 【AtCoder】ARC088
  15. Libevent例子(二)
  16. python性能对比
  17. 如何把he_llo wo_rld 变成 HeLlo WoRld
  18. C# 代码操作XML(增、删、改)
  19. LaTeX 中插入图片使其紧跟插入的文字之后
  20. sqlserver sql语句查看分区记录数、查看记录所在分区

热门文章

  1. shell 获取不同目录下指定文件,并把文件复制到一个文件夹下面
  2. 深入浅出 妙用Javascript中apply、call、bind【转】
  3. unity, 最简单的additive shader
  4. 怎么把本地的文件放到esxi主机上
  5. Android Studio 2.2 Record Espresso Test
  6. HDU 4968 Improving the GPA(dp)
  7. [na]pc加入域认证细节
  8. UrlOper
  9. navicat编辑记录 (zhuan)
  10. java.io.PrintWriter 中 write() 与 print() 的区别