跳到正文

安装插件 ​

你可以根据需要为 OpenSearch 安装单独的插件(plugin)。有关可用插件的信息,请参阅可用插件。

警告

为了让插件与 OpenSearch 正常配合工作,所有插件都必须能够访问集群(Cluster)中的数据,包括有关集群操作的元数据。因此,为了保护集群数据并维护其完整性,首先,在 OpenSearch 集群上安装插件之前,务必了解该插件的功能。其次,在选择自定义插件时,务必确保插件来源可靠。

管理插件 ​

OpenSearch 使用名为 opensearch-plugin 的命令行工具管理插件。使用该工具,你可以:

传入 -h 或 --help 可打印帮助文本。根据主机配置,你可能还需要以 sudo 权限运行该命令。

注意

如果你在 Docker 容器中运行 OpenSearch,则必须通过修改 Docker 镜像来安装、删除和配置插件。有关信息,请参阅使用插件

列出插件 ​

使用 list 查看已安装的插件列表。

用法 ​

bash
bin/opensearch-plugin list

示例 ​

bash
$ ./opensearch-plugin list
opensearch-alerting
opensearch-anomaly-detection
opensearch-asynchronous-search
opensearch-cross-cluster-replication
opensearch-geospatial
opensearch-index-management
opensearch-job-scheduler
opensearch-knn
opensearch-ml
opensearch-notifications
opensearch-notifications-core
opensearch-observability
opensearch-performance-analyzer
opensearch-reports-scheduler
opensearch-security
opensearch-sql

你也可以使用 CAT API 列出已安装的插件。

路径和 HTTP 方法 ​

bash
GET _cat/plugins

示例响应 ​

bash
opensearch-node1 opensearch-alerting                  2.0.1.0
opensearch-node1 opensearch-anomaly-detection         2.0.1.0
opensearch-node1 opensearch-asynchronous-search       2.0.1.0
opensearch-node1 opensearch-cross-cluster-replication 2.0.1.0
opensearch-node1 opensearch-index-management          2.0.1.0
opensearch-node1 opensearch-job-scheduler             2.0.1.0
opensearch-node1 opensearch-knn                       2.0.1.0
opensearch-node1 opensearch-ml                        2.0.1.0
opensearch-node1 opensearch-notifications             2.0.1.0
opensearch-node1 opensearch-notifications-core        2.0.1.0

安装插件 ​

使用 opensearch-plugin 安装插件有三种方式:

按名称安装插件: ​

有关可按名称安装的插件列表,请参阅其他插件。

用法 ​

bash
bin/opensearch-plugin install <plugin-name>

示例 ​

bash
$ sudo ./opensearch-plugin install analysis-icu
-> Installing analysis-icu
-> Downloading analysis-icu from opensearch
[=================================================] 100%   
-> Installed analysis-icu with folder name analysis-icu

从 zip 文件安装插件 ​

要安装远程 zip 文件,请将 <zip-file> 替换为托管文件的 URL。该工具仅支持通过 HTTP/HTTPS 协议下载。对于本地 zip 文件,请将 <zip-file> 替换为 file: 加上插件 zip 文件的绝对路径或相对路径,如下面的第二个示例所示。

用法 ​

bash
bin/opensearch-plugin install <zip-file>

示例 ​

bash
# zip 文件托管在远程服务器上,本例中为 Maven 中央仓库。
$ sudo ./opensearch-plugin install https://repo1.maven.org/maven2/org/opensearch/plugin/opensearch-anomaly-detection/2.2.0.0/opensearch-anomaly-detection-2.2.0.0.zip
-> Installing https://repo1.maven.org/maven2/org/opensearch/plugin/opensearch-anomaly-detection/2.2.0.0/opensearch-anomaly-detection-2.2.0.0.zip
-> Downloading https://repo1.maven.org/maven2/org/opensearch/plugin/opensearch-anomaly-detection/2.2.0.0/opensearch-anomaly-detection-2.2.0.0.zip
[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessClassInPackage.sun.misc
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission getClassLoader
* java.lang.RuntimePermission setContextClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.net.SocketPermission * connect,resolve
* javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] registerMBean
* javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] unregisterMBean
* javax.management.MBeanServerPermission createMBeanServer
* javax.management.MBeanTrustPermission register
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed opensearch-anomaly-detection with folder name opensearch-anomaly-detection

# 本地目录中的 zip 文件。
$ sudo ./opensearch-plugin install file:/home/user/opensearch-anomaly-detection-2.2.0.0.zip
-> Installing file:/home/user/opensearch-anomaly-detection-2.2.0.0.zip
-> Downloading file:/home/user/opensearch-anomaly-detection-2.2.0.0.zip
[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessClassInPackage.sun.misc
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission getClassLoader
* java.lang.RuntimePermission setContextClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.net.SocketPermission * connect,resolve
* javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] registerMBean
* javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] unregisterMBean
* javax.management.MBeanServerPermission createMBeanServer
* javax.management.MBeanTrustPermission register
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed opensearch-anomaly-detection with folder name opensearch-anomaly-detection

使用 Maven 坐标安装插件 ​

opensearch-plugin install 工具也接受 Maven 坐标,用于安装托管在 Maven Central 上的可用制品和版本。opensearch-plugin 会解析你提供的 Maven 坐标并构造 URL。因此,主机必须能够直接连接到 Maven Central。如果你将坐标传给代理或本地仓库,插件安装将会失败。

用法 ​

bash
bin/opensearch-plugin install <groupId>:<artifactId>:<version>

示例 ​

bash
$ sudo ./opensearch-plugin install org.opensearch.plugin:opensearch-anomaly-detection:2.2.0.0
-> Installing org.opensearch.plugin:opensearch-anomaly-detection:2.2.0.0
-> Downloading org.opensearch.plugin:opensearch-anomaly-detection:2.2.0.0 from maven central
[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessClassInPackage.sun.misc
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission getClassLoader
* java.lang.RuntimePermission setContextClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.net.SocketPermission * connect,resolve
* javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] registerMBean
* javax.management.MBeanPermission org.apache.commons.pool2.impl.GenericObjectPool#-[org.apache.commons.pool2:name=pool,type=GenericObjectPool] unregisterMBean
* javax.management.MBeanServerPermission createMBeanServer
* javax.management.MBeanTrustPermission register
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed opensearch-anomaly-detection with folder name opensearch-anomaly-detection

注意

安装插件后,请重启 OpenSearch 节点(Node)。

安装多个插件 ​

可以在一次调用中安装多个插件。

用法 ​

bash
bin/opensearch-plugin install <plugin-name> <plugin-name> ... <plugin-name>

示例 ​

bash
$ sudo $ ./opensearch-plugin install analysis-nori repository-s3

删除插件 ​

你可以使用 remove 选项删除已安装的插件。

用法 ​

bash
bin/opensearch-plugin remove <plugin-name>

示例 ​

bash
$ sudo $ ./opensearch-plugin remove opensearch-anomaly-detection
-> removing [opensearch-anomaly-detection]...

注意

删除插件后,请重启 OpenSearch 节点。

批处理模式 ​

安装需要默认未包含的额外权限的插件时,插件会提示用户确认所需的权限。要授予所有请求的权限,可以使用批处理模式跳过确认提示。

要在安装插件时强制使用批处理模式,请添加 -b 或 --batch 选项:

bash
bin/opensearch-plugin install --batch <plugin-name>

可用插件 ​

警告

插件的主版本号、次版本号和补丁版本号必须与 OpenSearch 的主版本号、次版本号和补丁版本号一致,才能兼容。例如,2.3.0.x 版本的插件只能与 OpenSearch 2.3.0 配合使用。

内置插件 ​

除最小发行包外,所有 OpenSearch 发行版都内置了以下插件。

插件名称仓库最早可用版本
Alertingopensearch-alerting1.0.0
Anomaly Detectionopensearch-anomaly-detection1.0.0
Asynchronous Searchopensearch-asynchronous-search1.0.0
Cross Cluster Replicationopensearch-cross-cluster-replication1.1.0
Custom Codecsopensearch-custom-codecs2.10.0
Flow Frameworkflow-framework2.12.0
Notebooks1opensearch-notebooks1.0.0 至 1.1.0
Notificationsnotifications2.0.0
Reports Scheduleropensearch-reports-scheduler1.0.0
Geospatialopensearch-geospatial2.2.0
Index Managementopensearch-index-management1.0.0
Job Scheduleropensearch-job-scheduler1.0.0
k-NNopensearch-knn1.0.0
ML Commonsopensearch-ml1.3.0
Neural Searchneural-search2.4.0
Observabilityopensearch-observability1.2.0
Performance Analyzer2opensearch-performance-analyzer1.0.0
Securityopensearch-security1.0.0
Security Analyticsopensearch-security-analytics2.4.0
SQLopensearch-sql1.0.0

1随着 OpenSearch 1.2.0 的发布,Dashboard Notebooks 已合并到 Observability 插件中。
2Performance Analyzer 在 Windows 上不可用。

其他插件 ​

OpenSearch 社区成员为该服务构建了无数插件。由于许多插件并不在 OpenSearch GitHub 仓库中维护,因此无法列出所有插件的完整列表,但以下插件可以使用 bin/opensearch-plugin install <plugin-name> 按名称安装。

插件名称最早可用版本
analysis-icu1.0.0
analysis-kuromoji1.0.0
analysis-nori1.0.0
analysis-phonetic1.0.0
analysis-smartcn1.0.0
analysis-stempel1.0.0
analysis-ukrainian1.0.0
discovery-azure-classic1.0.0
discovery-ec21.0.0
discovery-gce1.0.0
ingest-attachment1.0.0
mapper-annotated-text1.0.0
mapper-murmur31.0.0
mapper-size1.0.0
query-insights2.12.0
repository-azure1.0.0
repository-gcs1.0.0
repository-hdfs1.0.0
repository-s31.0.0
store-smb1.0.0
transport-nio1.0.0