Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views3 pages

MongoDB Cluster Configuration

This document provides instructions for setting up a MongoDB cluster. It recommends that all servers have the same version of MongoDB and describes how to check the installed version. Additionally, it explains the preliminary steps such as registering the IPs of the servers in the hosts file, starting the MongoDB service from the console instead of using systemctl, and installing MongoDB on Ubuntu and Arch Linux derivatives. Finally, it details how to configure the config server, a replica server, and the mongos server, including the required configuration files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

MongoDB Cluster Configuration

This document provides instructions for setting up a MongoDB cluster. It recommends that all servers have the same version of MongoDB and describes how to check the installed version. Additionally, it explains the preliminary steps such as registering the IPs of the servers in the hosts file, starting the MongoDB service from the console instead of using systemctl, and installing MongoDB on Ubuntu and Arch Linux derivatives. Finally, it details how to configure the config server, a replica server, and the mongos server, including the required configuration files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

MongoDB cluster configuration

Versions
It is recommended that all servers have the same version.
To check the installed version, the command is used

mongo--version

The output should be similar to:

MongoDB shell version v4.0.10


c389e7f69f637f7a1ac3cc9fae843b635f20b766
OpenSSL 1.1.1c 28 May 2019
allocator:tcmalloc
modules:none
build environment:
distmod:ubuntu1804
distarch:x86_64
x86_64

Preliminary steps

Hostnames

Each team must have the IPs of the other teams recorded in the file.hosts
Routes:

On GNU-Linux:/etc/hosts
On Windowsc:\windows\system32\drivers\etc\hosts

For example, if the server configuration has the IP 192.168.0.13 and the computer name is Juanel, the hosts file
The enmongos server must have the following line:

192.168.0.13 Juan

MongoDB service

The mongo demon must be started from the console, not with systemctl because it usually causes
conflicts, which is why it is recommended to run the following command before starting.

sudosystemctlstopmongodb

or its equivalent command

Installation on Ubuntu

The steps for installation for Ubuntu can be found in the followingLink

Installation on Arch and derivatives


Mongo is installed from AUR, using yaourt or aurman.

Replica set configuration


For this case, the configuration server will be called juanpabloconfig. The file of
the configuration is the following:

replication
juanpabloconfig

systemLog
destination:file
/var/log/mongodb/mongod.log
logAppend:true
storage
journal
enabled:true
net:
0.0.0.0
port:27019
setParameter
enableLocalhostAuthBypass:false

This file is saved with an easily accessible name and path, for this case it will be
mongodb.confthen the command is executed:

sudomongod--configmongodb.conf

Replica set configuration


For this case, the replica server will be called replicauno. The configuration file is the
next:

sharding
shardsvr
replication
replicauno
net:
localhost

This file is saved with a name and a path that are easy to access, in this case it will be
mongodb.confthen the command is executed:

sudomongod--configmongodb.conf

Configuration of the mongos server

The configuration of the mongo is similar to the previous ones, only the file changes.
configurationmongodb.conf.
Assuming that the IPs are the following:
Config server: 192.168.0.13
Shard 1 server (replicauno): 192.1680.0.14

The filemongodb.confit would be:

sharding:
juanpabloconfig/192.168.0.13:27019
net
localhost

After executing:

sudomongod--configmongodb.conf

Then in the mongo console add the shards:

sh.addShard("replicaone/192.1680.0.14:27017")

Guide created by: Baderda

You might also like