mongo wiredTiger db service start - mongodb

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"

Related

Mongodb: assigning docker gateway to mongo.conf

I'm trying to use my local mongodb inside my docker container.
To allow access, I have edited my mongo.conf as follows:
but when running mongo db restart, I get this in the mongodb.log:
systemLog:
destination: file
path: /opt/homebrew/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /opt/homebrew/var/mongodb
net:
bindIp: 127.0.0.1,172.17.0.1
ipv6: false
Can't assign requested address
{"t":{"$date":"2022-09-21T15:35:17.125+03:00"},"s":"E", "c":"CONTROL", "id":20568, "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Can't assign requested address"}}}
and running brew services restart mongodb-community && brew services list
mongodb-community error 12288 ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

offical mongo docker image cannot use custom file via volumen

I am trying simply to use mongo with custom configuration file placed in my host machine. I obtain 100 error code, I tested this in debian 10 and on a windows 10 machine (docker desktop). I think that its a permission issue, may be mongo has not permission to use those files.
docker-compose.yml
version: "3.7"
services:
mongod:
image: mongo:4.1.13
# restart: always
ports:
- "27017:27017"
volumes:
- ./config/mongo/mongod.conf:/etc/mongod.conf
- ./data/mongo:/data/db
# - ./log/mongo:/var/log/mongodb
entrypoint: ["mongod","--config","/etc/mongod.conf","--verbose"]
mongod.conf (default)
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Error:
This, this image does not create a log file under /var/log/mongodb.
Your docker-compose.yml and mongod.conf has inconsistent options:
docker-compose.yml specifies /data/db as a folder for DB files, but mongod.conf tries to use dbPath: /var/lib/mongodb (which is missing in your container). Fix your mongod.conf to point to /data/db/ folder and it should fix your error.
To debug such kind of error, your can run your image (mongo) by hand (docker run ...) with bash, instead of using docker-compose and you will be able to see all error in logs.

Mongo auth fails to login when using mongod.conf

So this is the weirdest thing.
I have two centOS 7 servers running mongo. I now wanted to enforce authentication so I added the security.authorization: enabled to the mongod.conf file.
I already have a user on database "buzzztv".
So when I ran mongod --conf /etc/mongod.conf on the first server everything went fine.
Then I did the exact same thing on the second server and whenever I try to connect with one of the users I get the following error:
connecting to: mongodb://127.0.0.1:27017/?authSource=buzzztv&compressors=disabled&gssapiServiceName=mongodb
2020-02-20T13:02:35.166+0000 E QUERY [js] Error: Authentication failed. :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-02-20T13:02:35.168+0000 F - [main] exception: connect failed
2020-02-20T13:02:35.168+0000 E - [main] exiting with code 1
Now if I run mongod --fork --logpath /var/log/mongodb/mongod.log --auth the login works perfectly fine.
So obiously I could just run this command, but I want to use the mongod.conf.
Here is my mongod.conf file, I checked and it is a perfect copy of the file from the server in which it does work.
Any ideas?
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
So after several hurtful hours of looking into it, I neede to change the
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
Apparently something was wrong with my /var/lib/mongo so I backed up the data, and created a new folder /var/lib/mongodb
Then edited the mongod.conf file to:
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
Then it all worked fine. Now I'll just re-create the users and re-insert all the data and I'm good to go.
Hope this saves someone the wasteful hours I've lost

Mongo Connector doesn't sync properly

Here's my problem.
Our solution :
Front web connect to a cloud mongodb instances.
End-point client connect to a local mongodb instances.
People put some data throught the Front web, those data must be sync to the local instances for end-point client.
End-point client generate some data to the local's instance which must be sync to the cloud environnement.
================================
I tried to use mongo-connector to sync both way and I did sync something but everytime mongo-connector sync only half of the data randomely...
Here's my local mongodb conf :
# Where and how to store data.
storage:
dbPath: /server/mongo/data
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
replication:
replSetName: rs-local
Master mongodb conf:
# Where and how to store data.
storage:
dbPath: /server/mongo/data
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#operationProfiling:
replication:
replSetName: master-replica-01
This is the command I use for mongo-connector :
/usr/local/bin/mongo-connector -m localhost:27017 -t X.X.X.X:27017 -d mongo_doc_manager -n "db.role,db.site,db.split,db.organism,db.users,db.namespace1.namespace2.namespace3.*" --admin-username mongosu --password verysecretpassword--oplog-ts /server/mongo/data/oplog.timestamp --no-dump --enable-syslog
Everytime I dump the database then launch the mongo-connector I got some of my data but not all of it...
I thought it was an oplog problem so set the oplog to 16Gb.
Many help ask :)
Elenui

Mongodb restrict to given IP to localhost

I am trying to restrict the mongodb to local ip, it is not working.
Using MongoDb 3.2 version.
Below is the configuration file for the service, which is located in "C:\Program Files\MongoDB\Server\3.2\mongod.cfg"
systemLog:
destination: file
path: c:\data\mongo.log
quiet: false
logAppend: true
storage:
dbPath: C:\data\db
directoryPerDB: true
wiredTiger:
engineConfig:
cacheSizeGB: 2
directoryForIndexes: true
net:
port: 27017
bindIp: [127.0.0.0, 10.64.87.231]
replication:
oplogSizeMB: 500
replSetName: "mongoDbRepSet"
setParameter:
enableLocalhostAuthBypass: false
processManagement:
windowsService:
serviceName: "MongoDB"
displayName: "MongoDB 3.2 Standard"
description: "This is the service for MongoDB 3.2 Standard version"
I am using below command
mongod --config "C:\Program Files\MongoDB\Server\3.2\mongod.cfg" --install
I am restarting the mongo service after installing it with the configuraiton.
Strange thing is, when I open in RoboMongo and try to connect using 127.0.0.0 and 10.64.87.231 it is not working.
Also noticed that, it is connecting with ip addresses 127.0.0.1 to 127.0.0.255 (so many loopback ips?)
I also checked by assigning enableLocalhostAuthBypass: true but still not working.
What is wrong happening no idea. Please help me to restrict mongo service to give ip address.