许可证API
edit许可证API
edit您可以使用以下API来管理您的许可证:
删除许可证 API
edit此API使您能够删除许可信息。
请求
editDELETE /_license
描述
edit当您的许可证过期时,X-Pack 将以降级模式运行。更多信息,请参阅 许可证过期。
获取许可证 API
edit此API使您能够检索许可证信息。
请求
editGET /_license
描述
edit此API返回有关许可证类型的信息,例如何时颁发以及何时到期。
有关不同类型许可证的更多信息,请参阅 https://www.elastic.co/subscriptions。
如果主节点正在生成新的集群状态,获取许可证API可能会返回404 Not Found响应。如果在集群启动后收到意外的404响应,请等待片刻并重试请求。
查询参数
edit-
local -
(布尔值) 指定是否检索本地信息。默认值为
false,这意味着信息是从主节点检索的。 -
accept_enterprise -
(布尔值) 如果为
true,此参数返回enterprise表示企业版许可证类型。如果为false,此参数对platinum和enterprise许可证类型都返回platinum。此行为是为了向后兼容而保留的。
在7.6.0版本中已弃用。
此参数已弃用,在8.x中将始终设置为true。
授权
edit您必须拥有 monitor 集群权限才能使用此 API。
有关更多信息,请参阅 安全权限。
示例
edit以下示例提供了有关试用许可证的信息:
GET /_license
{
"license" : {
"status" : "active",
"uid" : "cbff45e7-c553-41f7-ae4f-9205eabd80xx",
"type" : "trial",
"issue_date" : "2018-10-20T22:05:12.332Z",
"issue_date_in_millis" : 1540073112332,
"expiry_date" : "2018-11-19T22:05:12.332Z",
"expiry_date_in_millis" : 1542665112332,
"max_nodes" : 1000,
"max_resource_units" : null,
"issued_to" : "test",
"issuer" : "elasticsearch",
"start_date_in_millis" : -1
}
}
获取试用状态 API
edit使您能够检查您的试用状态。
请求
editGET /_license/trial_status
描述
edit如果您想尝试所有订阅功能,您可以开始30天的试用。
仅当您的集群尚未为当前主要产品版本激活试用时,您才可以启动试用。例如,如果您已经为 v6.0 激活了试用,则在 v7.0 之前您无法开始新的试用。不过,您可以在 https://www.elastic.co/trialextension 申请延长试用。
有关功能和订阅的更多信息,请参阅 https://www.elastic.co/subscriptions。
开始试用 API
edit开始30天试用。
请求
editPOST /_license/start_trial
描述
editThe start trial API 使您能够开始一个30天的试用期,该试用期提供所有订阅功能的使用权限。
仅当您的集群尚未为当前主要产品版本激活试用时,您才可以启动试用。例如,如果您已经为 v6.0 激活了试用,则在 v7.0 之前您无法开始新的试用。不过,您可以在 https://www.elastic.co/trialextension 申请延长试用。
要检查您的试用状态,请使用获取试用状态。
有关功能和订阅的更多信息,请参阅 https://www.elastic.co/subscriptions。
获取基本状态 API
edit此API使您能够检查您的基本许可证的状态。
请求
editGET /_license/basic_status
描述
edit为了启动基本许可证,您当前不能拥有基本许可证。
有关不同类型许可证的更多信息,请参阅 https://www.elastic.co/subscriptions。
开始基本 API
edit此API启动一个无限期的基本许可证。
请求
editPOST /_license/start_basic
描述
editThe start basic API 使您能够启动一个无限期的基本许可证,该许可证提供对所有基本功能的访问。然而,如果基本许可证不支持当前许可证中的所有功能,您将在响应中收到通知。然后,您必须重新提交 API 请求,并将 acknowledge 参数设置为 true。
要检查您的基本许可证状态,请使用以下 API: 获取基本状态。
有关不同类型许可证的更多信息,请参阅 https://www.elastic.co/subscriptions。
授权
edit您必须拥有 manage 集群权限才能使用此 API。
有关更多信息,请参阅
安全权限。
示例
edit以下示例在没有当前许可证的情况下启动基本许可证:
POST /_license/start_basic
示例响应:
{
"basic_was_started": true,
"acknowledged": true
}
以下示例在您当前拥有比基本许可证更多功能的许可证时,启动一个基本许可证。由于您正在失去功能,因此必须传递acknowledge参数:
POST /_license/start_basic?acknowledge=true
示例响应:
{
"basic_was_started": true,
"acknowledged": true
}
更新许可证 API
edit更新您的 Elasticsearch 集群的许可证。
先决条件
edit-
如果启用了Elasticsearch安全功能,您需要
manage集群权限来安装许可证。 - 如果启用了Elasticsearch安全功能并且您正在安装黄金或更高级别的许可证,您必须在安装许可证之前在传输网络层启用TLS。请参阅使用TLS加密节点间通信。
- 如果启用了操作员权限功能,只有操作员用户可以使用此API。
描述
edit您可以在不关闭节点的情况下在运行时更新许可证。许可证更新会立即生效。但是,如果您安装的许可证不支持您之前许可证中的所有功能,您将在响应中收到通知。然后,您必须重新提交API请求,并将acknowledge参数设置为true。
有关不同类型许可证的更多信息,请参阅 https://www.elastic.co/subscriptions。
查询参数
edit-
acknowledge -
(可选,布尔值)
指定您是否确认许可协议的变更。默认值为
false。
请求体
edit-
licenses - (必需,数组) 包含许可证信息的JSON文档序列,一个或多个。
示例
edit以下示例更新为基本许可证:
PUT _license
{
"licenses": [
{
"uid":"893361dc-9749-4997-93cb-802e3d7fa4xx",
"type":"basic",
"issue_date_in_millis":1411948800000,
"expiry_date_in_millis":1914278399999,
"max_nodes":1,
"issued_to":"issuedTo",
"issuer":"issuer",
"signature":"xx"
}
]
}
这些值是无效的;您必须从您的许可证文件中替换适当的内容。
您也可以使用curl命令安装许可证文件。请确保在许可证文件路径前添加@,以指示curl将其视为输入文件。
curl -XPUT -u <user> 'http://<host>:<port>/_license' -H "Content-Type: application/json" -d @license.json
在 Windows 上,使用以下命令:
Invoke-WebRequest -uri http://<host>:<port>/_license -Credential elastic -Method Put -ContentType "application/json" -InFile .\license.json
在这些示例中,
-
是一个具有适当权限的用户ID。 -
是Elasticsearch集群中任何节点的hostname(如果在本地执行,则为localhost) -
是http端口(默认为9200) -
license.json是许可证JSON文件
如果您的 Elasticsearch 节点在 HTTP 接口上启用了 SSL,您必须在 URL 开头使用 https://
如果您之前拥有比基本许可证更多功能的许可证,您将收到以下响应:
{
"acknowledged": false,
"license_status": "valid",
"acknowledge": {
"message": """This license update requires acknowledgement. To acknowledge the license, please read the following messages and update the license again, this time with the "acknowledge=true" parameter:""",
"watcher": [
"Watcher will be disabled"
],
"logstash": [
"Logstash will no longer poll for centrally-managed pipelines"
],
"security": [
"The following X-Pack security functionality will be disabled: ..." ]
}
}
要完成更新,您必须重新提交API请求并将acknowledge参数设置为true。例如:
PUT _license?acknowledge=true
{
"licenses": [
{
"uid":"893361dc-9749-4997-93cb-802e3d7fa4xx",
"type":"basic",
"issue_date_in_millis":1411948800000,
"expiry_date_in_millis":1914278399999,
"max_nodes":1,
"issued_to":"issuedTo",
"issuer":"issuer",
"signature":"xx"
}
]
}
或者:
curl -XPUT -u elastic 'http://<host>:<port>/_license?acknowledge=true' -H "Content-Type: application/json" -d @license.json
有关许可证到期时禁用的功能的更多信息,请参阅 许可证到期。