Skip to main content

Checks to be Made Before Starting Installation

Very ImportantBefore starting installations, make sure that the server’s hostname is not localhost.localdomain and each one is unique (with hostname command). If it is, be sure to change it before starting operations.
There should not be an IP block hostname assignment like 127.0.1.1 in the /etc/hosts file.There should not be an entry like nameserver 127.0.1.1 in the /etc/resolv.conf file.
ImportantFor the installation to be healthy, your servers need to access the following addresses.MongoDB:

Operating System Configurations

These steps should be performed on all MongoDB servers.

MongoDB Installation

Installing MongoDB Application

These steps should be performed on all MongoDB servers.

MongoDB Configurations

These steps should be performed on all MongoDB servers.
Creating key:
You need to add the following parameters to the /etc/mongod.conf file by setting them according to your environment:
  • storage / wiredTiger
  • replication
  • security
  • setParameter
  • processManagement
The following are edited and added without changing other lines.
Then MongoDB application is started.
If MongoDB installation will be done on multiple servers, keys created on Primary node are moved to all nodes and the same permissions are given.

ReplicaSet Configuration and Authorized User Definition

These steps should be performed only on MongoDB Primary server.
Replicaset activation operation should be done only on Primary server.
Activating Replicaset:
Creating authorized user for Apinizer application:
If MongoDB’s local management will be done by you, a user with the following role needs to be created.
If password change is desired
Replicaset settings are made.
Grant permission to a user on previously created MongoDB using the following command lines.
If arbiter is desired to be added to MongoDB:

MongoDB ReplicaSet Installation on Multiple Servers

These steps should be performed only on MongoDB Primary server.
Apinizer recommends MongoDB’s high availability feature. High availability enables Secondary Nodes to come into play when Primary Node fails.At least 3 servers (1 Primary and 2 Secondary) are required for high availability in MongoDB as well. If Primary node encounters a problem, a Secondary node automatically becomes Primary, so the system works without interruption. When Primary node becomes active again, it remains as Secondary node. However, this function cannot be seen when there are fewer than 3 active servers.High availability is not limited to only 3 servers; it can also be applied with Arbiter or more servers. Servers can be positioned in different locations to increase system continuity.For more information, you can check the link https://www.mongodb.com/docs/manual/core/replica-set-architectures/.
When you restart Mongod services, you can configure Secondary nodes on Primary node with replica set architecture using the following commands.
With this step, a structure consisting of a total of three servers, one Primary and the other two Secondary, has been established. In high availability situation, if Primary server’s connection is cut or it does not work, a Secondary server should automatically take over the main server role. To set this situation, the following steps should be applied for all nodes on Primary node.
Priority specifies the priority of the node being selected as new Primary and this value can be scaled between 0 and 1. While value 0 indicates that it can never be Primary node, Primary priority is found according to how close other values are to 1.Votes specifies whether a node can vote in a new Primary election and takes value 0 or 1. This value shows whether the node will vote in the election.
This installation has been prepared assuming that DNSs in the form of “mongoDb01, mongoDb02, mongoDb03, k8sWorkerIP” can be resolved by the system. In cases where servers cannot resolve these DNSs, either this situation should be fixed or all DNSs should be fixed as IP.