On this page本页内容
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 MongoDB驱动程序和客户端使用hello
to determine the state of the replica set members and to discover additional members of a replica set.hello
来确定副本集成员的状态,并发现副本集的其他成员。
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
的包装。
Starting in MongoDB 4.2, if the client that issued the 从MongoDB 4.2开始,如果发出hello
disconnects before the operation completes, MongoDB marks the hello
for termination (i.e. killOp
on the operation).hello
的客户端在操作完成之前断开连接,MongoDB会标记hello
以终止(即操作上的killOp
)。
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
,则此实例是副本集中的primary、mongos
实例或独立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.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.mongod
或mongos
实例能够用于与客户端通信的有线协议的最早版本。
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.mongod
或mongos
实例能够用于与客户端通信的最新版本的有线协议。
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
时,表示mongod
或mongos
正在只读模式下运行。
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.mongod
或mongos
实例之间的通信的压缩算法(即客户端和mongod
或mongos
实例通用)。
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
能够同时使用snappy
和zlib
压缩器,并且客户端指定了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
能够同时使用snappy
、zlib
压缩器,并且客户端指定了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" ]
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.mongod
或mongos
实例启用压缩程序,则该字段不会返回。
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>" } )
mongos
instances add the following field to the 实例将以下字段添加到hello
response document:hello
响应文档中:
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.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].priority
为0
的所有成员。
This field only appears if there is at least one member with a 仅当至少有一个成员的members[n].priority
of 0
.members[n].priority
为0
时,才会显示此字段。
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].priority
为0
的成员。
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>",... }
settings.getLastErrorModes
and settings.getLastErrorDefaults
.settings.getLastErrorModes
和settings.getLastErrorDefaults
创建自定义写入关注。For more information, see Configure Replica Set Tag Sets.有关详细信息,请参阅配置副本集标记集。
hello.electionId
A unique identifier for each election. 每个选举的唯一标识符。Included only in the output of 仅包含在primary的hello
for the primary. hello
的输出中。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.lastWriteDate
A date object containing the time of the last write operation.包含上次写入操作时间的日期对象。
For details on the 有关ok
status field, the operationTime
field, and the $clusterTime
field, see Command Response.ok
状态字段、operationTime
字段和$clusterTime
字段的详细信息,请参阅命令响应。