调整原因:
1.原有分片是两个SECONDARY,查询时开发人员也很少设置成
const string RP_SECONDARY = "secondary" ;
const string RP_SECONDARY_PREFERRED = "secondaryPreferred" ;
此类读优化
2.出现误操作,把一个表的部分数据删除了。
3.正好手头上多了一台用来备份的服务器,但测试使用文件备份mongodump
的方法,发现备份时性能不理想。
数量量大,半天也还没全部备份完成,跑shell,出现错误:
Failed: error running `listIndexes`. Collection: `dp.tb_bid` Err: read tcp 127.0.0.1:28011: i/o timeout
这个错误好几台服务器都同出现。
计划达到目的:
1.增加备份节点,以保证数据安全(误操作:比如删除数据,修改数据)
2.两个次节点的,减少集群同步消耗,优化插入性能,同时 slaveDelay 节点不建立索引。
3.slaveDelay 节点设置成前台不可见(不可查询数据)
具体性能,还得后面跟进,看看效果。
原架构
set host:port stateStr
----------------------------------------------------------
shard1 192.168.0.11:27011 PRIMARY
shard1 192.168.0.13:27011 SECONDARY
shard1 192.168.0.17:27011 SECONDARY
shard2 192.168.0.11:27012 SECONDARY
shard2 192.168.0.15:27012 PRIMARY
shard2 192.168.0.19:27012 SECONDARY
shard3 192.168.0.13:27013 PRIMARY
shard3 192.168.0.15:27013 SECONDARY
shard3 192.168.0.19:27013 ARBITER
shard4 192.168.0.15:27011 ARBITER
shard4 192.168.0.17:27012 PRIMARY
shard4 192.168.0.19:27011 SECONDARY
调整后:
set host:port stateStr
-------------------------------------------------------------
shard1 192.168.0.11:27011 PRIMARY
shard1 192.168.0.13:27011 slaveDelay
shard1 192.168.0.17:27011 SECONDARY
shard2 192.168.0.11:27012 slaveDelay
shard2 192.168.0.15:27012 PRIMARY
shard2 192.168.0.19:27012 SECONDARY
shard3 192.168.0.13:27013 PRIMARY
shard3 192.168.0.15:27013 SECONDARY
shard3 192.168.0.21:27011 slaveDelay
shard4 192.168.0.21:27012 slaveDelay
shard4 192.168.0.17:27012 PRIMARY
shard4 192.168.0.19:27011 SECONDARY
删除 ARBITER 节点,另外增加slaveDelay 节点:
[mongo@ms3 bin]$ ./mongo -port 27011
rs.remove("192.168.0.19:27013");
rs.add({_id: 2, host:'192.168.0.21:27012',"slaveDelay":36000,"priority":0,"hidden":true,"buildIndexes":true});