Save screenshots:
The mongo replica set is written separately:
1. Create the corresponding conf file
/etc/mongos/mongod1.conf
/etc/mongos/mongod2.conf
/etc/mongos/mongod3.conf
2. Create corresponding data files
/mongodata/data1
/mongodata/data2
/mongodata/data3
3. Start mongo as a replica set (Stop adding –shutdown)
Mongod–f /etc/mongos/mongod1.conf –replSetrs1
Mongod–f /etc/mongos/mongod2.conf –replSetrs1
Mongod–f /etc/mongos/mongod3.conf –replSetrs1
4. Log in to one (you hope it is the primary one)
mongo 192.168.1.226:27017
User admin
cOnfig={
“_id” : “rs1”,
“members” : [
“_id” : 0,
“host” : “192.168.1.226:27017”
},
“_id” : 1,
“host” : “192.168.1.226:27017”
},
“_id” : 2,
“host” : “192.168.1.226:27017”
]
}
rs.initiate(config)
rs.status()//Check the situation
Arbitration node Configuration example : “host” : “192.168.1.226:27017”, arbiterOnly: true; The arbiter node can be used as long as you Even if the machine is down, there are still two available