本机测试搭建Mongo复制集
- 首先创建三个配置文件
# mongo1.conf
logpath=/tmp/logs.log1.txt
dbpath=/data/db
port=27017
fork=true
logappend=true
replSet=wukai/127.0.0.1:27018
# mongo2.conf
logpath=/tmp/logs/log2.txt
dbpath=/data/db2
port=27018
fork=true
logappend=true
replSet=wukai/127.0.0.1:27017
# mongo3.conf
logpath=/tmp/logs.log3.txt
dbpath=/data/db3
port=27019
fork=true
logappend=true
replSet=wukai/127.0.0.1:27017,127.0.0.1:27018
- 分别启动这三个数据库
./mongod -f mongo1.conf
./mongod -f mongo2.conf
./mongod -f mongo3.conf
- 进入一个数据库client,设置复制集
MongoDB Enterprise > config_rs1={_id:'wukai', members:[{_id:0,host:'127.0.0.1:27017', priority:10},{_id:1, host: '127.0.0.1:27018', priority:9}, {_id:2, host:'127.0.0.1:27019', priority:9}]}
{
"_id" : "wukai",
"mem