Mongodb disable option not available

My current problem: I have a production server and just updated mongod, but lost some functionality.

In earlier versions ( v2.0.6 ), I was able to run mongod with the --shutdown option and it will kill all other instances.

Now with version v2.4.5 - if I run:

 mongod --shutdown 

Result:

 error command line: unknown option shutdown use --help for help 

Version Information: mongod --version

 db version v2.4.5 Mon Sep 16 14:09:38.994 git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b 


It is important that I have this option or something similar, because I have a server process managing a new instance.

For instance:

 var spawn = require('child_process').spawn, result = spawn('mongod', ['--quiet', '--shutdown', '--directoryperdb', '--dbpath', __dirname + '/database']); 


Edit:
The Mongodb documentation still has the --shutdown option.
Link: http://docs.mongodb.org/manual/tutorial/manage-mongodb-processes/

 Alternately, you can shut down the mongod instance: using the --shutdown option from a driver using the shutdown. For details, see the drivers documentation for your driver. 


Edit:
<B> I felt I should update this question. This problem has been fixed in the mongojs shell version v.9.6. However, there are still some kinks that will be developed as outlined in issue # 97 , but should work for most requirements.

+4
source share
3 answers

Have you tried using db.shutdownServer () in mongo shell?

From the documentation:

To stop a mongod instance running in the background or foreground, issue the db.shutdownServer () helper in the mongo shell. Use the following sequence:

To open the mongo shell for the mongod instance running by default on port 27017, run the following command:

 mongo 

To switch to the administrator database and close the mongod instance, run the following commands:

 use admin db.shutdownServer() 

You can only use db.shutdownServer () when connecting to mongod, when it is authenticated in the administrator database or on systems without authentication connected via the localhost interface.


In your comments, you can do the same by running the shutdown command against the admin database in the driver:

 {shutdown : 1} 

I am not familiar with the node.js driver, but you have two options for running commands in the drivers as a whole, and you should always work:

  • Use the driver shell for runCommand (which you can use in the mongo shell, for example :)

    db.runCommand ({shutdown: 1});

  • Use the $cmd built-in pseudo-collection to run your commands. Wrappers for commands actually use this method, and if you have no other parameters, you can run queries against $ cmd to shut down the server:

    db $ cmd.findOne ({"shutdown": 1}).

If you are not using the driver, you can use the REST interface if you opened it (use the --rest line command when starting mongod ). By executing a POST request, you can run commands in the administrator database:

 http://localhost:28017/admin/$cmd/?filter_shutdown=1&limit=1 

which is equivalent to executing a previous request with $cmd .

+1
source

Since the "-shutdown" option is not available in new versions of mongo, now you need to kill the process manually or log in and run:

 use admin; db.shutdownServer(); 

However, you can do this on a single line by doing:

 mongo 127.0.0.1/admin --eval "db.shutdownServer()" 

Assuming you are connecting to a local DB at 127.0.0.1. You can only run one line with the --eval param parameter, so use admin; db.shutdownServer(); use admin; db.shutdownServer(); is not an option, however you can connect to the db administrator by adding that "/ admin" after the IP.

+8
source

If someone else found this command through a tutorial while running OS X, this command is only available on Linux machines and not available on OS X (see http://docs.mongodb.org/manual/reference/program/mongod/# cmdoption - shutdown , where this is explicitly indicated). I'm not sure if this happened with the original poster, but hope this helps someone.

+2
source

Source: https://habr.com/ru/post/1502481/


All Articles