Skip to content

Configuring MongoDB in a PLOSSYS 5 Cluster


Caution - the same database

All servers in a cluster must use the same database.


Configuring a Shared Replica Set

For the communication within the cluster, configure the database servers with a shared replica set.

Perform the following configuration steps on <server_1>, <server_2> and <server_3>:

  1. Edit the MongoDB configuration file:

    /opt/seal/etc/mongod.conf
    
  2. Change the following line:

    bindIp: 127.0.0.1
    

    to:

    bindIp: 0.0.0.0
    
  3. Add the following lines:

    replication:
      oplogSizeMB: 2048
      replSetName: <YourReplicaSetName>
    

    Hint - oplogSizeMB

    We recommend setting oplogSizeMB to 5 % of the disk space available for MongoDB.

  4. Restart the MongoDB:

    mongod
    

Initializing the Database Cluster

Perform the following configuration step on <server_1>:

  1. Initialize the cluster on <server_1>:

    sudo mongo --ssl --sslAllowInvalidCertificates --eval "rs.initiate({ _id : '<YourReplicaSetName>', members: [{ _id : 0, host : '<server_1>' }]})"
    

    The output has to contain the following line:

    "ok" : 1


Connecting the Database Server to the Cluster

After initializing the database cluster on <server_1>, add the other servers.

Perform the following configuration steps on <server_1>:

  1. Add <server_2> to the cluster:

    sudo mongo --ssl --sslAllowInvalidCertificates --eval "rs.add('<server_2>')"
    

    The output has to contain the following line::

    "ok" : 1

  2. Add <server_3> to the cluster:

    sudo mongo --ssl --sslAllowInvalidCertificates --eval "rs.add('<server_3>')"
    

    The output has to contain the following line::

    "ok" : 1

  3. Proceed until all servers are added.

  4. Proceed until all servers are added.


Checking the Status of the Database Cluster

  1. Execute the following command:

    sudo mongo --ssl --sslAllowInvalidCertificates --eval 'printjson(rs.status())'
    

    The output has to contain the following line:

    "ok" : 1


Showing the Configuration of the Database Cluster

  1. Execute the following command:

    sudo mongo --ssl --sslAllowInvalidCertificates --eval 'printjson(rs.conf())'
    

Back to top