Mongo高可用集群搭建

路由(mongos):1个
分片副本集(mongod):3个
配置集:3个

配置集配置文件

dbpath=/home/mongo/config/data/
logpath=/home/mongo/config/log/config.log
logappend=true
port=21000
fork=true
configsvr=true

路由配置文件

logpath=/home/mongo/mongos/log/mongos.log
logappend=true
port=20000
fork=true
configdb=192.168.46.251:21000,192.168.46.142:21000,192.168.46.220:21000

副本集配置文件

dbpath=/home/mongo/shard1/data
logpath=/home/mongo/shard1/log/shard1.log
logappend=true
port=22001
fork=true
replSet=shard1ReplSet
shardsvr=true

登陆任一台配置集mongo,初始化配置集

rs.initiate({_id:"cfgReplSet",configsvr:true,members:[{_id:0,host:"192.168.46.251:21000"},{_id:1,host:"192.168.46.142:21000"},{_id:2,host:"192.168.46.220:21000"}]})

登陆任一台副本集mongo,初始化副本集

use admin
rs.initiate({_id:"shard1ReplSet",members:[{_id:0,host:"192.168.46.251:22001"},{_id:1,host:"192.168.46.142:22001",arbiterOnly:true},{_id:2,host:"192.168.46.220:22001"}]})

登陆mongo路由,加入副本集

use admin
db.runCommand({addshard : "shard1ReplSet/192.168.46.251:22001,192.168.46.142:22001,192.168.46.220:22001"});

问题:

  1. 启用分片跟不启用分片的库有什么区别?
  2. 分片与单机在存储结果上有什么区别?

你可能感兴趣的:(Mongo高可用集群搭建)