Skip to content

Configure MongoDB in a Cluster


All PLOSSYS 5 server in a cluster have to use the same database.


Configure a Shared Replica Set

For the communication among each other, configure the database servers with a common replica set.

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

  1. Open the MongoDB configuration file:

    C:\ProgramData\SEAL Systems\config\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: p5
    

    Hint - oplogSizeMB

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

  4. Restart the following service:

    • seal-mongodb

Initialize the Database Cluster

Perform the following configuration step on <server_1>:

  1. Initialize the cluster on <server_1>:

    & "C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval "rs.initiate({ _id : 'p5', members: [{ _id : 0, host : '<Server1>' }]})"
    

    The output has to contain the following line:

    "ok" : 1
    

Connect 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:

    & "C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval "rs.add('<server_2>')"
    

    The output has to contain the following line::

    "ok" : 1
    
  2. Add <server_3> to the cluster:

    & "C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval "rs.add('<server_3>')"
    

    The output has to contain the following line::

    "ok" : 1
    

Configure the Access the Cluster in PLOSSYS 5

Perform the following configuration steps on <server_1>:

  1. Export the configuration of PLOSSYS 5:

    plossys config export <plossys_5_backup>.yml
    

Hint - more options

For more information about the export via PLOSSYS CLI, refer to Administrate the System Configuration.

  1. In the file with the exported configuration, <plossys_5_backup>.yml, change the MONGO_JOBS_URL, MONGO_EVENTS_URL and MONGO_PRINTERS_URL keys according to the following scheme:

    service:
      any:
        tag:
          any:
            MONGO_EVENTS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-events?replicaSet=p5
            MONGO_JOBS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-jobs?replicaSet=p5
            MONGO_PRINTERS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-printers?replicaSet=p5
    
  2. Save the file.

  3. Import the changed configuration:

    plossys config import <plossys_5_backup>.yml
    

    Hint - more options

    For more information about the import via PLOSSYS CLI, refer to Administrate the System Configuration.


Check the Status of the Database Cluster

& "C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval 'rs.status()'

The output has to contain the following line:

"ok" : 1

Show the Configuration of the Database Cluster

& "C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval 'rs.conf()'

Back to top