Friday, 7 September 2018

mongo config files



There are 2 ways, we can spawn mongodb processes

a. CLI way

User can use below mongodb CLIs to spawn processes for auth
mongod-
mongod --configsvr --replSet setname --dbpath /data --port 26050 --fork --logpath /data/log.cfg0 --logappend --oplogSize 50 --directoryperdb --auth --keyFile /home/key

mongos-
mongos --configdb setname/host1.pne.ven.veritas.com:26050 --fork --logappend --logpath /data/log.mongos0 --port 26051 --keyFile /home/key

Note- Just remove --auth switch and key file if you don't wish to enable auth for testing purpose

b. Using conf files

Let's see how to spawn it using conf files.
Below is the typical example for mongodb.conf file

Here, I have enabled auth using key file and placed same under /home/key with 400 permission








Available mongod.conf options are as below, you can edit and enable required options as per required environment to be set.


net:
      port: 27017
      bindIp: 0.0.0.0
     ssl:
          mode: requireSSL
          PEMKeyFile: /home/mongodb/host2.pem
          CAFile: /home/mongodb/mongo-CA-cert.crt
storage:
      dbPath: /data
systemLog:
      destination: file
      path: "/data/log.cfg0"
      logAppend: true
storage:
      journal:
          enabled: true
sharding:
     clusterRole: configsvr
replication:
     replSetName: cert2set
#security: authorization: enabled
#clusterFile:/home/mongodb/host1.pem
security:
clusterAuthMode: x509
processManagement:
fork: true



A typical example of mongos.conf will be like below





No comments:

Post a Comment

Configure certificate based authentication for mongodb (MongoDB-X509 authentication)

A . Spawn mongod and mongos with no authentication first Configure MongoDB cluster, with no authentication, enabled using config files ...