对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。

使用公共 API 启动流程

注意

注意:群组和项目是同义词。您的 {PROJECT-ID} 与您的项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。当引用说明时,此页面将使用“群组”这个更为人熟知的术语。终结点仍如文档中所述。

Use this endpoint to start a process that was previously shut down. Ops Manager sets disabled to false for the process in the automation configuration and publishes the change.

The request is asynchronous: 200 OK means Ops Manager published the change, not that the process is running. Poll the automation status resource until the plan completes. Then confirm that the member's replicaStateName on the v2.0 Get One Host by ID endpoint returns to SECONDARY or PRIMARY.

If the process is already running, nothing changes and the agent takes no action, but Ops Manager still publishes the configuration and records the event. If the oplog rolled over while the process was down, the member stays in RECOVERING and doesn't resync on its own. Use Resync a Process instead.

基本 URL: https://{OPSMANAGER-HOST}:{PORT}/api/public/v1.0

POST /groups/{GROUP-ID}/process/{HOST-PORT}:startup

The API key that makes this request must have the Project Automation Admin role.

名称
类型
必要性
说明

群组 ID(group ID)

字符串

必需

标识项目的唯一 24 位十六进制数字字符串。

托管-端口

字符串

必需

Target process, as hostname:port. For example, node1.example.com:27017.

名称
类型
必要性
说明
默认

干运行

布尔

Optional

If true, Ops Manager validates the request and returns the changed process without publishing it or adding an activity feed event. Ops Manager rejects any value other than true or false with 400 INVALID_QUERY_PARAMETER.

false

以下查询参数为可选参数:

名称
类型
必要性
说明
默认

pretty

布尔

Optional

指示响应正文是否采用 pretty-print 格式的标志。

false

envelope

布尔

Optional

指示是否将响应包装在信封中的标志。

某些 API 客户端无法访问 HTTP 响应标头或状态代码。要解决这个问题,可在查询中设置 envelope=true。

对于返回一个结果的端点,响应体包括:

  • status: HTTP 响应代码

  • content:预期响应正文

false

此端点不使用 HTTP 请求正文参数。

Ops Manager returns 200 OK and the target process as it appears in the automation configuration, with the change applied. disabled is false. The body is the same whether you set dryRun or not.

名称
类型
说明

名称

字符串

自动化配置中的流程名称。

主机名

字符串

进程的主机名。

处理类型

字符串

Type of process, for example mongod.

版本

字符串

该流程的 MongoDB 版本。

残疾人

布尔

true 如果进程被关闭。

lastRestart

字符串

Timestamp, in ISO 8601 UTC format, of the last requested restart.

lastResync

字符串

Timestamp, in ISO 8601 UTC format, of the last requested resync.

The document also contains the rest of the process's automation configuration, such as args2_6, featureCompatibilityVersion, and authSchemaVersion. See the Automation Configuration reference.

The following example starts the process running on node1.example.com:27017.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \ --include \ --request POST "https://<OpsManagerHost>:<Port>/api/public/v1.0/groups/{GROUP-ID}/process/node1.example.com:27017:startup?pretty=true"
HTTP/1.1 401 UnauthorizedContent-Type: application/json;charset=ISO-8859-1Date: {dateInUnixFormat}WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=falseContent-Length: {requestLengthInBytes}Connection: keep-alive
HTTP/1.1 200 OKVary: Accept-EncodingContent-Type: application/jsonStrict-Transport-Security: max-age=300Date: {dateInUnixFormat}Connection: keep-aliveContent-Length: {requestLengthInBytes}X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion}
{ "name": "rs0_1", "processType": "mongod", "version": "8.0.4", "hostname": "node1.example.com", "disabled": false, "authSchemaVersion": 5, "featureCompatibilityVersion": "8.0", "args2_6": { "net": { "port": 27017 }, "replication": { "replSetName": "rs0" }, "storage": { "dbPath": "/data/rs0_1" }, "systemLog": { "destination": "file", "path": "/data/rs0_1/mongodb.log" } }}
HTTP Status
错误代码
说明

200

--

The change was published, or computed with dryRun=true. Returns the process document.

400

--

流程处于手动模式,或者自动化配置验证失败。该消息解释了原因。未返回进行试运行。

409

组处于恢复模式

项目在恢复后正在进行协调。

403

流程外部管理

该项目的流程由外部系统管理。

409

AUTOMATION_CONFIG_DRAFT_ALREADY_EXISTS

项目中有一个尚未发布的自动化配置草稿。

404

进程未找到

HOST-PORT 与项目自动化配置中的流程不匹配。

400

无效查询参数

dryRun isn't true or false.

409

AUTOMATION_CONFIG_CONCURRENT_MODIFICATION

请求处理期间,有人发布了更改。运维管理器仅在收到真实请求时才会返回此代码。

运维经理会按列出的顺序检查共享错误。有关前提条件和限制,请参阅流程生命周期。