isdbgrid
This command verifies that a process is a 此命令验证进程是否为mongos
.mongos
。
If you issue the 如果您在连接到isdbgrid
command when connected to a mongos
, the response document includes the isdbgrid
field set to 1
. mongos
时发出isdbgrid
命令,则响应文档包含设置为1
的isdbgrid
字段。The returned document is similar to the following:返回的文档类似于以下内容:
{ "isdbgrid" : 1, "hostname" : "app.example.net", "ok" : 1 }
If you issue the 如果在连接到isdbgrid
command when connected to a mongod
, MongoDB returns an error document. mongod
时发出isdbgrid
命令,MongoDB将返回一个错误文档。The isdbgrid
command is not available to mongod
. isdbgrid
命令对mongod
不可用。The error document, however, also includes a line that reads 然而,错误文档中还包含一行"isdbgrid" : 1
, just as in the document returned for a mongos
. "isdbgrid" : 1
,就像为mongos
返回的文档中一样。The error document is similar to the following:错误文档类似于以下内容:
{ "errmsg" : "no such cmd: isdbgrid", "bad cmd" : { "isdbgrid" : 1 }, "ok" : 0 }
You can instead use the 相反,您可以使用hello
command to determine connection to a mongos
. hello
命令来确定与mongo的连接。When connected to a 当连接到mongos
, the hello
command returns a document that contains the string isdbgrid
in the msg
field.mongos
时,hello
命令返回一个文档,该文档在msg
字段中包含字符串isdbgrid
。