I am very happy to come to Sifei website for the first time. Today, I encountered a small problem when I was learning mongodb to configure the master-slave server, that is, when I set the ip and port of the master-slave server, logging in to the master server 192.168.1.102 primary, 27017 and the slave server 192.168.1.102 primary, 27018 packet ID shows that the slave server can be written arbitrarily. It is not that you just logged in to the server and did not switch to the identity of the slave server.
because the master server can not achieve the effect of master and slave, I hope the boss will give us some advice! Thank you very much
the steps to set up the master / slave server are as follows:
Environment: mac version / / MongoDB version: "3.4.2
- create database directories db1, db2
create two directory paths / Users/gavin/Desktop, for suspending two mongodb servers
mkdir db1
mkdir db2
2. Suspend two servers
mongod-- bind_ip 192.168.1.102-- port 27017-- dbpath / Users/gavin/Desktop/db1-- replSet rs0
mongod-- bind_ip 192.168.1.102-- port 27018-- dbpath / Users/gavin/Desktop/db2-- replSet rs0
3. Connect to the primary server. Here, set 192.168.1.102purl 27017 as the primary server
mongo-- host 192.168.1.102-- port 27017
rs.initiate ()
4. Add a copy set
rs.add ("192.168.1.102 br 27018")
5. Check the configuration status rs.status ():
.
: