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>
:
-
Edit 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: <YourReplicaSetName>
Hint -
oplogSizeMB
We recommend setting
oplogSizeMB
to 5 % of the disk space available for MongoDB. -
Restart the MongoDB:
mongod
Initializing the Database Cluster¶
Perform the following configuration step on <server_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>
:
-
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
-
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
-
Proceed until all servers are added.
-
Proceed until all servers are added.
Checking the Status of the Database Cluster¶
-
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¶
-
Execute the following command:
sudo mongo --ssl --sslAllowInvalidCertificates --eval 'printjson(rs.conf())'