I am newbie on Ubuntu Platform (Past was on Windows 10). I want to create specific directory where my MongoDB data will be store.

Expectation of Designing the Structure

  • Mongodb is a main Parent folder
  • Under that there is 3 Database folder (For Replication purpose)
  • First one is : Master. Under this folder I have created the master.conf file.
  • Second one is : Slave. Under this folder I have created the slave.conf file.
  • Third one is : Arbiter. Under this folder I have created the arbiter.conf file.

Now I installed Mongodb through the official documentation link that is Mongodb-official-link-for-ubuntu-installation

Now I want to create three seperate instances and there data and log file all are under specific folder. I have done this on Windows but not able to do on Ubuntu 18.04 LTS.

My master.conf file is:

# master.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /home/mongodb/master
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /home/mongodb/master/master.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

My slave.conf file is

# slave.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /home/mongodb/slave
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /home/mongodb/slave/slave.log

# network interfaces
net:
  port: 27018
  bindIp: 127.0.0.1


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

And my arbiter.conf is :

# arbiter.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /home/mongodb/arbiter
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /home/mongodb/arbiter/arbiter.log

# network interfaces
net:
  port: 27019
  bindIp: 127.0.0.1


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

after that I run the command for copying all the engine & related data files of mongodb ie.

under master folder I run the command: mongod dbpath --/home/mongodb/master
under slave folder I run the command: mongod dbpath --/home/mongodb/slave
under arbiter folder I run the command: mongod dbpath --/home/mongodb/arbiter

All these things are done from my side. Now by default mongodb create the mongodb run as a service which is initiated through the command "sudo service mongod start". I will also like to create that with different name by which my specific instance will run. For run I have to create the service And that I dont know how to create...

On windows platform it have the command that is

sc.exe create Master binPath= "\"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe\" --service --config=\"C:\data\mongod.cfg\"" DisplayName= "Master" start= "auto"

Is anyone here who guide me for achieve this task. any help is really appreciated.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.