mongo添加replicaset的slave或arbiter

往mongo里添加replica set的slave需要两步:
首先在新结点里定义
vim /etc/mongodb.conf
dbpath=/var/lib/mongodb                   
#where to log                                                                   
logpath=/var/log/mongodb/mongodb.log
pidfilepath=jiepang_production.pid
logappend=true
replSet = MONGO_REPLI_NAME                                                                 
rest=true                                                                          
oplogSize=8192
fork=true

重启新节点的mongodb

其次到replica set的master上
newnode = {_id: 1, host: "mongodb3.example.net:27017", priority: 0, hidden: true}
rs.add(newnode)

一个replicaset中voting节点不能超过7个,否则新节点需要设置votes := 0
其中hidden会影响节点的read preference, 新节点只会接受直接的读请求
priority取值0~1000,数值越大越容易变成master

添加arbiter则更简单,priority不需指定,默认就是0
rs.addArb("m1.example.net:30000")


mongo需要关闭numa
#!/bin/sh
echo 0 > /proc/sys/vm/zone_reclaim_mode
numactl --interleave=all /home/jiepang/services/mongo/bin/mongod -f /home/jiepang/services/mongo/jiepang_production_slave.conf

猜你喜欢

转载自luozhaoyu.iteye.com/blog/1705965