以3个节点为例子
1. 分别配置三个配置文件,文件目录,日志目录
systemLog:
verbosity: 1
destination: file
path: "/root/software/mongod_replication/replication2/logs/mongod.log"
logAppend: true
storage:
dbPath: "/root/software/mongod_replication/replication2/db"
journal:
enabled: true
processManagement:
fork: true
net:
bindIp: 0.0.0.0
port: 29017
replication:
replSetName: rs0
#setParameter:
# enableLocalhostAuthBypass: false
分别启动三个mongod进程
mongod -f mongod.conf
2. 配置复制级
mongo 192.168.6.180:27017 // 链接到其中一个复制集中
rs.initiate()
rs.add("192.168.6.180:29017") // 分别将另外两个节点加入到复制集中
rs.add("192.168.6.180:28017")