- 操作系统
windows10 - mongodb版本
3.4.X - mongo安装路径
D:\mongo 建立服务器本地路径
D:\mongo\shard11\data
D:\mongo\shard12\data
D:\mongo\shard13\data
D:\mongo\shard11\log\shard11.log
D:\mongo\shard12\log\shard12.log
D:\mongo\shard13\log\shard13.log
D:\mongo\shard11\shard11.conf
D:\mongo\shard12\shard12.conf
D:\mongo\shard13\shard13.confD:\mongo\shard21\data
D:\mongo\shard22\data
D:\mongo\shard23\data
D:\mongo\shard21\log\shard21.log
D:\mongo\shard22\log\shard22.log
D:\mongo\shard23\log\shard23.log
D:\mongo\shard21\shard21.conf
D:\mongo\shard22\shard22conf
D:\mongo\shard23\shard23confD:\mongo\config\data
D:\mongo\config\log\config.log
D:\mongo\config\config.confD:\mongo\route\data
D:\mongo\route\log\route.log
D:\mongo\route\route.conf服务器配置文件示例(组成副本集)
配置文件名称 副本集名称(replica set) bind_ip 端口 服务器预设类型 可配置数量 shard11.conf rs1 0.0.0.0 10001 主服务器 1 shard12.conf rs1 0.0.0.0 10002 从服务器 1+ shard13.conf rs1 0.0.0.0 10003 仲裁服务器 1 shard21.conf rs2 0.0.0.0 20001 主服务器 1 shard22.conf rs2 0.0.0.0 20002 从服务器 1+ shard23.conf rs2 0.0.0.0 20003 仲裁服务器 1 config.conf conf 0.0.0.0 30000 配置服务器 1+ route.conf 不建立副本集 0.0.0.0 40000 路由服务器 1+ 分片服务器配置示例:
dbpath = D:\mongo\shard11\data
port = 10011
auth = false
bind_ip = 0.0.0.0
directoryperdb = true
logpath = D:\mongo\shard11\log\shard11.log
shardsvr=true
replSet=set1
oplogSize=2048
配置服务器配置示例:
dbpath = D:\mongo\config\data
port = 30000
auth = false
bind_ip=0.0.0.0
directoryperdb = true
logpath = D:\mongo\config\log\config.log
configsvr=true
oplogSize=2048
replSet=conf
路由服务器示例:
port = 40000
logpath = D:\mongo\route\log\route.log
configdb=conf/127.0.0.1:30000
注:configdb属性务必于配置服务器对应 配置服务器副本集名称(replSet)/ip地址:端口
这里区别于生产配置,生产配置的时候,是不允许出现本地ip地址,即:127.0.0.1和localhost
注意以下问题:
auth=false
oplogsize表示日志文件的大小,根据需要做限制
mongodb在3.2版本及以上要求必须建立副本集