change the mongod configuration file after mongodb replicaset started - mongodb

is there a way to change mongod.conf and have it applied to a mongodb replica set after initialization. I tried restarting mongod passing in new mongod.conf however the new config was was not applied it the replica set still reflected the old mongo config
https://docs.mongodb.com/manual/reference/configuration-options/

Related

setting up config server setup for mongo query router

I am using mongo v3.2 - I already have the config replica set as well as two shard replica sets running. When I try to launch the mongos (query router) with the test config file setting below, I get the error copied below - any ideas on how to fix this?
sharding:
configDB: config-set0/127.0.0.1:27019,127.0.0.1:27020,127.0.0.1:27021
error
Unrecognized option: sharding.configDB
I can see this setting in the mongodb docs at the URL below:
https://docs.mongodb.com/manual/tutorial/deploy-shard-cluster/
Ensure that the process is being launched as mongos and not mongod if the intent is to run the process as a query router (and not a config server or a shard).
Use this command to start the mongos.
sudo mongos -f <-- location of conf file -->

Are the changes done by db command in MongoDB permanent and how?

Are the changes done using the shell in mongodb permanent ?
And how MongoDb detects the config file?
I am stuck in setting Slow query logs in MongoDb.
We have a command db.setProfilingLevel() to set profiling level.
But how can we set profiling for all databases and how to set it via Config file?
How mongodb remember this change after restart?
Yes, Changes made to data in MongoDB shell are permanent but for configuration parameters, they will last only till next restart of instance if they are not specified in config file.
MongoDB runs with default values if config file is not specified.
You can specify config file as,
mongod --config /etc/mongod.conf
or
mongod --f /etc/mongod.conf
and for profiling you can provide parameters from command line or in config file like,
From command line,
mongod --slowms <value in milliseconds for slow queries>
or
mongod --profile <0/1/2>
In config file,
profile = <0/1/2>
slowms = <value>
logpath = <path>

Start Mongo with a flag

Is it possible to start mongod (using systemctl) with --master flag?
I want to use the oplog file to watch for data changes. I know this should be used with replicas set, but on my development machine I don't need any replicas set.
Yes, there is an option to enable oplog on standalone mongod. All you need to do is start mongod with --master option. Or if you have a config file add the entry master=true.
This option will ensure that oplog will be created, but unlike a replica set there will not be any secondary instances of mongod which will read it and apply it to their local databases.

oplog enable on standalone mongod not for replicaset

I am running mongod as standalone server .now i want to enable oplog for it ,i want to know whether it is possible or not ?
I knew I can do this by creating single node ReplicaSet ,but I want to do this without replica set .
I got a reply from the MongoDb Team, and it's working fine.
To enable oplog on a standalone server, start mongo with master options.
On command line start mongod --master.
For conf file append the following line:
master=true
More details here.
For mongo 2.6 or greater the /etc/mongod.conf now uses a yaml format.
To enable the oplog add something similar to the below, note the replication: line may already exist, be sure to use spaces.
replication:
replSetName: rs0
oplogSizeMB: 100
Full documentation here:
https://docs.mongodb.com/manual/reference/configuration-options/#replication-options

Set replSet without restarting the mongod

Is any way that I can assign the replSet without restarting the mongod? MongoDB Doc says that we should restart the mongo and assign some parameters, but I'm using MongoHQ's service (via Heroku), I can't find the way to set the replSet. How can I do it?