注意
注意:群组和项目是同义词。您的 {PROJECT-ID} 与您的项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。当引用说明时,此页面将使用“群组”这个更为人熟知的术语。终结点仍如文档中所述。
Use this endpoint to gracefully restart a running process. Ops Manager sets lastRestart for the process in the automation configuration and publishes the change. If the process is the current primary, the Automation Agent steps it down before it restarts the process.
The request is asynchronous: 200 OK means Ops Manager published the change, not that the process has restarted. Poll the automation status resource until the plan completes.
The restart endpoint returns 400 PROCESS_DISABLED_CANNOT_RESTART for a process that is shut down. To start it, use Start a Process instead.
基本 URL: https://{OPSMANAGER-HOST}:{PORT}/api/public/v1.0
Resource
POST /groups/{GROUP-ID}/process/{HOST-PORT}:restart所需角色
The API key that makes this request must have the Project Automation Admin role.
请求路径参数
名称 | 类型 | 必要性 | 说明 |
|---|---|---|---|
群组 ID(group ID) | 字符串 | 必需 | 标识项目的唯一 24 位十六进制数字字符串。 |
托管-端口 | 字符串 | 必需 | Target process, as |
请求查询参数
名称 | 类型 | 必要性 | 说明 | 默认 |
|---|---|---|---|---|
干运行 | 布尔 | Optional | If |
|
以下查询参数为可选参数:
名称 | 类型 | 必要性 | 说明 | 默认 |
|---|---|---|---|---|
pretty | 布尔 | Optional | 指示响应正文是否采用 pretty-print 格式的标志。 |
|
envelope | 布尔 | Optional | 指示是否将响应包装在信封中的标志。 某些 API 客户端无法访问 HTTP 响应标头或状态代码。要解决这个问题,可在查询中设置 envelope=true。 对于返回一个结果的端点,响应体包括:
|
|
请求正文参数
此端点不使用 HTTP 请求正文参数。
响应
Ops Manager returns 200 OK and the target process as it appears in the automation configuration, with the change applied. lastRestart is set. The body is the same whether you set dryRun or not.
名称 | 类型 | 说明 |
|---|---|---|
名称 | 字符串 | 自动化配置中的流程名称。 |
主机名 | 字符串 | 进程的主机名。 |
处理类型 | 字符串 | Type of process, for example |
版本 | 字符串 | 该流程的 MongoDB 版本。 |
残疾人 | 布尔 |
|
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 restarts 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:restart?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-aliveHTTP/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, "lastRestart": "2026-10-06T09:15:20Z", "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 |
400 | 进程已禁用,无法重启 | 该进程已关闭。请重新启动它。 |
409 | 进程代理未报告 | 目标主机的自动化代理从未向运维管理器报告过。 |
409 | 组处于恢复模式 | 项目在恢复后正在进行协调。 |
403 | 流程外部管理 | 该项目的流程由外部系统管理。 |
409 | AUTOMATION_CONFIG_DRAFT_ALREADY_EXISTS | 项目中有一个尚未发布的自动化配置草稿。 |
404 | 进程未找到 |
|
400 | 无效查询参数 |
|
409 | AUTOMATION_CONFIG_CONCURRENT_MODIFICATION | 请求处理期间,有人发布了更改。运维管理器仅在收到真实请求时才会返回此代码。 |
运维经理会按列出的顺序检查共享错误。有关前提条件和限制,请参阅流程生命周期。