Configure MongoDB in a Cluster¶
All PLOSSYS 5 servers 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 shared replica set.
Perform the following configuration steps on <server_1>
, <server_2>
and <server_3>
:
-
Open the MongoDB configuration file:
/opt/seal/etc/mongod.conf
-
Change the following line:
bindIp: 127.0.0.1
to
bindIp: 0.0.0.0
-
Add the following lines:
replication: oplogSizeMB: 2048 replSetName: p5
Hint -
oplogSizeMB
We recommend setting
oplogSizeMB
to 5 % of the disk space available for MongoDB. -
Restart the following service:
seal-mongodb
Initialize the Database Cluster¶
Perform the following configuration step on <server_1>
:
-
Initialize the cluster on
<server_1>
:sudo mongo --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval "rs.initiate({ _id : 'p5', members: [{ _id : 0, host : '<server_1>' }]})"
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>
:
-
Add
<server_2>
to the cluster:sudo mongo --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval "rs.add('<server_2>')"
The output has to contain the following line::
"ok" : 1
-
Add
<server_3>
to the cluster:sudo mongo --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval "rs.add('<server_3>')"
The output has to contain the following line::
"ok" : 1
Configure Access to the Cluster in PLOSSYS 5¶
Perform the following configuration steps on <server_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.
-
In the file with the exported configuration,
<plossys_5_backup>.yml
, change theMONGO_JOBS_URL
,MONGO_EVENTS_URL
andMONGO_PRINTERS_URL
keys according to the following scheme:service: any: tag: any: MONGO_ACTIONS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-actions?replicaSet=p5 MONGO_CONFIGS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-configs?replicaSet=p5 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_LOCKS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-locks?replicaSet=p5 MONGO_PREPROCESS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-preprocess?replicaSet=p5 MONGO_PRINTERS_URL: mongodb://<server_1>,<server_2>,<server_3>/spooler-printers?replicaSet=p5
-
Save the file.
-
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¶
sudo mongo --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval 'printjson(rs.status())'
The output has to contain the following line:
"ok" : 1
Show the Configuration of the Database Cluster¶
sudo mongo --ssl --sslAllowInvalidCertificates --sslAllowInvalidHostnames --eval 'printjson(rs.conf())'