Can't do db.shutdownServer()

Hi,

Is the following supposed to work? I am getting “errmsg” : “there are no users authenticated”. Or was the user not created? At the moment, I am doing mongod --shutdown instead. Please advise.

use admin
db.shutdownServer()
quit()

vagrant@m103:~ vagrant@m103:~ ps -ef | grep mongo
vagrant 3483 1506 0 05:07 pts/0 00:00:04 mongod --config /home/vagrant/config/config_lab.txt
vagrant 3676 1595 0 05:15 pts/1 00:00:00 grep --color=auto mongo
vagrant@m103:~ mongo --port 27000 MongoDB shell version v3.6.12 connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("c5c399c8-ebe1-46b6-b2ae-5301fe8b66ca") } MongoDB server version: 3.6.12 MongoDB Enterprise > use admin switched to db admin MongoDB Enterprise > db.shutdownServer() 2019-04-15T05:16:04.716+0000 E QUERY [thread1] Error: shutdownServer failed: { "ok" : 0, "errmsg" : "there are no users authenticated", "code" : 13, "codeName" : "Unauthorized" } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DB.prototype.shutdownServer@src/mongo/shell/db.js:453:1 @(shell):1:1 MongoDB Enterprise > quit function quit() { [native code] } MongoDB Enterprise > quit() vagrant@m103:~ mongod --config ~/config/config_lab.txt --shutdown
killing process with pid: 3483
vagrant@m103:~ ps -ef | grep mongo vagrant 3686 1595 0 05:16 pts/1 00:00:00 grep --color=auto mongo vagrant@m103:~
vagrant@m103:~$

Sorry just noted I need to use -u and -p.

I can now do a shutdown using mongos. But are the following messages normal or as expected?

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.shutdownServer()
server should be down…
2019-04-15T05:58:47.069+0000 I NETWORK [thread1] trying reconnect to 127.0.0.1:27000 (127.0.0.1) failed
2019-04-15T05:58:47.071+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused
2019-04-15T05:58:47.071+0000 I NETWORK [thread1] reconnect 127.0.0.1:27000 (127.0.0.1) failed failed
MongoDB Enterprise > exit
bye
2019-04-15T05:59:03.500+0000 I NETWORK [thread1] trying reconnect to 127.0.0.1:27000 (127.0.0.1) failed
2019-04-15T05:59:03.501+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused
2019-04-15T05:59:03.501+0000 I NETWORK [thread1] reconnect 127.0.0.1:27000 (127.0.0.1) failed failed
2019-04-15T05:59:03.502+0000 I QUERY [thread1] Failed to end session { id: UUID(“e7d96f50-22ff-4b01-9a29-c774d7316fc1”) } due to SocketException: socket exception [CONNECT_ERROR] for couldn’t connect to server 127.0.0.1:27000, connection attempt failed
vagrant@m103:~$

Yes it means the server is shutting down. And if you don’t exit the terminal, it will try to reconnect but will fail.

Execute quit() command to get out of the mongo shell.

Kanika