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 -->
Related
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/
I am trying to configure a replica set on windows as a service, means that even the PC will restart the mongod will run again automatically.
problem is that I run the mongod like this:
mongod --dbpath "C:\Program Files\MongoDB\Server\4.2\data" --logpath "C:\Program Files\MongoDB\Server\4.2\log\mongod.log" --port 27017 --storageEngine=wiredTiger --journal --replSet test_replica
And once I close the CMD running this command the service is killed. How do I run it correctly then?
Also, currenctly the service is navigating to the default cfg file but I see the replication there is marked with # (so the service is running as standalone). and when I try to add to replication the replSet: test_replica it won't start anymore.
You should put all your parameters into a configuration file. Then you can create the service like this:
mongod.exe --config c:\MongoDB\config\mongod.cfg --install
For a replica set you typically create several services, not just one. It is possible to run a replica set with just one member, however this is quite useless. Of course, when you create several services then each one needs his own config file (and also his own dbPath, port, etc.)
The next time your PC will boot, the mongo service should also start. Or start it manually with command net start <mongo service name>
You should install mongodb as windows service. Read the guide from the official documentation
Setting --replSet from command line or replication:replSetName in configuration file is not enough. Read this guide, in short: after mongodb process is started in replica set mode, you should run rs.initiate() in mongo shell.
I am new to mongodb and am looking into the concept of replication .
Can u please help if u are aware of this error.
The error I got
The config file I am using
Thanks in advance,
Tarun
Its because you're passing in config to the rs.initiate function.
Before you run the initiate you need to start the different mongod instances which will make up the replicaset. Then run rs.initiate() on one of the nodes (without and args). You can then do rs.add(<host:port>) to add the nodes making up the rs.
There are some excellent tutorials available for setting up replicasets. This one is a good starting point:
https://docs.mongodb.com/manual/tutorial/deploy-replica-set/
It provides step-by-step instructions for starting the necessary mongod instances, and linking them as a replicaset in the mongoshell
you need to start all mongod instances with following command which include replica set name, other way is to create entries in config file and pass it to mongod process :
mongod --replSet "Tarun"
then you can initiate : rs.initiate() with your config file
I have installed mongo db in my local system, i am aware that at any point in time we can start the mongo using mongod service.
in normal mode which will run on port 27017
in rest API mode where we can query to collections and db's which normally runs on mongo port + 1000
i want to start both mode together, any help would be appreciated.
Thanks
Amit
You should add modify your mongod config file to enable http.
add following config line, see https://docs.mongodb.org/manual/reference/configuration-options/
net:
http:
enabled: true
or add parameter in the command line
mongod --httpinterface
You can start multiple instances of mongod. You just have to make sure that they're using different ports and different dbpaths.
To run two separate instances of mongod
mongod
This will start a mongod instance on port 27017 and use dbpath /data/db
Start another command prompt and type in
mongod --port 27018 --dbpath /data/db2
Just make sure that you have a folder named db2 inside your data folder in your c drive. That's where it stores the data.
Additionally, if you're on Node.js, the MongoDB Node.js driver provides a server method where you can start a mongod instance programatically.
var mongo = require("mongodb");
var server = new mongo.Server('localhost', 27017, { auto_reconnect : true} );
This will create a server in what you are calling the Rest API mode.
And then you can simply start mongod from command prompt specifying some other port and dbpath.
I'm not sure which we can start two instance of mondo or not!. but try this:
Run one of then through service mongod start and second one directly by running binary file (e.g. /usr/bin/mondodb). (also you can run both of them directly from CLI.)
In second mode, you most give appropriate parameter for mondo (e.g. path for config file). If you don't know how to give/pass parameters to mondo's binary file, see man mongodb or go and read /etc/init.d/mongod (in Debian based distributions), it give you useful information)
Unfortunately I don't have an installed mongoDB on my machine, so I can't give you exact commands.
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