数据分片节点
#192.168.114.26
#mongo.cnf
port=2001
dbpath=/data/mongodb/data
logpath=/data/mongodb/log/mongodb.log
fork=true
shardsvr=true
directoryperdb=true
journal=true
mongod --shardsvr --port 2001 --dbpath=/data/mongodb/data --logpath=/data/mongodb/log/mongodb.log --fork
#192.168.114.27
mongod --shardsvr --port 2002 --dbpath=/data/mongodb/data --logpath=/data/mongodb/log/mongodb.log --fork
配置服务器
#192.168.114.28
#mongo.cnf
port=3001
dbpath=/data/mongodb/cfg1
logpath=/data/mongodb/log/mongodb.log
fork=true
configsvr=true
directoryperdb=true
mongod --configsvr --port 3001 --dbpath=/data/mongodb/cfg1 --logpath=/data/mongodb/log/mongodb.log --fork
mongod --configsvr --port 3002 --dbpath=/data/mongodb/cfg2 --logpath=/data/mongodb/log/mongodb.log --fork
mongod --configsvr --port 3003 --dbpath=/data/mongodb/cfg3 --logpath=/data/mongodb/log/mongodb.log --fork
查询路由mongos服务器
#192.168.114.25
port=5000
logpath=/data/mongodb/log/mongodb.log
pidfilepath=/data/mongodb/log/mongos.pid
fork=true
logappend=true
configdb=192.168.114.28:3001,192.168.114.28:3002,192.168.114.28:3003
mongos --port 5000 --configdb 192.168.114.28:3001,192.168.114.28:3002,192.168.114.28:3003 --logpath=/data/mongodb/log/mongodb.log --fork
连接mongos,为集群添加数据分片节点
mongo --port 5000 admin
sh.addShard("192.168.114.26:2001")
sh.addShard("192.168.114.27:2002")