MongoDB Cluster Configuration
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
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
Installation on Ubuntu
The steps for installation for Ubuntu can be found in the followingLink
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
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
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
sharding:
juanpabloconfig/192.168.0.13:27019
net
localhost
After executing:
sudomongod--configmongodb.conf
sh.addShard("replicaone/192.1680.0.14:27017")