1.https://www.cnblogs.com/out-of-memory/p/6810525.html
(1)配置文件
master:
dbpath=/data/mongodb/master/data
logpath=/data/mongodb/master/log/mongodb.log
pidfilepath=/data/mongodb/master/pid/mongodb.pid
port=27017
logappend=true
fork=true
journal=true
oplogSize=2048
smallfiles=true
replSet=OctopusDBset
clusterAuthMode=keyFile
keyFile=/data/mongodb/master/rs/keyfile
slave:
dbpath=/data/mongodb/slave/data
logpath=/data/mongodb/slave/log/mongodb.log
pidfilepath=/data/mongodb/slave/pid/mongodb.pid
port=27017
logappend=true
fork=true
journal=true
oplogSize=2048
smallfiles=true
replSet=OctopusDBset
clusterAuthMode=keyFile
keyFile=/data/mongodb/slave/rs/keyfile
artiber:
dbpath=/data/mongodb/arbiter/data
logpath=/data/mongodb/arbiter/log/mongodb.log
pidfilepath=/data/mongodb/arbiter/pid/mongodb.pid
port=37017
logappend=true
fork=true
journal=true
oplogSize=2048
smallfiles=true
replSet=OctopusDBset
clusterAuthMode=keyFile
keyFile=/data/mongodb/arbiter/rs/keyfile
(2):启动命令
-========================master and arbiter=================================================
/opt/srv/mongodb-linux-x86_64-2.6.6/bin/mongod --fork --config /etc/mongo/master.config --auth
/opt/srv/mongodb-linux-x86_64-2.6.6/bin/mongod --fork --config /etc/mongo/arbiter.config --auth
-============================slave=========================================================
/opt/mongodb-linux-x86_64-2.6.6/bin/mongod --fork --config /etc/mongo/slave.config --auth
2.用户认证:
openssl rand -base64 741 > keyfile
chmod 600 keyfile
https://jingyan.baidu.com/album/e4d08ffdb207080fd3f60d40.html?picindex=1
3.副本集的配置过程
cfg={_id:"OctopusDBset", members:[{_id:0, host:'10.140.2.70:27017', priority:50},{_id:1, host:'10.140.2.49:27017', priority:30}, {_id:2,host:'10.140.2.70:37017', arbiterOnly:true}]};
rs.initiate(cfg)
-====================
4.副本集中的主要命令:
(1).为副本集添加新成员:
rs.add("192.168.1.2:27017");
(2).删除副本集中的成员
rs.remove("192.168.1.2:27017"); 删除成员时,所有已经建立的连接都将断掉,暂时没有主节点(179)
(3).查看配置是否修改成功
re.config()
(4).重新配置某一个副本集
re.reconfig(c)