Not able to start mongodb server as a long running process - mongodb

I want to keep MongoDb server running forever or as a background process.
But while doing so it throws me the below error :
about to fork child process, waiting until server is ready for connections.
forked process: 12538
ERROR: child process failed, exited with error number 1.
Command I have used is :
mongod --dbpath="<location of data files>" --fork --logpath="/var/log/mongodb/mongodb.log".
Can anyone comment here?

Related

How to initial sync mongo replica

My mongo slave is dead because it stopped unexpectedly due to not enough space and It wont start due to
mongodb.service: Main process exited, code=exited, status=14/n/a
I tried to fix the error with following suggestions:
https://askubuntu.com/questions/823288/mongodb-loads-but-breaks-returning-status-14
but it lead to next error code:
mongodb.service: Main process exited, code=exited, status=100/n/a
which I tried to fix with following
https://dba.stackexchange.com/questions/220411/sudo-service-mongod-start-returns-error-100
this it it log output
2021-05-01T18:25:30.987+0000 I - [initandlisten] Fatal assertion 28579 UnsupportedFormat: Unable to find metadata for table:index-3-848131710157586571 Index: {name: _id_, ns: local.me} - version too new for this mongod. See http://dochub.mongodb.org/core/3.4-index-downgrade for detailed instructions on how to handle this error. at src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp 241
The command sudo service mongodb start wont work because the status command shows that the service is dead.
I figured out that it would be easier to resync the data from scratch. I found the documentation
https://docs.mongodb.com/manual/tutorial/resync-replica-set-member/#resync-a-member-of-a-replica-set
but I am not fully aware what commands run to execute this operation.
My dbPath = "/mnt/mongo/mongodb", MongoDB shell version v3.4.14, and my database has about 2.5T. Could you give my some guidance how to execute initial sync mongo replica?
From my understanding i should
sudo rm -r /mnt/mongo/mongodb/*
sudo service mongodb start
After some time everything should get back to normal(?)
Correct me if I am wrong...

mongoDB: child process failed, exited with 1 & 14

I have already tried it with the following thread but it didn't help me:
ERROR: child process failed, exited with error number 1,mongodb
Tried that:
sudo mongod --fork --config /etc/mongod.conf --logpath /var/log/mongodb/mongod.log
Result:
forked process: 2887
ERROR: child process failed, exited with 48
To see additional information in this output, start without the "--fork" option.
Tried the following as well:
sudo systemctl start mongod
One of the lines in the error message say:
ERROR: child process failed, exited with 14
Would appreciate any help. mongod was working pretty well until I have started trying to implement a replica set.
Use this command on the terminal:
sudo mongod --dbpath /System/Volumes/Data/data/db
It should start the MongoDB server and allocate a port for it. You can exit out of the server and then try the command again and it should work.

Mongodb 3.4 - fail to start mongodb

How can I start mongodb. The child process fail.
-bash-4.1$ mongod --config /mongodb/etc/mongod-ctr.conf
about to fork child process, waiting until server is ready for connections.
forked process: 22965
ERROR: child process failed, exited with error number 48
-bash-4.1$ mongo
MongoDB shell version v3.4.17
connecting to: mongodb://127.0.0.1:27017
2018-11-27T13:52:13.826-0500 W NETWORK [thread1] Failed to
connect to 127.0.0.1:27017, in(checking socket for error after
poll), reason: Connection refused
According to the MongoDB error code manual, and your error status, there seems to be another process either running on port 27017, or you just don't have the right permissions.
You can use the command lsof -i -P -n to see a list of all applications, and the ports they are using.

ERROR: child process failed, exited with error number 4

I was trying to run this command
#mongod --fork --logpath /var/log/mongod.log
but I got this message
about to fork child process, waiting until server is ready for connections.
forked process: 10750
all output going to: /var/log/mongod.log
log file [/var/log/mongod.log] exists; copied to temporary file
[/var/log/mongod.log.2017-05-23T14-57-31]
ERROR: child process failed, exited with error number 4
Could you please help me resolve the problem?
Per the MongoDB docs:
4
The version of the database is different from the version supported by the mongod (or mongod.exe) instance. The instance exits cleanly.

mongodb keyFile between replicas throws Permission denied

I have a single node ReplicaSet with auth activated, a root user and a keyFile I've created with this tutorial, I also have two more mongod processes in the same server in different ports (37017 and 47017) and the same replSet name, but when I try to add the secondaries in the mongo shell connected to PRIMARY with rs.add("172.31.48.41:37017") I get:
{
"ok" : 0,
"errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 172.31.48.41:27017; the following nodes did not respond affirmatively: 172.31.48.41:37017 failed with Failed attempt to connect to 172.31.48.41:37017; couldn't connect to server 172.31.48.41:37017 (172.31.48.41), connection attempt failed",
"code" : 74
}
Then I went to the mongod process log of the PRIMARY and found out this:
2015-05-19T20:53:59.848-0400 I REPL [conn51] replSetReconfig admin command received from client
2015-05-19T20:53:59.848-0400 W NETWORK [conn51] Failed to connect to 172.31.48.41:37017, reason: errno:13 Permission denied
2015-05-19T20:53:59.848-0400 I REPL [conn51] replSetReconfig config object with 2 members parses ok
2015-05-19T20:53:59.849-0400 W NETWORK [ReplExecNetThread-0] Failed to connect to 172.31.48.41:37017, reason: errno:13 Permission denied
2015-05-19T20:53:59.849-0400 W REPL [ReplicationExecutor] Failed to complete heartbeat request to 172.31.48.41:37017; Location18915 Failed attempt to connect to 172.31.48.41:37017; couldn't connect to server 172.31.48.41:37017 (172.31.48.41), connection attempt failed
2015-05-19T20:53:59.849-0400 E REPL [conn51] replSetReconfig failed; NodeNotFound Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 172.31.48.41:27017; the following nodes did not respond affirmatively: 172.31.48.41:37017 failed with Failed attempt to connect to 172.31.48.41:37017; couldn't connect to server 172.31.48.41:37017 (172.31.48.41), connection attempt failed
And the log of the mongod that should become SECONDARY shows nothing, the last two lines are:
2015-05-19T20:48:36.584-0400 I REPL [initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument Did not find replica set configuration document in local.system.replset
2015-05-19T20:48:36.591-0400 I NETWORK [initandlisten] waiting for connections on port 37017
It's clear that I cannot rs.initiate() in this node because it will self vote to be PRIMARY and that would create a conflict, so the line that states "Did not find local replica set configuration document at startup" is to be ignores as far as I know.
So I would think that the permission should be ok since I'm using the same key file in every mongod process and the replSet is the same in every config file, and that's all the tutorial states to be needed, but obviously something is missing.
Any ideas? Is this a bug?
If you are using ec2 instances and ip 27017 port in security group for both instances, just add a secondary instance port. It worked for me.