Short answer / tl; dr
Not.
Slightly long answer
No, because it makes sense to use a shell.
Answer
When you set up a replica set, you usually have several members. As long as the replica set is not initialized, none of the members have the necessary configuration. the node that you initialize the replica set becomes the main, saving the configuration. Now you add items either with the rs.add command or with rs.reconfig . What happens then is that the main contact adds a member, configuration synchronization, and some other things. It is best that the regular members of the replica set are equal, so that one of the node fails, there is no dearth of the fact that the other node becomes the main one, and so the new primary element can remain primary until it goes for some reason or another by itself.
So, if you run a member of a replica set, where should it get the configuration from? Decide for yourself what he should do. This will not work in the cluster. How should he find other members and their configuration? Remember that replica set members can be located in different data centers. And if there was a parameter --IamPrimaryDoAsISay , what will happen if there is another main cluster? And how should a situation be solved in which more than one member with this option has been started? Switching to another server? Maybe just because you replaced the cooler? Or should the newly started instance do nothing when it was already the primary? What is the meaning of this option in the first place?
And all these complications just to prevent a single command from the shell?
Note. If you need one server, just run a standalone instance (mongod without the --replSet option). If you want to explore the possibilities of a replica set, you will need several members.
source share