用的配置和命令

dbpath = D:\mongodb\data\shard12\data
port = 10002
auth = false
bind_ip = 0.0.0.0
directoryperdb = true
logpath = D:\mongodb\data\shard12\log\shard12.log
shardsvr = true
replSet=set1
oplogSize= 24
mongod --config D:\mongodb\data\shard11\shard11.conf --serviceName "shard11" --serviceDisplayName "shard11" –install
mongod --config D:\mongodb\data\shard12\shard12.conf --serviceName "shard12" --serviceDisplayName "shard12" –install
mongod --config D:\mongodb\data\shard13\shard13.conf --serviceName "shard13" --serviceDisplayName "shard13" –install
net start shard11
net start shard12
net start shard13
初始化副本集
mongo --port 10001
config={_id:'rs1',members:[{_id:0,host:'127.0.0.1:10001'},{_id:1,host:'127.0.0.1:10002'},{_id:2,host:'127.0.0.1:10003',arbiterOnly:false}]}
rs.initiate(config)

​​配置windows服务链接​​

配置步骤

windows下配置mongodb副本集_mongodb