Can you take the mongodb replication set out from the disk and make a new mongodb server?

  mongodb, question

I tried to do this, but could not copy the set initialization.

Yes, the operation process is as follows:

  1. Don’t add examples--replSetParameter startup;
  2. Delete local database:
    use local;
  3. Add--replSetRestart;
  4. Reinitialize a new replication set;

The principle is very simple, the copied node is already a member of a copy set, of course you are not allowed to reinitialize. However, this information is stored in some sets of the local library (you can see which sets are available if you are interested). Therefore, if these sets are deleted, the system will think that this is an uninitialized replication set. Then initialization can begin.
In fact, it can be done without deleting the local library and changing the contents of the tables in it. However, it may be more complicated. If you are interested, you can explore it yourself.