您可以使用 Ops Manager API来关闭、启动、重启和重新同步 MongoDB 进程。每次请求都会更新自动化配置中的进程,并立即发布更改。目标主机的自动化代理会在下次签入时应用此更改。如果该进程是当前主进程,代理会先将其降级,以便其他成员可以接管,然后再停止或重启它。
Each operation is asynchronous. A 200 OK response means Ops Manager published the change, not that the process has stopped, started, restarted, or resynced. The response includes no job ID. To follow the change to completion, poll the automation status resource. If the agent can't apply the change, the plan shows as failed there and the agent keeps retrying.
Every endpoint accepts an optional dryRun=true query parameter. Use it to preview a change before you apply it. Ops Manager runs all the same checks and returns the process document as it would look after the change, but sends nothing to the agent and changes nothing in your deployment. For example, after a shutdown the returned document contains "disabled": true. Review it, then send the same request without dryRun=true to apply the change.
先决条件
在使用流程生命周期资源之前,请先查看以下要求。
注意
注意:群组和项目是同义词。您的 {PROJECT-ID} 与您的项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。当引用说明时,此页面将使用“群组”这个更为人熟知的术语。终结点仍如文档中所述。
基本 URL: https://{OPSMANAGER-HOST}:{PORT}/api/public/v1.0
To use the Process Lifecycle resources, you must be an Ops Manager user with the Project Automation Admin role.
Your deployment must run Ops Manager 8.0.28 or 9.0.2 or later. Automation must be enabled for the project, and the target host's Automation Agent must be running.
If you have an unpublished automation configuration draft in the project, Ops Manager rejects every request, including a dry run, with a 409 AUTOMATION_CONFIG_DRAFT_ALREADY_EXISTS error. Publish or discard the draft before you continue.
所有验证也适用于模拟运行,因此成功的模拟运行预示着实际请求也能通过相同的检查。但实际请求仍然可能因并发变更或手动模式验证而失败。
重要
外部管理的项目或 Kubernetes Operator (MCK) 部署不支持流程生命周期操作。
警告
这些端点不提供仲裁保护。关闭副本集中过多的成员会导致副本集缺少主节点。请一次关闭一个成员,并等待每个成员停止运行后再继续。
端点
下表列出了流程生命周期资源可用的端点。
方法 | 端点 | 说明 |
|---|---|---|
| 优雅地停止正在运行的进程。 | |
| 启动之前已关闭的进程。 | |
| 优雅地重启正在运行的进程。 | |
| 触发副本集成员的初始同步。 |
审核记录
每次成功请求(非试运行)都会在项目活动流中添加一个事件,与常规的自动化配置发布事件并列。活动流会将通过API发出的请求归类到公共 API。
操作 | 事件类型 | 它告诉您什么 |
|---|---|---|
| 已对此进程发出关闭请求。如果某个成员意外离线,请检查此事件。 | |
| 已提出启动已停止进程的请求。 | |
| 已为此进程发出重启请求。请检查此事件,确认是否有成员短暂退出或发生了选举。 | |
| A resync request was made for this process. Check this event if a member went into |