Definition定义
helloNew in version 4.2.在版本4.2中新增。helloreturns a document that describes the role of the返回一个描述mongodinstance.mongod实例角色的文档。If the optional field如果指定了可选字段saslSupportedMechsis specified, the command also returns anarray of SASL mechanismsused to create the specified user's credentials.saslSupportedMechs,则该命令还将返回用于创建指定用户凭据的SASL机制数组。If the instance is a member of a replica set, then如果实例是副本集的成员,则helloreturns a subset of the replica set configuration and status including whether or not the instance is the primary of the replica set.hello将返回副本集配置和状态的子集,包括实例是否是副本集中的primary。When sent to a当发送到不是副本集成员的mongodinstance that is not a member of a replica set,helloreturns a subset of this information.mongod实例时,hello会返回此信息的子集。MongoDB drivers and clients useMongoDB驱动程序和客户端使用helloto determine the state of the replica set members and to discover additional members of a replica set.hello来确定副本集成员的状态,并发现副本集的其他成员。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
Note
This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令。
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
hello: 1
}
)
The hello command accepts optional fields saslSupportedMechs: <db.user> to return an additional field hello.saslSupportedMechs in its result and comment <any> to add a log comment associated with the command.hello命令接受可选字段saslSupportedMechs: <db.user>以在其结果中返回额外的字段hello.saslSupportedMechs,并接受comment <any>以添加与该命令关联的日志注释。
db.runCommand(
{
hello: 1,
saslSupportedMechs: "<db.username>",
comment: <any>
}
)
The db.hello() method in mongosh provides a wrapper around hello.mongosh中的db.hello()方法为hello提供了一个包装器。
Behavior行为
Client Disconnection客户端断开连接
If the client that issued 如果发出hello disconnects before the operation completes, MongoDB marks hello for termination using killOp.hello的客户端在操作完成之前断开连接,MongoDB将使用killOp标记hello以终止。
Output输出
All Instances所有实例
The following 以下hello fields are common across all roles:hello字段在所有角色中都很常见:
hello.isWritablePrimaryA boolean value that reports when this node is writable.一个布尔值,用于报告此节点何时可写。If如果为true, then this instance is a primary in a replica set, or amongosinstance, or a standalonemongod.true,则此实例是副本集中的primary、mongos实例或独立mongod。This field will be如果该实例是副本集的次要成员,或者该成员是副本集中的仲裁器,则此字段将为falseif the instance is a secondary member of a replica set or if the member is an arbiter of a replica set.false。
hello.topologyVersionFor internal use by MongoDB.供MongoDB内部使用。
hello.maxBsonObjectSizeThe maximum permitted size of a BSON object in bytes for this此mongodprocess. If not provided, clients should assume a max size of "16 * 1024 * 1024".mongod进程允许的BSON对象的最大大小(以字节为单位)。如果没有提供,客户端应假设最大大小为“16*1024*1024”。
hello.maxMessageSizeBytesThe maximum permitted size of a BSON wire protocol message. The default value isBSON有线协议消息的最大允许大小。默认值为48000000bytes.48000000字节。
hello.maxWriteBatchSizeThe maximum number of write operations permitted in a write batch. If a batch exceeds this limit, the client driver divides the batch into smaller groups each with counts less than or equal to the value of this field.写入批处理中允许的最大写入操作数。如果批次超过此限制,客户端驱动程序会将批次分成更小的组,每组的计数小于或等于此字段的值。The value of this limit is此限制的值为100,000writes.100000次写入。
hello.localTimeReturns the local server time in UTC. This value is an ISO date.返回以UTC为单位的本地服务器时间。此值是ISO日期。
hello.logicalSessionTimeoutMinutesThe time in minutes that a session remains active after its most recent use.会话在最近一次使用后保持活动状态的时间(分钟)。Sessions that have not received a new read/write operation from the client or been refreshed with未从客户端接收到新的读/写操作或在此阈值内使用refreshSessionswithin this threshold are cleared from the cache. State associated with an expired session may be cleaned up by the server at any time.refreshSessions刷新的会话将从缓存中清除。服务器可以随时清理与过期会话相关联的状态。Only available when仅当featureCompatibilityVersionis"3.6"or greater.featureCompatibilityVersion为"3.6"或更高版本时可用。
hello.connectionIdAn identifier for themongod/mongosinstance's outgoing connection to the client.mongod/mongos实例到客户端的传出连接的标识符。
hello.minWireVersionThe earliest version of the wire protocol that this此mongodormongosinstance is capable of using to communicate with clients.mongod或mongos实例能够用于与客户端通信的最早版本的有线协议。Clients may use客户端可以使用minWireVersionto help negotiate compatibility with MongoDB.minWireVersion来帮助协商与MongoDB的兼容性。
hello.maxWireVersionThe latest version of the wire protocol that this此mongodormongosinstance is capable of using to communicate with clients.mongod或mongos实例能够用于与客户端通信的最新版本的有线协议。Clients may use客户端可以使用maxWireVersionto help negotiate compatibility with MongoDB.maxWireVersion来帮助协商与MongoDB的兼容性。
hello.readOnlyA boolean value that, when一个布尔值,当为true, indicates that themongodormongosis running in read-only mode.true时,表示mongod或mongos正在以只读模式运行。
hello.compressionAn array listing the compression algorithms used or available for use (i.e. common to both the client and the一个数组,列出了用于压缩客户端和mongodormongosinstance) to compress the communication between the client and themongodormongosinstance.mongod或mongos实例之间通信的压缩算法(即客户端和mongood或mongos实例共有的压缩算法)。The field is only available if compression is used. For example:该字段仅在使用压缩时可用。例如:If the如果mongodis enabled to use both thesnappy,zlibcompressors and a client has specifiedzlib, thecompressionfield would contain:mongod启用了snappy和zlib压缩器,并且客户端指定了zlib,则压缩字段将包含:"compression": [ "zlib" ]If the如果mongodis enabled to use both thesnappy,zlibcompressors and a client has specifiedzlib,snappy, thecompressionfield would contain:mongod启用了snappy,zlib压缩器,并且客户端指定了snappy,zlib,则compression字段将包含:"compression": [ "zlib", "snappy" ]If the如果mongodis enabled to use thesnappycompressor and a client has specifiedzlib,snappy, thecompressionfield would contain :mongod启用了snappy压缩器,并且客户端指定了zlib,snappy,则compression字段将包含:"compression": [ "snappy" ]If the如果启用了mongodis enabled to use thesnappycompressor and a client has specifiedzlibor the client has specified no compressor, the field is omitted.mongod来使用snappy压缩器,并且客户端指定了zlib,或者客户端没有指定压缩器,则省略该字段。
That is, if the client does not specify compression or if the client specifies a compressor not enabled for the connected也就是说,如果客户端没有指定压缩,或者客户端指定了一个未为连接的mongodormongosinstance, the field does not return.mongod或mongos实例启用的压缩器,则该字段不会返回。
hello.saslSupportedMechsAn array of SASL mechanisms used to create the user's credential or credentials. Supported SASL mechanisms are:一系列用于创建用户凭据的SASL机制。支持的SASL机制包括:GSSAPISCRAM-SHA-256SCRAM-SHA-1
The field is returned only when the command is run with the仅当使用saslSupportedMechsfield:saslSupportedMechs字段运行命令时,才会返回该字段:db.runCommand( { hello: 1, saslSupportedMechs: "<db.username>" } )
Sharded Instances分片实例
mongos instances add the following field to the 实例将以下字段添加到hello response document:hello响应文档中:
hello.msgContains the value包含从isdbgridwhenhelloreturns from amongosinstance.mongos实例返回hello时的值isdbgrid。
Replica Sets复制集
hello contains these fields when returned by a member of a replica set:当副本集的成员返回时,包含以下字段:
hello.hostsAn array of strings in the format of一个字符串数组,格式为"[hostname]:[port]"that lists all members of the replica set that are neither hidden, passive, nor arbiters."[hostname]:[port]",列出了副本集中既不是隐藏的、被动的也不是仲裁器的所有成员。Drivers use this array and the驱动程序使用此数组和hello.passivesto determine which members to read from.hello.passives来确定从哪些成员读取。
hello.setNameThe name of the current :replica set.当前副本集的名称。
hello.setVersionThe current replica set config version.当前副本集配置版本。
hello.secondaryA boolean value that, when一个布尔值,当为true, indicates if themongodis a secondary member of a replica set.true时,表示mongod是否是副本集的次要成员。
hello.passivesAn array of strings in the format of一个字符串数组,格式为"[hostname]:[port]"listing all members of the replica set which have amembers[n].priorityof0."[hostname]:[port]",列出了副本集中members[n].priority为0的所有成员。This field only appears if there is at least one member with a仅当至少有一个members[n].priorityof0.members[n].priority为0时,才会显示此字段。Drivers use this array and the驱动程序使用此数组和hello.hoststo determine which members to read from.hello.hosts来确定从哪些成员读取。
hello.arbitersAn array of strings in the format of一个字符串数组,格式为"[hostname]:[port]"listing all members of the replica set that are arbiters."[hostname]:[port]",列出了副本集中作为仲裁器的所有成员。This field only appears if there is at least one arbiter in the replica set.仅当副本集中至少有一个仲裁器时,才会显示此字段。
hello.primaryA string in the format of一个格式为"[hostname]:[port]"listing the current primary member of the replica set."[hostname]:[port]"的字符串,列出了副本集的当前primary成员。
hello.arbiterOnlyA boolean value that , when一个布尔值,当为true, indicates that the current instance is an arbiter. ThearbiterOnlyfield is only present, if the instance is an arbiter.true时,表示当前实例是仲裁器。只有当实例是仲裁器时,arbiterOnly字段才存在。
hello.passiveA boolean value that, when一个布尔值,当为true, indicates that the current instance is passive.true时,表示当前实例是被动的。Thepassivefield is only present for members with amembers[n].priorityof0.passive字段仅适用于members[n].priority为0的成员。
hello.hiddenA boolean value that, when一个布尔值,当为true, indicates that the current instance is hidden. Thehiddenfield is only present for hidden members.true时,表示当前实例已隐藏。hidden字段仅对隐藏成员存在。
hello.tagsAtagsdocument contains user-defined tag field and value pairs for the replica set member.tags文档包含用户定义的标记字段和副本集成员的值对。{ "<tag1>": "<string1>", "<tag2>": "<string2>",... }For read operations, you can specify a tag set in the read preference to direct the operations to replica set member(s) with the specified tag(s).对于读取操作,您可以在读取首选项中指定一个标记集,以将操作定向到具有指定标记的副本集成员。For write operations, you can create a customize write concern using对于写入操作,您可以使用settings.getLastErrorModesandsettings.getLastErrorDefaults.settings.getLastErrorModes和settings.getLastErrorDefaults创建自定义写入关注。
For more information, see Configure Replica Set Tag Sets.有关详细信息,请参阅配置副本集标记集。Tip
hello.meThe返回[hostname]:[port]of the member that returnedhello.hello的成员的[hostname]:[port]。
hello.electionIdA unique identifier for each election. Included only in the output of每次选举的唯一标识符。仅包含在primary的hellofor the primary. Used by clients to determine when elections occur.hello输出中。客户使用它来确定选举何时发生。
hello.lastWriteA document containing optime and date information for the database's most recent write operation.包含数据库最近写入操作的最佳值和日期信息的文档。hello.lastWrite.opTimeAn object giving the optime of the last write operation.给出上次写入操作optime(最优值)的对象。
hello.lastWrite.lastWriteDateA date object containing the time of the last write operation.包含上次写入操作时间的日期对象。
hello.lastWrite.majorityOpTimeAn object giving the optime of the last write operation readable by一个对象,给出majorityreads.majority读取可读的最后一次写入操作的optime(最优值)。
hello.lastWrite.majorityWriteDateA date object containing the time of the last write operation readable by一个日期对象,包含majorityreads.majority读取可读的最后一次写入操作的时间。
For details on the 有关ok status field, the operationTime field, and the $clusterTime field, see Command Response.ok状态字段、operationTime字段和$clusterTime字段的详细信息,请参阅命令响应。