hello

On this page本页内容

Definition定义

hello

New in version 5.0.在版本5.0中新增 (and 4.4.2, 4.2.10, 4.0.21, and 3.6.21)(以及4.4.2、4.2.10、4.0.21和3.6.21)

hello returns a document that describes the role of the mongod instance. 返回描述mongod实例角色的文档。If the optional field saslSupportedMechs is specified, the command also returns an array of SASL mechanisms used to create the specified user's credentials.如果指定了可选字段saslSupportedMechs,则该命令还会返回用于创建指定用户凭据的SASL机制数组

If the instance is a member of a replica set, then hello returns 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 mongod instance that is not a member of a replica set, hello returns a subset of this information.当发送到不是副本集成员的mongod实例时,hello返回该信息的子集。

MongoDB drivers and clients use hello to determine the state of the replica set members and to discover additional members of a replica set.MongoDB驱动程序客户端使用hello来确定副本集成员的状态,并发现副本集的其他成员。

Syntax语法

The command takes the following form:该命令采用以下形式:

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客户端断开连接

Starting in MongoDB 4.2, if the client that issued the hello disconnects before the operation completes, MongoDB marks the hello for termination (i.e. killOp on the operation).从MongoDB 4.2开始,如果发出hello的客户端在操作完成之前断开连接,MongoDB会标记hello以终止(即操作上的killOp)。

Output输出

All Instances所有实例

The following hello fields are common across all roles:以下hello字段在所有角色中都很常见:

hello.isWritablePrimary

A boolean value that reports when this node is writable. 报告此节点何时可写的布尔值。If true, then this instance is a primary in a replica set, or a mongos instance, or a standalone mongod.如果为true,则此实例是副本集中的primarymongos实例或独立mongod

This field will be false if the instance is a secondary member of a replica set or if the member is an arbiter of a replica set.如果实例是副本集的辅助成员,或者该成员是副本集的仲裁器,则此字段将为false

hello.topologyVersion

For internal use by MongoDB.供MongoDB内部使用。

hello.maxBsonObjectSize

The maximum permitted size of a BSON object in bytes for this mongod process. mongod进程允许的BSON对象的最大大小(以字节为单位)。If not provided, clients should assume a max size of "16 * 1024 * 1024".如果未提供,客户端应假定最大大小为“16 * 1024 * 1024”。

hello.maxMessageSizeBytes

The maximum permitted size of a BSON wire protocol message. BSON有线协议消息的最大允许大小。The default value is 48000000 bytes.默认值为48000000字节。

hello.maxWriteBatchSize

The 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,000 writes.此限制的值为100000次写入。

hello.localTime

Returns the local server time in UTC. 返回本地服务器时间(UTC)。This value is an ISO date.此值是ISO日期

hello.logicalSessionTimeoutMinutes

The 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 refreshSessions within this threshold are cleared from the cache. 未从客户端接收到新的读/写操作或使用refreshSessions刷新的会话将从缓存中清除。State associated with an expired session may be cleaned up by the server at any time.服务器可以随时清除与过期会话相关联的状态。

Only available when featureCompatibilityVersion is "3.6" or greater. 仅当featureCompatibilityVersion"3.6"或更高时可用。See Backwards Incompatible Features.请参阅向后不兼容功能

hello.connectionId

An identifier for the mongod/mongos instance's outgoing connection to the client.mongod/mongos实例到客户端的传出连接的标识符。

hello.minWireVersion

The earliest version of the wire protocol that this mongod or mongos instance is capable of using to communicate with clients.mongodmongos实例能够用于与客户端通信的有线协议的最早版本。

Clients may use minWireVersion to help negotiate compatibility with MongoDB.客户端可以使用minWireVersion帮助协商与MongoDB的兼容性。

hello.maxWireVersion

The latest version of the wire protocol that this mongod or mongos instance is capable of using to communicate with clients.mongodmongos实例能够用于与客户端通信的最新版本的有线协议。

Clients may use maxWireVersion to help negotiate compatibility with MongoDB.客户端可以使用maxWireVersion帮助协商与MongoDB的兼容性。

hello.readOnly

A boolean value that, when true, indicates that the mongod or mongos is running in read-only mode.一个布尔值,当为true时,表示mongodmongos正在只读模式下运行。

hello.compression

An array listing the compression algorithms used or available for use (i.e. common to both the client and the mongod or mongos instance) to compress the communication between the client and the mongod or mongos instance.一个数组,列出了用于或可用于压缩客户端和mongodmongos实例之间的通信的压缩算法(即客户端和mongodmongos实例通用)。

The field is only available if compression is used. 该字段仅在使用压缩时可用。For Example:例如:

  • If the mongod is enabled to use both the snappy,zlib compressors and a client has specified zlib, the compression field would contain:如果mongod能够同时使用snappyzlib压缩器,并且客户端指定了zlib,则compression字段将包含:

    "compression": [ "zlib" ]
  • If the mongod is enabled to use both the snappy,zlib compressors and a client has specified zlib,snappy, the compression field would contain:如果mongod能够同时使用snappyzlib压缩器,并且客户端指定了zlib, snappy,则compression字段将包含:

    "compression": [ "zlib", "snappy" ]
  • If the mongod is enabled to use the snappy compressor and a client has specified zlib,snappy, the compression field would contain :如果mongod启用了snappy压缩器,并且客户端指定了zlib, snappy,则compression字段将包含:

    "compression": [ "snappy" ]
  • If the mongod is enabled to use the snappy compressor and a client has specified zlib or 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 mongod or mongos instance, the field does not return.也就是说,如果客户端未指定压缩,或者如果客户端指定未为连接的mongodmongos实例启用压缩程序,则该字段不会返回。

hello.saslSupportedMechs

An array of SASL mechanisms used to create the user's credential or credentials. 用于创建用户凭据的一组SASL机制。Supported SASL mechanisms are:支持的SASL机制包括:

  • GSSAPI
  • SCRAM-SHA-256
  • SCRAM-SHA-1

The field is returned only when the command is run with the saslSupportedMechs field:仅当使用saslSupportedMechs字段运行命令时,才会返回该字段:

db.runCommand( { hello: 1, saslSupportedMechs: "<db.username>" } )

Sharded Instances分片化实例

mongos instances add the following field to the hello response document:实例将以下字段添加到hello响应文档中:

hello.msg

Contains the value isdbgrid when hello returns from a mongos instance.hellomongos实例返回时,包含值isdbgrid

Replica Sets复制集

hello contains these fields when returned by a member of a replica set:副本集成员返回时包含以下字段:

hello.hosts

An 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.passives to determine which members to read from.驱动程序使用此数组和hello.passives来确定要从中读取的成员。

hello.setName

The name of the current :replica set.当前副本集的名称。

hello.setVersion

The current replica set config version.当前副本集配置版本。

hello.secondary

A boolean value that, when true, indicates if the mongod is a secondary member of a replica set.一个布尔值,当为true时,表示mongod是否是副本集次要成员。

hello.passives

An array of strings in the format of "[hostname]:[port]" listing all members of the replica set which have a members[n].priority of 0.格式为"[hostname]:[port]"的字符串数组,列出副本集members[n].priority0的所有成员。

This field only appears if there is at least one member with a members[n].priority of 0.仅当至少有一个成员的members[n].priority0时,才会显示此字段。

Drivers use this array and the hello.hosts to determine which members to read from.驱动程序使用此数组和hello.hosts来确定要读取的成员。

hello.arbiters

An 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.primary

A string in the format of "[hostname]:[port]" listing the current primary member of the replica set.格式为"[hostname]:[port]"的字符串,列出副本集的当前primary成员。

hello.arbiterOnly

A boolean value that , when true, indicates that the current instance is an arbiter. 一个布尔值,当为true时,表示当前实例是仲裁器The arbiterOnly field is only present, if the instance is an arbiter.只有当实例是仲裁器时,arbiterOnly字段才存在。

hello.passive

A boolean value that, when true, indicates that the current instance is passive. 一个布尔值,当为true时,表示当前实例是被动的The passive field is only present for members with a members[n].priority of 0.passive字段仅适用于members[n].priority0的成员。

hello.hidden

A boolean value that, when true, indicates that the current instance is hidden. 一个布尔值,当为true时,表示当前实例已隐藏The hidden field is only present for hidden members.hidden字段仅适用于隐藏成员。

hello.tags

A tags document contains user-defined tag field and value pairs for the replica set member.tags文档包含复制集成员的用户定义标记字段和值对。

{ "<tag1>": "<string1>", "<tag2>": "<string2>",... }

For more information, see Configure Replica Set Tag Sets.有关详细信息,请参阅配置副本集标记集

Tip提示
See also: 参阅:
hello.me

The [hostname]:[port] of the member that returned hello.返回hello的成员的[hostname]:[port]

hello.electionId

A unique identifier for each election. 每个选举的唯一标识符。Included only in the output of hello for the primary. 仅包含在primaryhello的输出中。Used by clients to determine when elections occur.客户端用于确定何时进行选举。

hello.lastWrite

A document containing optime and date information for the database's most recent write operation.包含数据库最近一次写入操作的最佳状态和日期信息的文档。

hello.lastWrite.opTime

An object giving the optime of the last write operation.给出最后一次写入操作optime的对象。

hello.lastWrite.lastWriteDate

A date object containing the time of the last write operation.包含上次写入操作时间的日期对象。

hello.lastWrite.majorityOpTime

An object giving the optime of the last write operation readable by majority reads.一种对象,它给出了majority读操作所能读取的最后一次写入操作的optime

hello.lastWrite.majorityWriteDate

A date object containing the time of the last write operation readable by majority reads.一个日期对象,包含majority读操作可读取的最后一次写入操作的时间。

For details on the ok status field, the operationTime field, and the $clusterTime field, see Command Response.有关ok状态字段、operationTime字段和$clusterTime字段的详细信息,请参阅命令响应

←  applyOpsreplSetAbortPrimaryCatchUp →