MongoDB分片部署(windows)
在Windows环境下手动部署MongoDB分片集群,你需要准备三个配置文件:mongos、config server、shard server。
- 配置文件:
mongos.conf
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongos.log
net:
port: 27017
bindIp: 0.0.0.0
processManagement:
fork: true
sharding:
configDB: localhost:27019,localhost:27020,localhost:27021
- 配置文件:
configsvr.conf
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/configsvr.log
net:
port: 27019
bindIp: 0.0.0.0
processManagement:
fork: true
storage:
dbPath: /var/lib/mongodb-config
journal:
enabled: true
security:
authorization: enabled
- 配置文件:
shard1.conf
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/shard1.log
net:
port: 27020
bindIp: 0.0.0.0
processManagement:
fork: true
storage:
dbPath: /var/lib/mongodb-shard1
journal:
enabled: true
sharding:
clusterRole: shardsvr
security:
authorization: enabled
然后,你需要在Windows上启动MongoDB实例。对于每个配置文件,你可以使用以下命令:
mongod --config /path/to/your/configfile.conf
启动Config Server:
mongod --config /path/to/your/configsvr.conf
启动Shard Server(例如两个):
mongod --config /path/to/your/shard1.conf
mongod --config /path/to/your/shard2.conf
最后,启动MongoS:
mongos --configdb localhost:27019,localhost:27020,localhost:27021 --port 27017
这样,你就在Windows上部署了一个简单的MongoDB分片集群。记得根据你的实际路径和配置调整命令和配置文件路径。
评论已关闭