Read-Write Configuration of mongodb Master-Slave Server

  mongodb, question

I am very happy to be on the Sibu website for the first time. I am not talented. I encountered a small problem when learning mongodb to configure the master server and the slave server today. That is, when I set the ip and port of the master server and the slave server, the login master server and the slave server

Because it is the master server that cannot achieve the effect of master and slave, I hope the big brothers can give me some advice. ! ! Thank you very much.

The steps for setting up the master-slave server are as follows:
Environment: mac Version //MongoDB version: “3.4.2

  1. Creating Database Directories db1, db2
    Create two directory paths of /Users/gavin/Desktop to suspend two mongodb servers

mkdir db1
mkdir db2
2. Suspend 2 servers respectively
mongod –bind_ip –port 27017 –dbpath /Users/gavin/Desktop/db1 –replSet rs0
mongod –bind_ip –port 27018 –dbpath /Users/gavin/Desktop/db2 –replSet rs0

3. Connect to the main server, and set as the main server here

mongo –host –port 27017

4. Add replica set
5. View the configuration status rs.status ():
The configuration seems to be no problem.

The link from the server is as follows:

There is a problem with the connection method, it is better to use Mongo-Host 27017 without knowing it. Embarrassment