os is deepin,i can use
/home/soft/mongodb/bin/mongod --dbpath=/home/soft/mongodb/data/db --logpath=/home/soft/mongodb/log/mongodb.log --logappend --port 27017 --fork
will normal start mongodb,but when i use the
mongod --config /usr/local/mongodb/mongodb.conf
will cause some problems like this picture
enter image description here
if the picture not display,error code :
root#deepin:/# mongod -config /home/soft/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 3196
ERROR: child process failed, exited with error number 100
after run,the log file picture like this
enter image description here
Try posting the logs if created any.
Check the permissions for folders created, i.e make sure the folders are created as sudo install-mongodb-child-process-failed-exited-with-error-number-100
Also try this out mongodb-wont-start-error-child-process-failed-exited-with-error-number-100
Related
I am having trouble making pm2 wait for mongodb to be ready before it starts a process on system reboot. (I am using Ubuntu 16.04 server)
In my systemd service file for pm2 I have this, which I thought would make it wait until after mongodb was started:
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
Wants=mongod.service
After=network.target mongod.service
[Service]
Type=forking
But it seems that it runs pm2, and therefore the node.js processes that pm2 launches before the mongodb actually is ready to listen on 27017. My error logs show that my node.js script can't find the db on 27017. But if I manually restart the process (after mongodb has had plenty of time to get ready) it works just great.
How can I delay pm2 starting, or delay pm2 starting a particular app until after mongodb is ready and listening for connections?
Note: I tried adding
ExecStartPost=/bin/sh -c 'while ! /usr/bin/mongo --eval "db.version()" > /dev/null 2>&1; do sleep 0.1; done'
To my mongod.service as per this answer: Systemd: Autostart service after mongodb, but that just prevented pm2 from starting at all.
I just ran into this exact same issue and the solution I finally found was to have pm2 also start mongodb. As long as you start mongodb before you start npm and then save the current process list before having pm2 generate the startup script, everything works great.
So, to get pm2 to run mongodb, you need to create a shell script that pm2 can run. This is what my mongod.sh file looks like:
#!/bin/bash
sudo mongod
I put that mongod.sh file in my user directory and then started it and npm with pm2 like so:
pm2 start ~/mongod.sh
pm2 start npm
You can check to make sure both scripts are running with pm2 and in the right order by running
pm2 status
In the process, you should see both mongod and npm running and the id for mongod should be 0 (or just lower than the npm process).
Once I had both mongod and npm running with pm2, I saved the pm2 process list and reset the startup script:
pm2 save
pm2 unstartup
pm2 startup
I have my server on AWS in which I am running the MongoDB but all of the sudden mongod server get stop and showing message Killed. Then I restart the mongod server again but after 10 to 15 minutes mongod server gets stops automatically and showing the same message. This is happening again and again.
My AWS server is t2.small and I am running mongod on the separate screen on the Linux shell and node server on different screen.
The message it is showing is displayed in the image below.
enter image description here
Please help me to make the mongod server running continuously .
You can run mongod in background as a daemon by using fork option and --logpath option.
mongod --fork --logpath /tmp/m.log
More info here
https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/
I'm launching an application and am able to use PM2 to run it however I'm looking at making sure PM2 launches on reboot of the server.
I have two users, root and a user for running the application. The user has sudo privileges.
Currently I am typing this command:
sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u USER --hp /home/USER
and the result:
[ERROR] Exit code : 1
[PM2][ERROR] systemctl start pm2-paul failed, see error above.
When I check jorunalctl for details, I see this:
pm2-user.service: PID file /home/user/.pm2/pm2.pid not readable (yet?) after
start: No such file or directory
Failed to start PM2 process manager.
Any help would be greatly appreciated, I've been struggling for a few hours now with this.
I am trying to run the following command on my ghost node instance running ghost
$ service ghost restart
And I keep getting the following:
"$ ghost stop/waiting ghost start/running, process 1494"
The process number changes depending on when I try and do it. I have looked in the logs and cant find anything?
I have tried using sudo, to no effect.
Please help.
Seems you have a problem with your control script. Try just killing the process manually and then issuing a service start:
# kill -9 1494
or whatever your process id is at the time
I'm getting the following error when I try to run "mongod" in the terminal. I've tried uninstalling, reinstalling, and restarting the machine. Any suggestions on how to get it working would be amazing.
ERROR:
dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
Side note:
Node also stopped working on my machine around the same time that I got this error.
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
Any help would be much appreciated!
This should work to ensure that the directory is set up in the right place so that Mongo can find it:
sudo mkdir -p /data/db/
sudo chown `id -u` /data/db
You need to create the directory on root /data/db or set any other path with the following command :
mongod --dbpath /srv/mongodb/
See the example link
I solved the problem with :
sudo mongod --dbpath=/var/lib/mongodb and then mongo to access the mongodb Shell.
Change the user of the new data directory:
chown mongodb [rute_directory]
And try another time to start the mongo service
service mongod start
I solve the same problem with this.
Daemons (usually ending with d) are normally started as services. Starting the service (daemon) will allow mongodb to work as designed (without permission changes if integrates well with your distro). I start it using the service named mongodb instead of starting mongod directly--on distro with systemd enable on startup then run like:
sudo systemctl enable mongodb
sudo systemctl start mongodb
or, on distro with upstart (if you have /etc/init) or init (if you have /etc/init.d) ( https://www.tecmint.com/systemd-replaces-init-in-linux/ ) instead run:
sudo service mongodb enable
sudo service mongodb start
If you have a distro with rc ("run commands") such as Gentoo (settings in /etc/init.d) (https://forums.gentoo.org/viewtopic-t-854138-start-0.html) run:
rc-update add mongodb default
/etc/init.d/mongodb start
In a distro/version of FreeBSD which still has rc (check whether your version switched to systemd, otherwise see below):
add the following line to /etc/rc.conf:
mongod_enable="YES"
then:
sudo service mongod start
After starting the service, an unpriveleged user can use mongo, and each user will have separate data.
I also got the error that "The file /data/db doesn't exist" when I tried to save my file using the "mkdir -p /data/db" command(using both with and without sudo command). But later on one site, a person named Emil answered that the path "/data/db" no longer works on Mac, so use "~/data/db" instead
i.e., use the command
mkdir -p ~/data/db
instead of previous command.
Moreover, use
mongod --dbpath ~/data/db
to run mongod
It worked for me, hope it work for others too facing the same problem