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 a hostname defined as 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.
ImportantWhen updating Ubuntu packages, it tries to pull from the server in Turkey location. However, there may be problems at tr.archive.ubuntu.com address from time to time. In this case, the following change needs to be made.
#Replace all addresses containing tr. with “Replace All”.#Example:Old: http://tr.archive.ubuntu.com/ubuntuNew: http://archive.ubuntu.com/ubuntu

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 state the relevant configuration file should be in:
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.
Changes That May Be NeededGrant permission to a user on previously created MongoDB using the following command lines.
If hostname or IP address change is desired:
If a user password change is desired:
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.