I am new to mongodb, this is my second day learning mongodb and trying to setup a sharded cluster.What I did is created virtual boxes of Ubuntu 18.04.1 LTS and installed mongodb version 4.2.8. after installing MongoDB on all of my VMs, I updated the mongod.conf file as follows (to configure Config Servers Replica Set, I connected to one of my VMs. I will be implementing 3 replica sets of Config servers)
net:
port: 27019
bindIP: 0.0.0.0,192.168.1.22,127.0.0.1
replication:
replSetName: rs01
sharding:
clusterRole: configsvr
after that, I restarted mongodb service using this command
sudo systemctl restart mongod
and when I try to connect to mongo shell or run this command
mongod --config /etc/mongod.conf
I get this error "Unrecognized Option: clusterRole". I am following official mongodb documentation on this link https://docs.mongodb.com/manual/tutorial/deploy-shard-cluster/
Any help would be greatly appreciated.
You are missing indentation in the yaml file. Suboptions need to be indented:
net:
port: 27019
bindIP: 0.0.0.0,192.168.1.22,127.0.0.1
replication:
replSetName: rs01
sharding:
clusterRole: configsvr
Related
I am trying to install a ReplicaSet with the help of the following manual:
[https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set/]
However, I always get that error:
Replication has not yet been configured
my code in OpenSUSE terminal
sudo mongod --port 27017 --dbpath /var/lib/mongo --replSet rs0 --bind_ip localhost
/etc/mongod.conf does have the following line:
replication:
replSetName: "rs0"
Anyone who could help me here? Would appreciate that!
You have two possibilities to start mongod
sudo mongod --port 27017 --dbpath /var/lib/mongo --replSet rs0 --bind_ip localhost
OR (when all those parameters, port, dbpath, bindIp... Are set in the config-file)
sudo mongod --config /etc/mongod.conf
Now mongod is running and it knows that it should be replica set.
Connect to that RS with 'mongo' command. You get answer like "MongoDB shell version v4.0.19" and prompt '>' where cursor is waiting your next command.
Now you need (only once) to initiate this replica set, give next command:
rs.initiate()
Now your prompt should be changed to
rs0:PRIMARY>
And you can "ask" now your replica set status
rs.status()
Or the configuration
rs.conf()
I have mongoDB container which runs on azure VM, and I'm trying to connect it to my mongoDB compass.
I have Public IP address to my VM, the port 27017 is open in my vm and also in my mongo container.
I have authentication, so to connect my mongo I'm Enter the mongo container and write the command "mongo -u username -p password --authenticationDatabase admin" (Relevant).
When I'm trying to connect I get "connection timed out" error message.
docker container ls
Open ports on the VM
My compass login page
I solved it by changing the configuration file of the mongoDB container.
Step 1:, make sure port 27017 is open on the VM:
Step 2:, create a mongoDB configuration file as below, name it mongod.conf, and change the bindIp field to your host IP (change < Host IP> to your host IP).
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /data/db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,<Host IP>
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Step 3: Copy the mogod.conf file into your VM, and save it wherever you want.
Step 4: Run the command:
docker run -d -v <FolderPathOnTheVM>/mongod.conf:/etc/mongod.conf -p 27017:27017 mongo -f /etc/mongod.conf
Make sure you changed the < FolderPathOnTheVM> to the path of the mongod.conf file on the VM (The path of step 3).
Do netstat on 27017 and check if its running on localhost or public IP. If its running on localhost, then change it to your public IP in mongodb config file and then retry. Also, telnet from your local machine to the mongodb IP and port to check if its working locally.
I am running Mongodb on AWS windows instance, I changed my config setting as following:
net:
port: 30000
bindIp: 0.0.0.0
As far as my knowledge, Server should get started on port 30000, it can listen request from other ip as well
However, on restarting mongod, it is still running on localhost and listening to port 27017
I have the same problem with you. What I did is a workaround it. I start the service with specifying the port and ip.
mongod --auth --port 30000 --dbpath /data/db --bind_ip_all
Basically I'm trying to change the default port of mongodb by changing the port in mongod.conf file . Then I'm starting the db by mongod --fork --logpath /var/log/mongod.log command . The db is being started in the background but the problem is it's still running on the port 27017.
mongod.conf:
net:
port: 15031
bindIp: 192.168.1.7
Add the parament mongod -f /etc/mongod.conf to specify the configuration file.
net:
port: 15031
Configuration file is written in YAML
You have to use SPACE characters instead of TAB characters for indentation.
Or pass the --port argument when you start mongod
mongod --port 15031
I installed the mongodb 3.0.2 on Ubuntu 14.04.2 with wiredTiger configured as the storage engine.
I change /etc/mongodbConfig.conf file -> /etc/mongod.conf
However
sudo service mongod start
doesn't start MongoDb
** service mongod start : error
Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service mongod start
But when I use this, I get the following error
initctl: Unknown job: mongod
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mongod
My mongod.conf
storage:
dbPath: "/data/wt"
engine: "wiredTiger"
wiredTiger:
engineConfig:
cacheSizeGB: 8
collectionConfig:
blockCompressor: snappy
replication:
oplogSizeMB: 1024
replSetName: "rs0"
net:
bindIp: "0.0.0.0"
port: 27017
systemLog:
destination: file
path: "/var/log/mongodb/mongodb.log"