Skip to content

Initializing the Database


Hint - secondary memmbers of a replica set

Secondary members of a replica set do not need to be initialized.


Single System

  1. Open a PowerShell (Administrator).

  2. Initialize the database:

    & "C:\Program Files\mongosh\mongosh.exe" --tls --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --eval "rs.initiate()"
    

    The output has to contain the following line:

    "ok" : 1


Proceed with Securing MongoDB: TLS encryption or user authentication.


Replica Set Primary

Caution - replica set primary only

Perform the following configuration steps only on the replica set primary:

  1. Open a PowerShell (Administrator).

  2. Initialize the cluster on <server_1>:

    & "C:\Program Files\mongosh\mongosh.exe" --tls --tlsAllowInvalidCertificates --eval "rs.initiate({ _id : '<YourReplicaSetName>', members: [{ _id : 0, host : '<Server1>' }]})"
    

    The output has to contain the following line:

    "ok" : 1


Proceed with connecting the database servers to the cluster.


Back to top