Is it possible for the Secondary nodes from the Replicate Set to only copy certain collections in a DB. Can it copy multiple DBs?
Besides Port number 27017 what other ports can be used to create the replSet mongod instance. What ports can be used fo Replication ?
How can you setup a Replicate Set where the members are in different networks? Since the rs.add(HOST_NAME:PORT NUMBER) command to add members will not work since the HOST NAME cannot be recognized because the network is not private but a public one.
Replica sets are designed for high availability and. failover, so each replica set member includes the same set of data (with the exception of the local system database, which is used for instance-specific data like the replication oplog). In a failover/election scenario, you want to have multiple members of a replica set eligible to become primary so there is some fault tolerance allowing some members of your replica set to be temporarily unavailable while still maintaining a primary.
If you only want to copy a subset of collections or databases, you will have to work out a separate solution from the built-in replication. For example, you could have multiple MongoDB deployments and Back up & Restore selected databases with MongoDB tools. You could also implement custom sync in application code using Change Streams to follow and relay data changes of interest.
Ports 1024-49151 (“registered ports”) are used for applications. Popular applications often have registered standard ports to avoid conflicts for default installations. The default MongoDB ports are 27017-27020. You generally want to avoid using a port commonly used by another service (for example, MySQL’s default port is 3306) but the main technical limitation is that you can’t have two different processes listening to the same IP:port combination.
Ports 0-1023 (“welll-known ports”) are usually used for system services (DNS, SSH, LDAP, …) and typically require superuser access (so are not recommended for applications like MongoDB).
Ports 49152-65535 are typically used for dynamic or ephemeral ports.
Your replica set members will need to be able to communicate with each other via the configured IP:port combinations, so you will have to set up appropriate firewall and networking configuration. The MongoDB Security Checklist has more information on recommended security measures.