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。