MongoDB分片(集群)

  

基本环境:

由于资源紧张,只有3台虚拟机的关系,只做两个replicaSet,每台机器配置分别如下:

10.10.1.55这台机器安装Primary1, configServer1, Arbiter1

10.10.1.56安装Primary2, configServer2, Arbiter2

10.10.1.57安装Secondary1, Secondary2, configServer3,蒙戈


<强> Primary1配置文的件:

dbpath=/数据/mongodb/rs0_0   logpath=/数据/mongodb/日志/rs0_0.log   logappend=true   端口=40000   bind_ip=192.168.11.55 10.10.1.55   oplogSize=10000   叉=true   journal =,真的   # noprealloc =,真的   replSet=rs0   directoryperdb=true

<强> Arbiter1的配置文件:

dbpath=/数据/mongodb/rs0_arbiter   logpath=/数据/mongodb/日志/rs0_arbiter.log   logappend=true   端口=40002   bind_ip=192.168.11.55 10.10.1.55   oplogSize=10000   叉=true   journal =,真的   # noprealloc =,真的   replSet=rs0   directoryperdb=true

<强> ConfigServer1的配置文件:

dbpath=/数据/mongodb/rs0_conf   logpath=/数据/mongodb/日志/rs0_conf.log   logappend=true   端口=40006   bind_ip=192.168.11.55 10.10.1.55   叉=true   journal =,真的   # noprealloc =,真的   configsvr=true   directoryperdb=true

分别通过mongod——config 文件名来启动不同的mongo进程,成功启动后可以通过netstat查看在1.55机器上分别分配了Primary1端口:40000年,Arbiter1端口:40002年,configureServer1端口:40006

<强> Primary2的配置文件:

dbpath=/数据/mongodb/rs1_primary   logpath=/数据/mongodb/日志/rs1_p.log   logappend=true   bind_ip=192.168.11.56 10.10.1.56   directoryperdb=true ,   端口=40003   oplogSize=10000   叉=true   journal =,真的   noprealloc =,真的   replSet=rs1

<强> Arbiter2配置文件:

dbpath=/数据/mongodb/rs1_arbiter   logpath=/数据/mongodb/日志/rs1_a.log   logappend=true   bind_ip=192.168.11.56 10.10.1.56   directoryperdb=true ,   端口=40005   oplogSize=10000   叉=true   journal =,真的   noprealloc =,真的   replSet=rs1

<强> ConfigureServer2配置文件:

dbpath=/数据/mongodb/rs1_conf   logpath=/数据/mongodb/日志/rs1_conf.log   logappend=true   bind_ip=192.168.11.56 10.10.1.56   directoryperdb=true ,   端口=40007   oplogSize=10000   叉=true   journal =,真的   noprealloc =,真的   configsvr=true

分别通过mongod——config 文件名来启动不同的mongo进程,成功启动后可以通过netstat查看在1.55   机器上分别分配了Primary2端口:40003年,Arbiter2端口:40005年,configureServer2端口:40007



<强> rs0_Secondary1配置:

dbpath=/数据/mongodb/rs0_Secondary1   logpath=/数据/mongodb/日志/rs0_secondary1.log   logappend=true   端口=40001   bind_ip=192.168.11.57 10.10.1.57   oplogSize=10000   叉=true   journal =,真的   # noprealloc =,真的   replSet=rs0   directoryperdb=true

<强> rs1_Secondary1配置:

dbpath=/数据/mongodb/rs1_Secondary1   logpath=/数据/mongodb/日志/rs1_secondary1.log   logappend=true   bind_ip=192.168.11.57 10.10.1.57   directoryperdb=true ,   端口=40004   oplogSize=10000   叉=true   journal =,真的   noprealloc =,真的   replSet=rs1

<强> configureServer3配置:

dbpath=/数据/mongodb/confSvr3   logpath=/数据/mongodb/日志/conf3.log   logappend=true   bind_ip=192.168.11.57 10.10.1.57   directoryperdb=true ,   端口=40008   oplogSize=10000   叉=true   journal =,真的   configsvr=true

<强>蒙戈配置:(启动蒙戈路由器要注意多台服务器时间必须要同步,否则出现错误)

logpath=/数据/mongodb/日志/mongos.log   port =40009   configdb=10.10.1.55:40006 10.10.1.56:40007 10.10.1.57:40008   时间=fork 真正的

分别通过mongod——config 文件名来启动不同的mongo进程,成功启动后可以通过netstat查看在1.55   机器上分别分配了rs0_secondary1端口:40001年,rs1_secondary1端口:40004年,configureServer3端口:40008年,蒙戈路由端口:40009

MongoDB分片(集群)