Mon cas particulier est :
démarrer précédemment mongod par :
sudo -u mongod mongod -f /etc/mongod.conf
maintenant, je veux arrêter mongod
.
et se référer au document officiel Arrêter les processus mongod a essayé :
(1) shutdownServer
mais a échoué :
> use admin
switched to db admin
> db.shutdownServer()
2019-03-06T14:13:15.334+0800 E QUERY [thread1] Error: shutdownServer failed: {
"ok" : 0,
"errmsg" : "shutdown must run from localhost when running db without auth",
"code" : 13
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.shutdownServer@src/mongo/shell/db.js:302:1
@(shell):1:1
(2) --shutdown
a toujours échoué :
# mongod --shutdown
There doesn't seem to be a server running with dbpath: /data/db
(3) la commande de démarrage précédente ajoutant --shutdown :
sudo -u mongod mongod -f /etc/mongod.conf --shutdown
killing process with pid: 30213
failed to kill process: errno:1 Operation not permitted
(4) utiliser service
de s'arrêter :
service mongod stop
et
service mongod status
spectacle attendu Active: inactive (dead)
mais mongod
en fait toujours en cours d'exécution, on peut voir le processus avec ps :
# ps -edaf | grep mongo | grep -v grep
root 30213 1 0 Feb04 ? 03:33:22 mongod --port PORT --dbpath=/var/lib/mongo
et enfin arrêtez vraiment de passer :
# sudo mongod -f /etc/mongod.conf --shutdown
killing process with pid: 30213
jusqu'à présent, Cause profonde : encore inconnue ...
J'espère que la solution ci-dessus vous sera utile.