'PRIMARY' / 'SECONDARY' after rs.initiate()

I have a doubt. I’m at the third lecture “Setting Up a Replica Set” of Chapter 2: Replication of M103.

At 3:27 Matt executes the rs.initiate() command. The shell shows some data that didn’t show to me (from $operationTime line to bottom) and the shell stays in MongoDB Enterprise > whereas my command line went from MongoDB Enterprise m103-example:SECONDARY> to MongoDB Enterprise m103-example:PRIMARY:


Here’s mine:

After I pressed ENTER it went from SECONDARY to PRIMARY.

  1. What’s up with these differences? I know I can keep up with the practice but I get bothered with this SECONDARY/PRIMARY because I feel I’m in a different place and feel that whatever command I execute will take a different effect if I’m in PRIMARY, SECONDARY or just MongoDB Enterprise

  2. What would have happened if I executed the db.createUser() command when it showed up SECONDARY?

MongoDB shell version: 3.6.16

I’m sorry if I ask unnecessary stuff or out of the scope of the course.

Thank you.

Don’t worry @Luis_Fernando_18793, you’re doing the right thing. He probably set the prompt for the mongo shell to only show “MongoDB Enterprise”, or it’s taking a little while for the prompt to change.

By the time you run createUser() the server would have become PRIMARY so it won’t matter i don’t think, but it’s obviously better to ensure that you’re in the PRIMARY state before attempting any other commands. It usually initiates from OTHER > SECONDARY > PRIMARY and it does all this in mere seconds.

1 Like

Hi @Luis_Fernando_18793,

I hope you found the post #2 made by @007_jb helpful.

The shell version used in the video lecture is 3.6.2. Don’t worry the prompt eventually changes to PRIMARY>

If you still have any question then please feel free to get back to us.

Shubham Ranjan
Curriculum Support Engineer