From a7642faeef86dcb69c948e0b99da0c6821b641fa Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 26 Nov 2026 10:22:20 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vitepress/config.mts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 5d4317a9..a9bf4d3a 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -21,6 +21,18 @@ const FORUM_URL = 'https://www.isharkfly.com/tag/opensearch'; const CONTACT_URL = 'https://www.isharkfly.com/t/opensearch/15530'; const REPO_URL = 'https://github.com/iSharkFly-Docs/opensearch-docs-cn'; +// iSharkFly links shown as a dropdown at the end of the nav bar. +function isharkflyNav(zh: boolean): DefaultTheme.NavItem { + return { + text: 'iSharkFly', + items: [ + { text: zh ? 'iSharkFly' : 'iSharkFly', link: FORUM_URL }, + { text: zh ? '文档导航' : 'Docs Portal', link: 'https://docs.isharkfly.com/' }, + { text: zh ? '本站源码' : 'Source Code', link: 'https://src.sharkdat.com/iSharkFly-Docs/OpenSearch-iSharkFly-Com' }, + ], + }; +} + // Sidebar group names (just-the-docs collection names from _config.yml). const zhSidebarText: Record = { 'About OpenSearch': '关于 OpenSearch', @@ -131,7 +143,7 @@ for (const [key, locale] of Object.entries(site.locales)) { { text: '客户端', link: `${b}clients/`, activeMatch: `^${b}clients/` }, { text: 'Data Prepper', link: `${b}data-prepper/`, activeMatch: `^${b}data-prepper/` }, { text: 'Benchmark', link: `${b}benchmark/`, activeMatch: `^${b}benchmark/` }, - { text: '中文论坛', link: FORUM_URL }, + isharkflyNav(true), ], sidebar: mapSidebar(locale.sidebar, link => link, text => zhSidebarText[text] ?? text), }, @@ -151,7 +163,7 @@ for (const [key, locale] of Object.entries(site.locales)) { { text: 'Clients', link: `${enBase}clients/`, activeMatch: `^${enBase}clients/` }, { text: 'Data Prepper', link: `${enBase}data-prepper/`, activeMatch: `^${enBase}data-prepper/` }, { text: 'Benchmark', link: `${enBase}benchmark/`, activeMatch: `^${enBase}benchmark/` }, - { text: 'Forum', link: FORUM_URL }, + isharkflyNav(false), ], sidebar: mapSidebar(locale.sidebar, enLink, text => text), }, -- 2.54.0 From 7a494fe806ebd637fefacc9f4fd32d4336988269 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 26 Nov 2026 11:24:00 -0500 Subject: [PATCH 2/3] =?UTF-8?q?about=20=E5=92=8C=20install-and-configure?= =?UTF-8?q?=20=E4=B8=A4=E9=83=A8=E5=88=86=E5=B7=B2=E7=BB=8F=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E5=AE=8C=EF=BC=8C=E5=85=B1=2042=20=E9=A1=B5=EF=BC=8C?= =?UTF-8?q?=E8=AF=91=E6=96=87=E5=9C=A8=20i18n/zh/=E3=80=82=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=A0=B8=E5=AF=B9=E3=80=81=E9=94=9A=E7=82=B9=E9=85=8D?= =?UTF-8?q?=E5=AF=B9=E5=92=8C=20Vue=20=E7=BC=96=E8=AF=91=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E9=83=BD=E9=80=9A=E8=BF=87=E4=BA=86=EF=BC=8C=E4=BD=86=E6=88=91?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=87=8D=E8=B7=91=E6=95=B4=E7=AB=99=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=EF=BC=8C=E4=B9=9F=E6=B2=A1=E6=9C=89=E5=9C=A8=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E9=87=8C=E7=9C=8B=E6=95=88=E6=9E=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/zh/about/index.md | 71 ++ i18n/zh/breaking-changes.md | 39 + .../configuring-dashboards.md | 9 + .../availability-recovery.md | 69 ++ .../configuring-opensearch/circuit-breaker.md | 61 ++ .../cluster-settings.md | 140 +++ .../configuration-system.md | 21 + .../discovery-gateway-settings.md | 33 + .../configuring-opensearch/experimental.md | 78 ++ .../configuring-opensearch/index-settings.md | 192 ++++ .../configuring-opensearch/index.md | 106 +++ .../configuring-opensearch/logs.md | 235 +++++ .../network-settings.md | 56 ++ .../configuring-opensearch/plugin-settings.md | 97 ++ .../configuring-opensearch/search-settings.md | 39 + .../security-settings.md | 484 ++++++++++ i18n/zh/install-and-configure/index.md | 27 + .../install-dashboards/debian.md | 132 +++ .../install-dashboards/docker.md | 21 + .../install-dashboards/helm.md | 132 +++ .../install-dashboards/index.md | 64 ++ .../install-dashboards/plugins.md | 105 +++ .../install-dashboards/rpm.md | 81 ++ .../install-dashboards/tar.md | 26 + .../install-dashboards/tls.md | 55 ++ .../install-dashboards/windows.md | 51 ++ .../install-opensearch/ansible.md | 65 ++ .../install-opensearch/debian.md | 514 +++++++++++ .../install-opensearch/docker.md | 500 ++++++++++ .../install-opensearch/helm.md | 166 ++++ .../install-opensearch/index.md | 112 +++ .../install-opensearch/rpm.md | 492 ++++++++++ .../install-opensearch/tar.md | 568 ++++++++++++ .../install-opensearch/windows.md | 251 +++++ i18n/zh/install-and-configure/plugins.md | 327 +++++++ .../upgrade-opensearch/appendix/index.md | 16 + .../appendix/rolling-upgrade-lab.md | 867 ++++++++++++++++++ .../upgrade-opensearch/index.md | 244 +++++ .../upgrade-opensearch/rolling-upgrade.md | 201 ++++ i18n/zh/intro.md | 106 +++ i18n/zh/quickstart.md | 161 ++++ i18n/zh/version-history.md | 50 + 42 files changed, 7064 insertions(+) create mode 100644 i18n/zh/about/index.md create mode 100644 i18n/zh/breaking-changes.md create mode 100644 i18n/zh/install-and-configure/configuring-dashboards.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/availability-recovery.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/circuit-breaker.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/cluster-settings.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/configuration-system.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/discovery-gateway-settings.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/experimental.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/index-settings.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/index.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/logs.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/network-settings.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/plugin-settings.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/search-settings.md create mode 100644 i18n/zh/install-and-configure/configuring-opensearch/security-settings.md create mode 100644 i18n/zh/install-and-configure/index.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/debian.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/docker.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/helm.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/index.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/plugins.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/rpm.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/tar.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/tls.md create mode 100644 i18n/zh/install-and-configure/install-dashboards/windows.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/ansible.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/debian.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/docker.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/helm.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/index.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/rpm.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/tar.md create mode 100644 i18n/zh/install-and-configure/install-opensearch/windows.md create mode 100644 i18n/zh/install-and-configure/plugins.md create mode 100644 i18n/zh/install-and-configure/upgrade-opensearch/appendix/index.md create mode 100644 i18n/zh/install-and-configure/upgrade-opensearch/appendix/rolling-upgrade-lab.md create mode 100644 i18n/zh/install-and-configure/upgrade-opensearch/index.md create mode 100644 i18n/zh/install-and-configure/upgrade-opensearch/rolling-upgrade.md create mode 100644 i18n/zh/intro.md create mode 100644 i18n/zh/quickstart.md create mode 100644 i18n/zh/version-history.md diff --git a/i18n/zh/about/index.md b/i18n/zh/about/index.md new file mode 100644 index 00000000..ea68aadb --- /dev/null +++ b/i18n/zh/about/index.md @@ -0,0 +1,71 @@ +--- +title: 入门 +--- + +# OpenSearch 和 OpenSearch Dashboards + + +本部分包含 OpenSearch 和 OpenSearch Dashboards 的文档。 + +## 入门 + +- [OpenSearch 简介](/intro) +- [快速入门](/quickstart) +- [安装 OpenSearch](/install-and-configure/install-opensearch/) +- [安装 OpenSearch Dashboards](/install-and-configure/install-dashboards/) +- [查看常见问题](https://opensearch.org/faq) + +## 为什么使用 OpenSearch? + +借助 OpenSearch,你可以实现以下用例: + + + + + + + + + + + + + + + + + + + + + + +
Fast, scalable full-text searchApplication and infrastructure monitoringSecurity and event information managementOperational health tracking
快速、可扩展的全文搜索应用程序和基础设施监控安全和事件信息管理运行健康状况跟踪
帮助用户在你的应用程序、网站或数据湖目录中找到所需的信息。轻松存储和分析日志数据,并针对性能下降设置自动告警。集中管理日志,实现实时安全监控和取证分析。使用可观测性日志、指标和追踪实时监控你的应用程序和业务。
+ +**其他功能和插件:** + +OpenSearch 提供了多种功能和插件(plugin),帮助你索引、保护、监控和分析数据。大多数 OpenSearch 插件都有对应的 OpenSearch Dashboards 插件,提供方便、统一的用户界面。 +- [异常检测](/observing-your-data/ad/) - 识别异常数据并接收自动通知 +- [KNN](/search-plugins/knn/) - 在向量数据中查找「最近邻」 +- [Performance Analyzer](/monitoring-your-cluster/pa/) - 监控和优化你的集群 +- [SQL](/search-plugins/sql/) - 使用 SQL 或管道处理语言查询数据 +- [索引状态管理](/im-plugin/) - 自动执行索引操作 +- [ML Commons 插件](/ml-commons-plugin/) - 训练和运行机器学习模型 +- [异步搜索](/search-plugins/async/) - 在后台运行搜索请求 +- [跨集群复制](/tuning-your-cluster/replication-plugin/) - 在多个 OpenSearch 集群之间复制数据 + +## 安全的前进之路 +OpenSearch 自带一套演示配置,便于你快速上手。但在生产环境中使用 OpenSearch 之前,你必须使用自己的证书、身份验证方法、用户和密码[手动配置 Security 插件](/security/configuration/)。 + +## 在找 Javadoc 吗? + +请参阅 [opensearch.org/javadocs/](https://opensearch.org/javadocs/)。 + +## 参与贡献 + +[OpenSearch](https://opensearch.org) 由 Amazon Web Services 提供支持。所有组件均在 [GitHub](https://github.com/opensearch-project/) 上以 [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) 许可证提供。 +本项目欢迎 GitHub issue、缺陷修复、新功能、插件、文档——任何贡献都可以。要参与贡献,请参阅 OpenSearch 网站上的[贡献指南](https://opensearch.org/source.html)。 + +--- + +OpenSearch 包含来自 Elasticsearch B.V. 的部分 Apache 许可的 Elasticsearch 代码以及其他源代码。Elasticsearch B.V. 不是这些其他源代码的来源。ELASTICSEARCH 是 Elasticsearch B.V. 的注册商标。 diff --git a/i18n/zh/breaking-changes.md b/i18n/zh/breaking-changes.md new file mode 100644 index 00000000..fcc52dbf --- /dev/null +++ b/i18n/zh/breaking-changes.md @@ -0,0 +1,39 @@ +--- +title: 破坏性变更 +--- + +## 1.x {#x} + +### 迁移到 OpenSearch 以及嵌套 JSON 对象数量的限制 + +如果集群中存在任何文档在所有字段中包含超过 10,000 个嵌套 JSON 对象,那么从 Elasticsearch OSS 6.8 版本迁移到 OpenSearch 1.x 版本将会失败。Elasticsearch 7.0 版本引入了 `index.mapping.nested_objects.limit` 设置以防止内存溢出错误,并将该设置的默认值设为 `10000`。OpenSearch 从一开始就采用了此设置,并强制执行嵌套 JSON 对象的限制。然而,由于 Elasticsearch 6.8 中不存在该设置,该版本也无法识别它,因此当任何文档中的嵌套 JSON 对象数量超过默认限制时,迁移到 OpenSearch 1.x 可能会导致不兼容问题,从而阻止分片在 Elasticsearch 6.8 和 OpenSearch 1.x 版本之间重新分配。 + +因此,我们建议在尝试从 Elasticsearch 6.8 迁移之前,先评估你的数据是否超出这些限制。 + +## 2.0.0 {#section} + +### 移除映射类型参数 + +`type` 参数已从所有 OpenSearch API 端点中移除。取而代之的是,可以按文档类型对索引进行分类。有关更多详细信息,请参阅 issue [#1940](https://github.com/opensearch-project/opensearch/issues/1940)。 + +### 弃用非包容性术语 + +非包容性术语在 2.x 版本中已被弃用,并将在 OpenSearch 3.0 中被永久移除。我们使用以下替代术语: + +- "Whitelist" 现在改为 "Allow list" +- "Blacklist" 现在改为 "Deny list" +- "Master" 现在改为 "Cluster Manager" + +### 添加 OpenSearch Notifications 插件 + +在 OpenSearch 2.0 中,Alerting 插件现已与新的 Notifications 插件集成。如果你想继续使用 Alerting 插件中的通知操作,请安装新的后端插件 `notifications-core` 和 `notifications`。如果你想在 OpenSearch Dashboards 中管理通知,请使用新的 `notificationsDashboards` 插件。有关更多信息,请参阅 OpenSearch 文档页面上的[通知](/observing-your-data/notifications/)。 + +### 不再支持 JDK 8 + +由于 Lucene 升级,OpenSearch 不得不放弃对 JDK 8 的支持。因此,[Java 高级 REST 客户端](/clients/java-rest-high-level)不再支持 JDK 8。恢复对 JDK 8 的支持目前是 `opensearch-java` 的一项提案 [#156](https://github.com/opensearch-project/opensearch-java/issues/156),这需要从 Java 客户端中移除对 OpenSearch 核心的依赖(issue [#262](https://github.com/opensearch-project/opensearch-java/issues/262))。 + +## 2.5.0 {#section-1} + +### 文本字段的通配符查询行为 + +OpenSearch 2.5 包含一项缺陷修复,纠正了文本字段上 `wildcard` 查询的 `case_insensitive` 参数的行为。因此,在此修复之前忽略大小写并错误返回结果的文本字段通配符查询,将不再返回相同的结果。有关更多信息,请参阅 issue [#8711](https://github.com/opensearch-project/OpenSearch/issues/8711)。 diff --git a/i18n/zh/install-and-configure/configuring-dashboards.md b/i18n/zh/install-and-configure/configuring-dashboards.md new file mode 100644 index 00000000..70449138 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-dashboards.md @@ -0,0 +1,9 @@ +--- +title: 配置 OpenSearch Dashboards +--- + +# 配置 OpenSearch Dashboards + +OpenSearch Dashboards 在你启动集群时使用 `opensearch_dashboards.yml` 配置文件读取设置。在每个节点上,你可以在 `/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml`(Docker)或 `/etc/opensearch-dashboards/opensearch_dashboards.yml`(大多数 Linux 发行版)中找到 `opensearch_dashboards.yml`。 + +有关 OpenSearch Dashboards 设置的信息,请参阅示例 [`opensearch_dashboards.yml`](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/config/opensearch_dashboards.yml) 文件。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/availability-recovery.md b/i18n/zh/install-and-configure/configuring-opensearch/availability-recovery.md new file mode 100644 index 00000000..da66f1f5 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/availability-recovery.md @@ -0,0 +1,69 @@ +--- +title: 可用性和恢复设置 +--- + +# 可用性和恢复设置 + +可用性和恢复设置包括以下方面的设置: + +- [快照](#snapshot-settings) +- [集群管理器任务限流](#cluster-manager-task-throttling-settings) +- [远程存储](#remote-backed-storage-settings) +- [搜索背压](#search-backpressure-settings) +- [分片索引背压](#shard-indexing-backpressure-settings) +- [段复制](#segment-replication-settings) +- [跨集群复制](#cross-cluster-replication-settings) + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +## 快照设置 + +OpenSearch 支持以下快照(Snapshot)设置: + +- `snapshot.max_concurrent_operations`(动态,integer):并发快照操作的最大数量。默认值为 `1000`。 + +### 与安全相关的快照设置 + +有关与安全相关的快照设置,请参阅[安全设置](/install-and-configure/configuring-opensearch/security-settings)。 + +### 文件系统设置 + +有关文件系统设置的信息,请参阅[共享文件系统](/tuning-your-cluster/availability-and-recovery/snapshots/snapshot-restore#shared-file-system)。 + +### Amazon S3 设置 + +有关 Amazon S3 存储库设置的信息,请参阅 [Amazon S3](/tuning-your-cluster/availability-and-recovery/snapshots/snapshot-restore#amazon-s3)。 + +## 集群管理器任务限流设置 + +有关集群管理器任务限流设置的信息,请参阅[设置限流阈值](/tuning-your-cluster/cluster-manager-task-throttling#setting-throttling-limits)。 + +## 远程存储设置 + +OpenSearch 支持以下集群级远程存储(Remote Store)设置: + +- `cluster.remote_store.translog.buffer_interval`(动态,time unit):执行定期 translog 更新时使用的 translog 缓冲间隔的默认值。仅当索引设置 `index.remote_store.translog.buffer_interval` 不存在时,此设置才生效。 + +- `remote_store.moving_average_window_size`(动态,integer):用于计算通过 [Remote Store Stats API](/tuning-your-cluster/availability-and-recovery/remote-store/remote-store-stats-api) 公开的滚动统计值的移动平均窗口大小。默认值为 `20`。强制的最小值为 `5`。 + +有关更多远程存储设置,请参阅[远程存储](/tuning-your-cluster/availability-and-recovery/remote-store/)和[配置远程存储](/tuning-your-cluster/availability-and-recovery/remote-store/#configuring-remote-backed-storage)。 + +有关远程段背压设置,请参阅[远程段背压设置](/tuning-your-cluster/availability-and-recovery/remote-store/remote-segment-backpressure#remote-segment-backpressure-settings)。 + +## 搜索背压设置 + +搜索背压(Search Backpressure)是一种用于识别资源密集型搜索请求,并在节点负载过高时取消这些请求的机制。有关更多信息,请参阅[搜索背压设置](/tuning-your-cluster/availability-and-recovery/search-backpressure#search-backpressure-settings)。 + +## 分片索引背压设置 + +分片索引背压(Shard Indexing Backpressure)是一种分片级别的智能拒绝机制,当集群承受压力时,它会动态拒绝索引请求。有关更多信息,请参阅分片索引背压[设置](/tuning-your-cluster/availability-and-recovery/shard-indexing-settings)。 + +## 段复制设置 + +有关段复制(Segment Replication)设置的信息,请参阅[段复制](/tuning-your-cluster/availability-and-recovery/segment-replication/)。 + +有关段复制背压设置的信息,请参阅[段复制背压](/tuning-your-cluster/availability-and-recovery/segment-replication/backpressure)。 + +## 跨集群复制设置 + +有关跨集群复制(Cross-cluster Replication)设置的信息,请参阅[复制设置](/tuning-your-cluster/replication-plugin/settings)。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/circuit-breaker.md b/i18n/zh/install-and-configure/configuring-opensearch/circuit-breaker.md new file mode 100644 index 00000000..bb720b57 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/circuit-breaker.md @@ -0,0 +1,61 @@ +--- +title: 断路器设置 +--- + +# 断路器设置 + +断路器(Circuit Breaker)可以防止 OpenSearch 引发 Java OutOfMemoryError。父断路器指定所有子断路器可用的内存总量。子断路器指定其自身可用的内存总量。 + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +## 父断路器设置 + +OpenSearch 支持以下父断路器设置: + +- `indices.breaker.total.use_real_memory`(静态,Boolean):如果为 `true`,父断路器会考虑实际内存使用量。否则,父断路器会考虑子断路器预留的内存量。默认值为 `true`。 + +- `indices.breaker.total.limit`(动态,percentage):指定父断路器的初始内存限制。如果 `indices.breaker.total.use_real_memory` 为 `true`,默认值为 JVM 堆的 95%。如果 `indices.breaker.total.use_real_memory` 为 `false`,默认值为 JVM 堆的 70%。 + +## 字段数据断路器设置 + +字段数据断路器限制将字段加载到字段数据缓存中所需的堆内存。OpenSearch 支持以下字段数据断路器设置: + +- `indices.breaker.fielddata.limit`(动态,percentage):指定字段数据断路器的内存限制。默认值为 JVM 堆的 40%。 + +- `indices.breaker.fielddata.overhead`(动态,double):一个常数,字段数据估算值乘以该常数即得到最终估算值。默认值为 1.03。 + +## 请求断路器设置 + +请求断路器限制构建请求所需数据结构(例如计算聚合时)所需的内存。OpenSearch 支持以下请求断路器设置: + +- `indices.breaker.request.limit`(动态,percentage):指定请求断路器的内存限制。默认值为 JVM 堆的 60%。 + +- `indices.breaker.request.overhead`(动态,double):一个常数,请求估算值乘以该常数即得到最终估算值。默认值为 1。 + +## 传输中请求断路器设置 + +传输中请求断路器限制传输层和 HTTP 层上当前正在运行的所有传入请求的内存使用量。请求的内存使用量基于请求的内容长度,包括原始请求以及表示该请求的结构化对象所需的内存。OpenSearch 支持以下传输中请求断路器设置: + +- `network.breaker.inflight_requests.limit`(动态,percentage):指定传输中请求断路器的内存限制。默认值为 JVM 堆的 100%(因此,传输中请求的内存使用限制由父断路器的内存限制决定)。 + +- `network.breaker.inflight_requests.overhead`(动态,double):一个常数,传输中请求估算值乘以该常数即得到最终估算值。默认值为 2。 + +## 脚本编译断路器设置 + +脚本编译断路器限制在一个时间间隔内内联脚本的编译次数。OpenSearch 支持以下脚本编译断路器设置: + +- `script.max_compilations_rate`(动态,rate):对于给定上下文,在一个时间间隔内编译的唯一动态脚本的最大数量。默认值为每 5 分钟 150 个(`150/5m`)。 + +## 正则表达式断路器设置 + +正则表达式断路器用于启用或禁用正则表达式,并限制其复杂度。OpenSearch 支持以下正则表达式断路器设置: + +- `script.painless.regex.enabled`(静态,string):在 Painless 脚本中启用正则表达式。 + 有效值为: + - `limited`:启用正则表达式,并使用 `script.painless.regex.limit-factor` 设置限制其复杂度。 + - `true`:启用正则表达式。关闭正则表达式断路器,不限制正则表达式的复杂度。 + - `false`:禁用正则表达式。如果 Painless 脚本包含正则表达式,则返回错误。 + + 默认值为 `limited`。 + +- `script.painless.regex.limit-factor`(静态,integer):仅当 `script.painless.regex.enabled` 设置为 `limited` 时才适用。限制 Painless 脚本中正则表达式的字符数。字符数上限的计算方式为:脚本输入中的字符数乘以 `script.painless.regex.limit-factor`。默认值为 6(因此,如果输入有 5 个字符,则正则表达式中的最大字符数为 5 · 6 = 30)。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/cluster-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/cluster-settings.md new file mode 100644 index 00000000..a77507c7 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/cluster-settings.md @@ -0,0 +1,140 @@ +--- +title: 集群设置 +--- + +# 集群设置 + +以下设置与 OpenSearch 集群相关。 + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +## 集群级路由和分配设置 + +OpenSearch 支持以下集群级路由和分片分配设置。此列表中的所有设置都是动态的: + +- `cluster.routing.allocation.enable`(String):为特定类型的分片启用或禁用分配。 + + 有效值为: + - `all` – 允许为所有类型的分片分配。 + - `primaries` – 仅允许为主分片分配。 + - `new_primaries` – 仅允许为新索引的主分片分配。 + - `none` – 不允许为任何索引分配分片。 + + 默认值为 `all`。 + +- `cluster.routing.allocation.node_concurrent_incoming_recoveries`(Integer):配置一个节点上允许同时进行多少个传入分片恢复。默认值为 `2`。 + +- `cluster.routing.allocation.node_concurrent_outgoing_recoveries`(Integer):配置一个节点上允许同时进行多少个传出分片恢复。默认值为 `2`。 + +- `cluster.routing.allocation.node_concurrent_recoveries`(String):用于将 `cluster.routing.allocation.node_concurrent_incoming_recoveries` 和 `cluster.routing.allocation.node_concurrent_outgoing_recoveries` 设置为相同的值。 + +- `cluster.routing.allocation.node_initial_primaries_recoveries`(Integer):设置节点重启后未分配主分片的恢复数量。默认值为 `4`。 + +- `cluster.routing.allocation.same_shard.host`(Boolean):设置为 `true` 时,会阻止将同一分片的多个副本分配到同一主机上的不同节点。默认值为 `false`。 + +- `cluster.routing.rebalance.enable`(String):为特定类型的分片启用或禁用重新平衡。 + + 有效值为: + - `all` – 允许对所有类型的分片进行平衡。 + - `primaries` – 仅允许对主分片进行平衡。 + - `replicas` – 仅允许对副本分片进行平衡。 + - `none` – 不允许对任何索引进行分片平衡。 + + 默认值为 `all`。 + +- `cluster.routing.allocation.allow_rebalance`(String):指定何时允许分片重新平衡。 + + 有效值为: + - `always` – 始终允许重新平衡。 + - `indices_primaries_active` – 仅当集群中的所有主分片都已分配时才允许重新平衡。 + - `indices_all_active` – 仅当集群中的所有分片都已分配时才允许重新平衡。 + + 默认值为 `indices_all_active`。 + +- `cluster.routing.allocation.cluster_concurrent_rebalance`(Integer):用于控制整个集群中允许同时进行多少个分片重新平衡。默认值为 `2`。 + +- `cluster.routing.allocation.balance.shard`(Floating point):定义每个节点上分配的分片总数的权重因子。默认值为 `0.45`。 + +- `cluster.routing.allocation.balance.index`(Floating point):定义节点上分配的每个索引的分片数量的权重因子。默认值为 `0.55`。 + +- `cluster.routing.allocation.balance.threshold`(Floating point):应执行的操作的最小优化值。默认值为 `1.0`。 + +- `cluster.routing.allocation.balance.prefer_primary`(Boolean):设置为 `true` 时,OpenSearch 会尝试在集群节点之间均匀分配主分片。启用此设置并不总能保证每个节点上的主分片数量相等,尤其是在发生故障转移的情况下。将此设置从 `true` 改为 `false` 不会触发主分片的重新分配。默认值为 `false`。 + +- `cluster.routing.allocation.disk.threshold_enabled`(Boolean):设置为 `false` 时,禁用磁盘分配决策器。禁用后还会移除所有现有的 `index.blocks.read_only_allow_delete index blocks`。默认值为 `true`。 + +- `cluster.routing.allocation.disk.watermark.low`(String):控制磁盘使用率的低水位线。设置为百分比时,OpenSearch 不会将分片分配给磁盘使用率达到该百分比的节点。也可以输入比率值,例如 `0.85`。此外,还可以设置为字节值,例如 `400mb`。此设置不影响新创建索引的主分片,但会阻止分配其副本。默认值为 `85%`。 + +- `cluster.routing.allocation.disk.watermark.high`(String):控制高水位线。OpenSearch 会尝试将分片从磁盘使用率高于所定义百分比的节点上迁移出去。也可以输入比率值,例如 `0.85`。此外,还可以设置为字节值,例如 `400mb`。此设置影响所有分片的分配。默认值为 `90%`。 + +- `cluster.routing.allocation.disk.watermark.flood_stage`(String):控制洪水阶段水位线。这是防止节点耗尽磁盘空间的最后手段。对于在该节点上分配了一个或多个分片、并且至少有一个磁盘超过洪水阶段的每个索引,OpenSearch 都会强制施加只读索引块(`index.blocks.read_only_allow_delete`)。一旦磁盘使用率降到高水位线以下,该索引块就会被解除。也可以输入比率值,例如 `0.85`。此外,还可以设置为字节值,例如 `400mb`。默认值为 `95%`。 + +- `cluster.info.update.interval`(Time unit):设置 OpenSearch 检查集群中每个节点磁盘使用情况的频率。默认值为 `30s`。 + +- `cluster.routing.allocation.include.`(Enum):将分片分配给其 `attribute` 至少包含所列逗号分隔值之一的节点。 + +- `cluster.routing.allocation.require.`(Enum):仅将分片分配给其 `attribute` 包含所列全部逗号分隔值的节点。 + +- `cluster.routing.allocation.exclude.`(Enum):不将分片分配给其 `attribute` 包含所列任意逗号分隔值的节点。集群分配设置支持以下内置属性。 + + 有效值为: + - `_name` – 按节点名称匹配节点。 + - `_host_ip` – 按主机 IP 地址匹配节点。 + - `_publish_ip` – 按发布 IP 地址匹配节点。 + - `_ip` – 匹配 `_host_ip` 或 `_publish_ip`。 + - `_host` – 按主机名匹配节点。 + - `_id` – 按节点 ID 匹配节点。 + - `_tier` – 按数据层角色匹配节点。 + +- `cluster.routing.allocation.shard_movement_strategy`(Enum):决定分片从传出节点迁移到传入节点的顺序。 + + 此设置支持以下策略: + - `PRIMARY_FIRST` – 先迁移主分片,再迁移副本分片。如果迁移中的节点在过程中发生故障,这种优先顺序可能有助于防止集群健康状态变为红色。 + - `REPLICA_FIRST` – 先迁移副本分片,再迁移主分片。在启用了段复制的混合版本 OpenSearch 集群中进行分片迁移时,这种优先顺序可能有助于防止集群健康状态变为红色。在这种情况下,迁移到较新版本 OpenSearch 节点上的主分片可能会尝试将段文件复制到较旧版本 OpenSearch 上的副本分片,从而导致分片故障。在多版本集群中,先迁移副本分片可能有助于避免这种情况。 + - `NO_PREFERENCE` – 默认行为,分片迁移的顺序无关紧要。 + +## 集群级分片、块和任务设置 + +OpenSearch 支持以下集群级分片、块和任务设置: + +- `cluster.blocks.read_only`(Boolean):将整个集群设置为只读。默认值为 `false`。 + +- `cluster.blocks.read_only_allow_delete`(Boolean):与 `cluster.blocks.read_only` 类似,但允许删除索引。 + +- `cluster.max_shards_per_node`(Integer):限制集群的主分片和副本分片总数。该限制的计算方式为:`cluster.max_shards_per_node` 乘以非冻结数据节点的数量。已关闭索引的分片不计入此限制。默认值为 `1000`。 + +- `cluster.persistent_tasks.allocation.enable`(String):为持久任务启用或禁用分配。 + + 有效值为: + - `all` – 允许将持久任务分配给节点。 + - `none` – 不允许为持久任务分配。这不会影响已在运行的持久任务。 + + 默认值为 `all`。 + +- `cluster.persistent_tasks.allocation.recheck_interval`(Time unit):当集群状态发生重大变化时,集群管理器会自动检查是否需要分配持久任务。还有其他一些因素(例如内存使用量)会影响持久任务是否被分配给节点,但这些因素不会导致集群状态发生变化。此设置定义了针对这些因素执行分配检查的频率。默认值为 `30 seconds`,最小值为 `10 seconds`。 + +## 集群级慢日志设置 + +有关更多信息,请参阅[搜索请求慢日志](/install-and-configure/configuring-opensearch/logs#search-request-slow-logs)。 + +- `cluster.search.request.slowlog.threshold.warn`(Time unit):设置请求级慢日志的 `WARN` 阈值。默认值为 `-1`。 + +- `cluster.search.request.slowlog.threshold.info`(Time unit):设置请求级慢日志的 `INFO` 阈值。默认值为 `-1`。 + +- `cluster.search.request.slowlog.threshold.debug`(Time unit):设置请求级慢日志的 `DEBUG` 阈值。默认值为 `-1`。 + +- `cluster.search.request.slowlog.threshold.trace`(Time unit):设置请求级慢日志的 `TRACE` 阈值。默认值为 `-1`。 + +- `cluster.search.request.slowlog.level`(String):设置要记录的最低慢日志级别:`WARN`、`INFO`、`DEBUG` 和 `TRACE`。默认值为 `TRACE`。 + +## 集群级索引设置 + +有关索引级索引设置的信息,请参阅[集群级索引设置](/install-and-configure/configuring-opensearch/index-settings#cluster-level-index-settings)。 + +## 集群级协调设置 + +OpenSearch 支持以下集群级协调设置。此列表中的所有设置都是动态的: + +- `cluster.fault_detection.leader_check.timeout`(Time unit):在 leader 检查期间,节点等待已选举的集群管理器响应的时间,超过该时间则认为检查失败。有效值范围为 `1ms` 到 `60s`(含边界值)。默认值为 `10s`。将此设置更改为默认值以外的值可能会导致集群不稳定。 + +- `cluster.fault_detection.follower_check.timeout`(Time unit):在 follower 检查期间,已选举的集群管理器等待响应的时间,超过该时间则认为检查失败。有效值范围为 `1ms` 到 `60s`(含边界值)。默认值为 `10s`。将此设置更改为默认值以外的值可能会导致集群不稳定。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/configuration-system.md b/i18n/zh/install-and-configure/configuring-opensearch/configuration-system.md new file mode 100644 index 00000000..ecaedfcf --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/configuration-system.md @@ -0,0 +1,21 @@ +--- +title: 配置和系统设置 +--- + +# 配置和系统设置 + +有关创建 OpenSearch 集群的概述以及配置设置示例,请参阅[创建集群](/tuning-your-cluster/)。要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +OpenSearch 支持以下系统设置: + +- `cluster.name`(静态,string):集群名称。 + +- `node.name`(静态,string):节点的描述性名称。 + +- `node.roles`(静态,list):为 OpenSearch 节点定义一个或多个角色。有效值为 `cluster_manager`、`data`、`ingest`、`search`、`ml`、`remote_cluster_client` 和 `coordinating_only`。 + +- `path.data`(静态,string):存储数据的目录路径。多个位置之间用逗号分隔。 + +- `path.logs`(静态,string):日志文件的路径。 + +- `bootstrap.memory_lock`(静态,Boolean):在启动时锁定内存。我们建议将堆大小设置为系统可用内存的一半左右,并确保进程的所有者被允许使用此限制。当系统进行内存交换时,OpenSearch 的性能会很差。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/discovery-gateway-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/discovery-gateway-settings.md new file mode 100644 index 00000000..009756d8 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/discovery-gateway-settings.md @@ -0,0 +1,33 @@ +--- +title: 发现和网关设置 +--- + +# 发现和网关设置 + +以下是与发现和本地网关相关的设置。 + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +## 发现设置 + +发现过程在集群组建时使用,包括发现节点和选举集群管理节点(Cluster Manager Node)。OpenSearch 支持以下发现设置: + +- `discovery.seed_hosts`(静态,list):节点启动时执行发现的主机列表。默认主机列表为 `["127.0.0.1", "[::1]"]`。 + +- `discovery.seed_providers`(静态,list):指定用于获取种子节点地址以启动发现过程的种子主机提供程序类型。 + +- `discovery.type`(静态,string):默认情况下,OpenSearch 会组建多节点集群。将 `discovery.type` 设置为 `single-node` 即可组建单节点集群。 + +- `cluster.initial_cluster_manager_nodes`(静态,list):用于引导集群的、有资格成为集群管理器的节点列表。 + +## 网关设置 + +本地网关存储集群重启时使用的集群状态和分片数据。OpenSearch 支持以下本地网关设置: + +- `gateway.recover_after_nodes`(静态,integer):在整个集群重启后,开始恢复之前必须加入集群的节点数量。 + +- `gateway.recover_after_data_nodes`(静态,integer):在整个集群重启后,开始恢复之前必须加入集群的数据节点数量。 + +- `gateway.expected_data_nodes`(静态,integer):集群中预期存在的数据节点数量。当预期数量的节点加入集群后,即可开始恢复本地分片。 + +- `gateway.recover_after_time`(静态,time value):如果数据节点数量少于预期数量,在开始恢复之前需要等待的时间。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/experimental.md b/i18n/zh/install-and-configure/configuring-opensearch/experimental.md new file mode 100644 index 00000000..c3502be8 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/experimental.md @@ -0,0 +1,78 @@ +--- +title: 实验性功能标志 +--- + +# 实验性功能标志 + +OpenSearch 的版本中可能包含实验性功能,你可以根据需要启用或禁用这些功能。根据安装类型的不同,有多种启用功能标志的方法。 + +## 在 opensearch.yml 中启用 {#enable-in-opensearchyml} + +如果你正在运行 OpenSearch 集群,并希望在配置文件中启用功能标志,请将以下行添加到 `opensearch.yml` 中: + +```yaml +opensearch.experimental.feature..enabled: true +``` + +## 在 Docker 容器中启用 + +如果你使用的是 Docker,请将以下行添加到 `docker-compose.yml` 中的 `opensearch-node` > `environment` 部分下: + +```bash +OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.feature..enabled=true" +``` + +## 在 tarball 安装中启用 + +要在 tarball 安装中启用功能标志,请在 `config/jvm.options` 或 `OPENSEARCH_JAVA_OPTS` 中提供新的 JVM 参数。 + +### 选项 1:修改 jvm.options {#option-1-modify-jvmoptions} + +在启动 `opensearch` 进程之前,将以下行添加到 `config/jvm.options` 中,以启用该功能及其依赖项: + +```bash +-Dopensearch.experimental.feature..enabled=true +``` + +然后运行 OpenSearch: + +```bash +./bin/opensearch +``` + +### 选项 2:使用环境变量启用 + +除了直接修改 `config/jvm.options` 之外,你还可以使用环境变量来定义这些属性。你可以在启动 OpenSearch 时通过单条命令完成,也可以使用 `export` 定义该变量。 + +要在启动 OpenSearch 时以内联方式添加功能标志,请运行以下命令: + +```bash +OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.feature..enabled=true" ./opensearch-2.12.0/bin/opensearch +``` + +如果你想在运行 OpenSearch 之前单独定义环境变量,请运行以下命令: + +```bash +export OPENSEARCH_JAVA_OPTS="-Dopensearch.experimental.feature..enabled=true" +``` + +```bash +./bin/opensearch +``` + +## 为 OpenSearch 开发启用 + +要在开发中启用功能标志,你必须在构建 OpenSearch 之前将正确的属性添加到 `run.gradle` 中。有关如何使用 Gradle 构建 OpenSearch 的信息,请参阅[开发者指南](https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md)。 + +将以下属性添加到 run.gradle 中以启用该功能: + +```gradle +testClusters { + runTask { + testDistribution = 'archive' + if (numZones > 1) numberOfZones = numZones + if (numNodes > 1) numberOfNodes = numNodes + systemProperty 'opensearch.experimental.feature..enabled', 'true' + } + } +``` diff --git a/i18n/zh/install-and-configure/configuring-opensearch/index-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/index-settings.md new file mode 100644 index 00000000..603d5a56 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/index-settings.md @@ -0,0 +1,192 @@ +--- +title: 索引设置 +--- + +# 索引设置 + +索引设置分为两种类型:影响集群中所有索引的[集群级设置](#cluster-level-index-settings),以及影响单个索引的[索引级设置](#index-level-index-settings)。 + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +## 集群级索引设置 + +OpenSearch 支持以下集群级索引设置。此列表中的所有设置都是动态的: + +- `action.auto_create_index`(Boolean):如果索引尚不存在,则自动创建该索引,同时应用已配置的所有索引模板(Index Template)。默认值为 `true`。 + +- `action.destructive_requires_name`(Boolean):设置为 `true` 时,删除索引时必须指定索引名称,不能删除所有索引或使用通配符。默认值为 `true`。 + +- `cluster.default.index.refresh_interval`(Time unit):设置未提供 `index.refresh_interval` 设置时的刷新间隔。当你希望为集群中的所有索引设置默认刷新间隔并支持 `searchIdle` 设置时,此设置非常有用。该间隔不能低于 `cluster.minimum.index.refresh_interval` 设置的值。 + +- `cluster.minimum.index.refresh_interval`(Time unit):设置最小刷新间隔,并将其应用于集群中的所有索引。`cluster.default.index.refresh_interval` 设置应高于此设置的值。如果在创建索引时 `index.refresh_interval` 设置低于所设定的最小值,则索引创建失败。 + +- `cluster.indices.close.enable`(Boolean):允许在 OpenSearch 中关闭已打开的索引。默认值为 `true`。 + +- `indices.recovery.max_bytes_per_sec`(String):限制每个节点的入站和出站恢复流量总量。此设置适用于对等恢复和快照恢复。默认值为 `40mb`。如果将恢复流量值设置为小于或等于 `0mb`,则会禁用速率限制,恢复数据将以尽可能高的速率传输。 + +- `indices.recovery.max_concurrent_file_chunks`(Integer):每个恢复操作并行发送的文件块数量。默认值为 `2`。 + +- `indices.recovery.max_concurrent_operations`(Integer):每次恢复并行发送的操作数量。默认值为 `1`。 + +- `indices.recovery.max_concurrent_remote_store_streams`(Integer):恢复远程存储索引时,可以并行打开的到远程存储库的流数量。默认值为 `20`。 + +- `indices.time_series_index.default_index_merge_policy`(String):此设置用于为时间序列索引(尤其是包含 `@timestamp` 字段的索引,例如数据流)指定默认合并策略。两个可用选项为 `tiered`(默认)和 `log_byte_size`。建议对时间序列索引使用 `log_byte_size`,以提升针对 `@timestamp` 字段的范围查询性能。要按索引覆盖合并策略,可以使用 `index.merge.policy` 索引设置。 + +- `indices.fielddata.cache.size`(String):字段数据缓存的最大大小。可以指定为绝对值(例如 `8GB`)或节点堆的百分比(例如 `50%`)。该值是静态的,因此必须在 `opensearch.yml` 文件中指定。如果不指定此设置,则最大大小不受限制。该值应小于 `indices.breaker.fielddata.limit`。有关更多信息,请参阅[字段数据断路器](/install-and-configure/configuring-opensearch/circuit-breaker#field-data-circuit-breaker-settings)。 + +## 索引级索引设置 + +你可以在创建索引时指定索引设置。索引设置有两种类型: + +- [静态索引级索引设置](#static-index-level-index-settings)是在索引处于打开状态时无法更新的设置。要更新静态设置,必须先关闭索引,更新设置,然后重新打开索引。 +- [动态索引级索引设置](#dynamic-index-level-index-settings)是可以随时更新的设置。 + +### 在创建索引时指定设置 + +创建索引时,可以按如下方式指定其静态或动态设置: + +```json +PUT /testindex +{ + "settings": { + "index.number_of_shards": 1, + "index.number_of_replicas": 2 + } +} +``` + +### 静态索引级索引设置 + +OpenSearch 支持以下静态索引级索引设置: + +- `index.number_of_shards`(Integer):索引中主分片的数量。默认值为 1。 + +- `index.number_of_routing_shards`(Integer):用于拆分索引的路由分片数量。 + +- `index.shard.check_on_startup`(Boolean):是否检查索引的分片是否损坏。可用选项为 `false`(不检查损坏)、`checksum`(检查物理损坏)和 `true`(同时检查物理和逻辑损坏)。默认值为 `false`。 + +- `index.codec`(String):决定索引的存储字段如何压缩并存储在磁盘上。此设置会影响索引分片的大小和索引操作的性能。 + + 有效值为: + + - `default` + - `best_compression` + - `zstd`(OpenSearch 2.9 及更高版本) + - `zstd_no_dict`(OpenSearch 2.9 及更高版本) + + 对于 `zstd` 和 `zstd_no_dict`,可以在 `index.codec.compression_level` 设置中指定压缩级别。有关更多信息,请参阅[索引编解码器设置](/im-plugin/index-codecs)。可选。默认值为 `default`。 + +- `index.codec.compression_level`(Integer):压缩级别设置在压缩率和速度之间进行权衡。较高的压缩级别会带来更高的压缩率(更小的存储空间),但代价是速度下降(压缩和解压缩速度变慢,导致索引和搜索延迟增加)。在 OpenSearch 2.9 及更高版本中,仅当 `index.codec` 设置为 `zstd` 和 `zstd_no_dict` 压缩级别时才能指定。有效值为 [1, 6] 范围内的整数。有关更多信息,请参阅[索引编解码器设置](/im-plugin/index-codecs)。可选。默认值为 3。 + +- `index.routing_partition_size`(Integer):自定义路由值可以路由到的分片数量。路由通过将值重新分配到一组分片而不是单个分片,来帮助解决集群不平衡的问题。要启用路由,请将此值设置为大于 1 但小于 `index.number_of_shards`。默认值为 1。 + +- `index.soft_deletes.retention_lease.period`(Time unit):保留分片操作历史的最长时间。默认值为 `12h`。 + +- `index.load_fixed_bitset_filters_eagerly`(Boolean):OpenSearch 是否应预加载缓存的过滤器。可用选项为 `true` 和 `false`。默认值为 `true`。 + +- `index.hidden`(Boolean):是否应隐藏该索引。隐藏索引不会在包含通配符的查询中返回。可用选项为 `true` 和 `false`。默认值为 `false`。 + +- `index.merge.policy`(String):此设置控制 Lucene 段的合并策略。可用选项为 `tiered` 和 `log_byte_size`。默认值为 `tiered`,但对于时间序列数据(例如日志事件),我们建议使用 `log_byte_size` 合并策略,它可以提升对 `@timestamp` 字段执行范围查询时的查询性能。我们建议不要更改现有索引的合并策略,而是在创建新索引时配置此设置。 + +- `index.merge_on_flush.enabled`(Boolean):此设置控制 Apache Lucene 的 merge-on-refresh 功能,该功能旨在通过 _on refresh_(用 OpenSearch 的术语来说是 _on flush_)执行合并来减少段的数量。默认值为 `true`。 + +- `index.merge_on_flush.max_full_flush_merge_wait_time`(Time unit):此设置用于设定启用 `index.merge_on_flush.enabled` 时等待合并的时间。默认值为 `10s`。 + +- `index.merge_on_flush.policy`(default | merge-on-flush):此设置控制启用 `index.merge_on_flush.enabled` 时应使用的合并策略。默认值为 `default`。 + +### 更新静态索引设置 + +只能在已关闭的索引上更新静态索引设置。以下示例演示如何更新索引编解码器设置。 + +首先,关闭索引: + +```json +POST /testindex/_close +``` + +然后通过向 `_settings` 端点发送请求来更新设置: + +```json +PUT /testindex/_settings +{ + "index": { + "codec": "zstd_no_dict", + "codec.compression_level": 3 + } +} +``` + +最后,重新打开索引以启用读写操作: + +```json +POST /testindex/_open +``` + +有关更新设置的更多信息(包括支持的查询参数),请参阅[更新设置](/api-reference/index-apis/update-settings)。 + +### 动态索引级索引设置 + +OpenSearch 支持以下动态索引级索引设置: + +- `index.number_of_replicas`(Integer):每个主分片应具有的副本分片数量。例如,如果有 4 个主分片,并将 `index.number_of_replicas` 设置为 3,则索引有 12 个副本分片。默认值为 1。 + +- `index.auto_expand_replicas`(String):集群是否应根据数据节点的数量自动添加副本分片。指定下限和上限(例如 0--9),或将上限指定为 `all`。例如,如果有 5 个数据节点,并将 `index.auto_expand_replicas` 设置为 0--3,则集群不会自动添加额外的副本分片。但是,如果将此值设置为 `0-all`,并再添加 2 个节点使总数达到 7 个,集群将扩展为拥有 6 个副本分片。默认为禁用。 + +- `index.search.idle.after`(Time unit):分片在没有收到搜索或 get 请求后进入空闲状态之前应等待的时间。默认值为 `30s`。 + +- `index.refresh_interval`(Time unit):索引刷新的频率,刷新会发布最近的更改并使其可被搜索。可以设置为 `-1` 以禁用刷新。默认值为 `1s`。 + +- `index.max_result_window`(Integer):搜索该索引时 `from` + `size` 的最大值。`from` 是开始搜索的起始位置,`size` 是要返回的结果数量。默认值为 10000。 + +- `index.max_inner_result_window`(Integer):`from` + `size` 的最大值,用于指定查询期间返回的嵌套搜索命中和聚合的最相关文档的数量。`from` 是开始搜索的起始位置,`size` 是要返回的最佳命中数量。默认值为 100。 + +- `index.max_rescore_window`(Integer):对该索引发出的重新评分请求中 `window_size` 的最大值。重新评分请求会对索引的文档重新排序并返回新的评分,该评分可能更加精确。默认值与 `index.max_inner_result_window` 相同,或默认为 10000。 + +- `index.max_docvalue_fields_search`(Integer):查询中允许的 `docvalue_fields` 的最大数量。默认值为 100。 + +- `index.max_script_fields`(Integer):查询中允许的 `script_fields` 的最大数量。默认值为 32。 + +- `index.max_ngram_diff`(Integer):`NGramTokenizer` 和 `NGramTokenFilter` 的 `min_gram` 与 `max_gram` 值之间的最大差值。默认值为 1。 + +- `index.max_shingle_diff`(Integer):传给 `shingle` 词元过滤器(Token Filter)的 `max_shingle_size` 与 `min_shingle_size` 之间的最大差值。默认值为 3。 + +- `index.max_refresh_listeners`(Integer):每个分片允许拥有的刷新监听器的最大数量。 + +- `index.analyze.max_token_count`(Integer):`_analyze` API 操作可以返回的最大词元数量。默认值为 10000。 + +- `index.highlight.max_analyzed_offset`(Integer):高亮请求可以分析的字符数。默认值为 1000000。 + +- `index.max_terms_count`(Integer):terms 查询可以接受的最大词项数量。默认值为 65536。 + +- `index.max_regex_length`(Integer):regexp 查询中正则表达式的最大字符长度。默认值为 1000。 + +- `index.query.default_field`(List):当参数中未指定字段时,OpenSearch 在查询中使用的一个字段或字段列表。 + +- `index.routing.allocation.enable`(String):指定索引分片分配的选项。可用选项为 `all`(允许为所有分片分配)、`primaries`(仅允许为主分片分配)、`new_primaries`(仅允许为新的主分片分配)和 `none`(不允许分配)。默认值为 `all`。 + +- `index.routing.rebalance.enable`(String):为索引启用分片重新平衡。可用选项为 `all`(允许对所有分片重新平衡)、`primaries`(仅允许对主分片重新平衡)、`replicas`(仅允许对副本重新平衡)和 `none`(不允许重新平衡)。默认值为 `all`。 + +- `index.gc_deletes`(Time unit):保留已删除文档版本号的时间。默认值为 `60s`。 + +- `index.default_pipeline`(String):索引的默认摄取节点管道。如果设置了默认管道但该管道不存在,则索引请求将失败。管道名称 `_none` 表示该索引没有摄取管道(Ingest Pipeline)。 + +- `index.final_pipeline`(String):索引的最终摄取节点管道。如果设置了最终管道但该管道不存在,则索引请求将失败。管道名称 `_none` 表示该索引没有摄取管道。 + +- `index.optimize_doc_id_lookup.fuzzy_set.enabled`(Boolean):此设置控制是否启用 `fuzzy_set`,以便通过使用额外的数据结构(在本例中为 Bloom 过滤器数据结构)来优化索引或搜索调用中的文档 ID 查找。启用此设置会创建一个新的数据结构(Bloom 过滤器),从而提升依赖文档 ID 的 upsert 和搜索操作的性能。Bloom 过滤器可以通过更快的堆外查找来处理否定情况(即 ID 不存在于现有索引中)。默认值为 `false`。仅当功能标志 `opensearch.experimental.optimize_doc_id_lookup.fuzzy_set.enabled` 设置为 `true` 时,才能使用此设置。 + +- `index.optimize_doc_id_lookup.fuzzy_set.false_positive_probability`(Double):设置底层 `fuzzy_set`(即 Bloom 过滤器)的误报概率。较低的误报概率可以确保 `UPSERT` 和 `GET` 操作获得更高的吞吐量。允许的值范围为 `0.01` 到 `0.50`。默认值为 `0.20`。仅当功能标志 `opensearch.experimental.optimize_doc_id_lookup.fuzzy_set.enabled` 设置为 `true` 时,才能使用此设置。 + +### 更新动态索引设置 + +你可以随时通过 API 更新动态索引设置。例如,要更新刷新间隔,请使用以下请求: + +```json +PUT /testindex/_settings +{ + "index": { + "refresh_interval": "2s" + } +} +``` + +有关更新设置的更多信息(包括支持的查询参数),请参阅[更新设置](/api-reference/index-apis/update-settings)。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/index.md b/i18n/zh/install-and-configure/configuring-opensearch/index.md new file mode 100644 index 00000000..e959b3dd --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/index.md @@ -0,0 +1,106 @@ +--- +title: 配置 OpenSearch +--- + +# 配置 OpenSearch + +OpenSearch 设置分为两种类型:[动态设置](#dynamic-settings)和[静态设置](#static-settings)。 + +## 动态设置 + +动态索引设置是可以随时更新的设置。你可以通过 Cluster Settings API 配置 OpenSearch 的动态设置。有关详细信息,请参阅[使用 API 更新集群设置](#updating-cluster-settings-using-the-api)。 + +::: tip 提示 +尽可能使用 Cluster Settings API:`opensearch.yml` 只作用于各自所在的节点,而 API 会将设置应用于集群中的所有节点。 +::: + +## 静态设置 + +某些操作是静态的,需要你修改 `opensearch.yml` [配置文件](#configuration-file)并重启集群。一般来说,这些设置与网络、集群组建和本地文件系统相关。要了解更多信息,请参阅[集群组建](/tuning-your-cluster/)。 + +## 以环境变量的形式指定设置 + +启动 OpenSearch 时,你可以使用 `-E` 将环境变量指定为参数: + +```bash +./opensearch -Ecluster.name=opensearch-cluster -Enode.name=opensearch-node1 -Ehttp.host=0.0.0.0 -Ediscovery.type=single-node +``` + +## 使用 API 更新集群设置 + +更改设置的第一步是发送以下请求,查看当前设置: + +```json +GET _cluster/settings?include_defaults=true +``` + +如需更简洁的非默认设置摘要,请发送以下请求: + +```json +GET _cluster/settings +``` + +Cluster Settings API 中存在三类设置:持久(persistent)设置、临时(transient)设置和默认(default)设置。顾名思义,持久设置在集群重启后仍然保留。重启后,OpenSearch 会清除临时设置。 + +如果在多个位置指定了同一个设置,OpenSearch 将按以下优先级使用: + +1. 临时设置 +2. 持久设置 +3. `opensearch.yml` 中的设置 +4. 默认设置 + +要更改设置,请使用 [Cluster Settings API](/api-reference/cluster-api/cluster-settings),并将新值指定为持久或临时设置。以下示例展示了扁平设置格式: + +```json +PUT _cluster/settings +{ + "persistent" : { + "action.auto_create_index" : false + } +} +``` + +你也可以使用展开格式,这样可以直接从 GET 响应中复制粘贴并修改现有值: + +```json +PUT _cluster/settings +{ + "persistent": { + "action": { + "auto_create_index": false + } + } +} +``` + +--- + +## 配置文件 + +在每个节点上,你可以在 `/usr/share/opensearch/config/opensearch.yml`(Docker)或 `/etc/opensearch/opensearch.yml`(大多数 Linux 发行版)中找到 `opensearch.yml`。 + +你可以编辑 `OPENSEARCH_PATH_CONF=/etc/opensearch` 来更改配置目录的位置。该变量来源于 `/etc/default/opensearch`(Debian 软件包)和 `/etc/sysconfig/opensearch`(RPM 软件包)。 + +如果你设置了自定义的 `OPENSEARCH_PATH_CONF` 变量,请注意其他默认环境变量将不会被加载。 + +在 `opensearch.yml` 中无需将设置标记为持久或临时,并且设置使用扁平格式: + +```yml +cluster.name: my-application +action.auto_create_index: true +compatibility.override_main_response_version: true +``` + +演示配置中包含许多 [Security 插件设置](/install-and-configure/configuring-opensearch/security-settings),在将 OpenSearch 用于生产工作负载之前,你应该修改这些设置。要了解更多信息,请参阅[安全](/security/)。 + +### (可选)CORS 标头配置 + +如果你正在开发的客户端应用程序要访问位于不同域上的 OpenSearch 集群,可以在 `opensearch.yml` 中配置标头,以便在同一台机器上开发本地应用程序。使用[跨源资源共享(Cross Origin Resource Sharing)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS),使你的应用程序能够调用本地运行的 OpenSearch API。在 `custom-opensearch.yml` 文件中添加以下行(注意每行的第一个字符必须是 "-")。 +```yml +- http.host:0.0.0.0 +- http.port:9200 +- http.cors.allow-origin:"http://localhost" +- http.cors.enabled:true +- http.cors.allow-headers:X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization +- http.cors.allow-credentials:true +``` diff --git a/i18n/zh/install-and-configure/configuring-opensearch/logs.md b/i18n/zh/install-and-configure/configuring-opensearch/logs.md new file mode 100644 index 00000000..dc7345b1 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/logs.md @@ -0,0 +1,235 @@ +--- +title: 日志 +--- + +# 日志 + +OpenSearch 日志包含了监控集群运行和排查问题的宝贵信息。日志的位置因安装类型而异: + +- 在 Docker 上,OpenSearch 将大部分日志写入控制台,其余日志存储在 `opensearch/logs/` 中。tarball 安装也使用 `opensearch/logs/`。 +- 在大多数 Linux 安装中,OpenSearch 将日志写入 `/var/log/opensearch/`。 + +日志以 `.log`(纯文本)和 `.json` 文件的形式提供。OpenSearch 日志的权限默认为 `-rw-r--r--`,这意味着节点上的任何用户账户都可以读取它们。你可以在 `log4j2.properties` 中使用 `filePermissions` 选项_针对每种日志类型_更改此行为。例如,你可以添加 `appender.rolling.filePermissions = rw-r-----` 来更改 JSON 服务器日志的权限。有关详细信息,请参阅 [Log4j 2 文档](https://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender)。 + +## 应用程序日志 + +对于应用程序日志,OpenSearch 使用 [Apache Log4j 2](https://logging.apache.org/log4j/2.x/) 及其内置日志级别(按严重程度从低到高排列)。下表介绍了日志设置。 + +| 设置 | 数据类型 | 描述 | +| :--- | :--- | :--- | +| `logger.org.opensearch.discovery` | String | 日志记录器接受 Log4j2 的内置日志级别:`OFF`、`FATAL`、`ERROR`、`WARN`、`INFO`、`DEBUG` 和 `TRACE`。默认值为 `INFO`。 | + +与其更改默认日志级别(`logger.level`),不如更改单个 OpenSearch 模块的日志级别: + +```json +PUT /_cluster/settings +{ + "persistent" : { + "logger.org.opensearch.index.reindex" : "DEBUG" + } +} +``` + +::: tip 提示 +识别模块最简单的方法不是查看日志(日志会缩写路径,例如 `o.o.i.r`),而是查看 [OpenSearch 源代码](https://github.com/opensearch-project/opensearch/tree/master/server/src/main/java/org/opensearch)。 +::: + +完成上述示例更改后,OpenSearch 会在重新索引操作期间输出更为详细的日志: + +```plaintext +[2019-10-18T16:52:51,184][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: starting +[2019-10-18T16:52:51,186][DEBUG][o.o.i.r.TransportReindexAction] [node1] executing initial scroll against [some-index] +[2019-10-18T16:52:51,291][DEBUG][o.o.i.r.TransportReindexAction] [node1] scroll returned [3] documents with a scroll id of [DXF1Z==] +[2019-10-18T16:52:51,292][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: got scroll response with [3] hits +[2019-10-18T16:52:51,294][DEBUG][o.o.i.r.WorkerBulkByScrollTaskState] [node1] [1626]: preparing bulk request for [0s] +[2019-10-18T16:52:51,297][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: preparing bulk request +[2019-10-18T16:52:51,299][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: sending [3] entry, [222b] bulk request +[2019-10-18T16:52:51,310][INFO ][o.e.c.m.MetaDataMappingService] [node1] [some-new-index/R-j3adc6QTmEAEb-eAie9g] create_mapping [_doc] +[2019-10-18T16:52:51,383][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: got scroll response with [0] hits +[2019-10-18T16:52:51,384][DEBUG][o.o.i.r.WorkerBulkByScrollTaskState] [node1] [1626]: preparing bulk request for [0s] +[2019-10-18T16:52:51,385][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: preparing bulk request +[2019-10-18T16:52:51,386][DEBUG][o.o.i.r.TransportReindexAction] [node1] [1626]: finishing without any catastrophic failures +[2019-10-18T16:52:51,395][DEBUG][o.o.i.r.TransportReindexAction] [node1] Freed [1] contexts +``` + +DEBUG 和 TRACE 级别的日志极其冗长。如果你为了排查问题而启用了其中任何一个级别,请在完成后将其禁用。 + +还有其他方法可以更改日志级别: + +1. 在 `opensearch.yml` 中添加以下行: + + ```yml + logger.org.opensearch.index.reindex: debug + ``` + + 如果你想在多个集群之间复用日志配置,或者调试单个节点的启动问题,修改 `opensearch.yml` 是最合适的做法。 + +2. 修改 `log4j2.properties`: + + ```properties + # 定义一个唯一 ID 为 reindex 的新日志记录器 + logger.reindex.name = org.opensearch.index.reindex + # 为该 ID 设置日志级别 + logger.reindex.level = debug + ``` + + 这种方法非常灵活,但需要熟悉 [Log4j 2 属性文件语法](https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties)。一般来说,其他选项提供的配置体验更为简单。 + + 如果你查看配置目录中默认的 `log4j2.properties` 文件,可以看到一些 OpenSearch 特有的变量: + + ```properties + appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n + appender.rolling_old.fileName = ${sys:opensearch.logs.base_path}${sys:file.separator}${sys:opensearch.logs.cluster_name}.log + ``` + + - `${sys:opensearch.logs.base_path}` 是日志目录(例如 `/var/log/opensearch/`)。 + - `${sys:opensearch.logs.cluster_name}` 是集群的名称。 + - `[%node_name]` 是节点的名称。 + +## 搜索请求慢日志 + +从 2.12 版本开始,OpenSearch 提供了请求级别的搜索慢日志。这些日志依靠阈值来定义什么算作「慢」。所有超过阈值的请求都会被记录。 + +搜索请求慢日志可以通过 [Cluster Settings API](/api-reference/cluster-api/cluster-settings) 动态启用。与分片慢日志不同,搜索请求慢日志的阈值是针对请求的总耗时配置的。默认情况下,日志处于禁用状态(所有阈值都设置为 `-1`)。 + +```json +PUT /_cluster/settings +{ +"persistent" : { + "cluster.search.request.slowlog.level" : "TRACE", + "cluster.search.request.slowlog.threshold.warn": "10s", + "cluster.search.request.slowlog.threshold.info": "5s", + "cluster.search.request.slowlog.threshold.debug": "2s", + "cluster.search.request.slowlog.threshold.trace": "10ms" +} +} +``` + +`opensearch_index_search_slowlog.log` 中的一行可能如下所示: + +```plaintext +[2023-10-30T15:47:42,630][TRACE][c.s.r.slowlog] [runTask-0] took[80.8ms], took_millis[80], phase_took_millis[{expand=0, query=39, fetch=22}], total_hits[4 hits], search_type[QUERY_THEN_FETCH], shards[{total: 10, successful: 10, skipped: 0, failed: 0}], source[{"query":{"match_all":{"boost":1.0}}}], id[] +``` + +::: warning 重要 +如果设置的阈值较低,搜索请求慢日志可能会占用大量磁盘空间并影响性能。建议仅在排查问题或进行性能调优时临时启用。要禁用搜索请求慢日志,请将所有阈值恢复为 `-1`。 +::: + +## 分片慢日志 + +OpenSearch 有两种*分片慢日志*,用于帮助你识别性能问题:搜索慢日志和索引慢日志。 + +这些日志依靠阈值来定义什么算作「慢」搜索或「慢」索引操作。例如,你可以规定一个查询如果需要超过 15 秒才能完成,就算是慢查询。与针对模块配置的应用程序日志不同,慢日志是针对索引配置的。默认情况下,两种日志都处于禁用状态(所有阈值都设置为 `-1`)。 + +与搜索请求慢日志不同,分片慢日志的阈值是针对单个分片的耗时配置的。 + +```json +GET /_settings?include_defaults=true +{ + "indexing": { + "slowlog": { + "reformat": "true", + "threshold": { + "index": { + "warn": "-1", + "trace": "-1", + "debug": "-1", + "info": "-1" + } + }, + "source": "1000", + "level": "TRACE" + } + }, + "search": { + "slowlog": { + "level": "TRACE", + "threshold": { + "fetch": { + "warn": "-1", + "trace": "-1", + "debug": "-1", + "info": "-1" + }, + "query": { + "warn": "-1", + "trace": "-1", + "debug": "-1", + "info": "-1" + } + } + } + } +} +``` + +要启用这些日志,请提高一个或多个阈值: + +```json +PUT /_settings +{ + "indexing": { + "slowlog": { + "threshold": { + "index": { + "warn": "15s", + "trace": "750ms", + "debug": "3s", + "info": "10s" + } + }, + "source": "500", + "level": "INFO" + } + } +} +``` + +在此示例中,OpenSearch 会以 WARN 级别记录耗时 15 秒或更长时间的索引操作,以 INFO 级别记录耗时 10 到 14.*x* 秒的操作。如果将阈值设置为 0 秒,OpenSearch 会记录所有操作,这对于测试慢日志是否确实已启用非常有用。 + +- `reformat` 指定是将文档的 `_source` 字段记录为单行(`true`),还是允许其跨越多行(`false`)。 +- `source` 是要记录的文档 `_source` 字段的字符数。 +- `level` 是要包含的最低日志级别。 + +`opensearch_index_indexing_slowlog.log` 中的一行可能如下所示: + +```plaintext +node1 | [2019-10-24T19:48:51,012][WARN][i.i.s.index] [node1] [some-index/i86iF5kyTyy-PS8zrdDeAA] took[3.4ms], took_millis[3], type[_doc], id[1], routing[], source[{"title":"Your Name", "Director":"Makoto Shinkai"}] +``` + +如果设置的阈值较低,分片慢日志可能会占用大量磁盘空间并影响性能。建议仅在排查问题或进行性能调优时临时启用。要禁用分片慢日志,请将所有阈值恢复为 `-1`。 + +## 任务日志 + +启用任务资源消费者(task resource consumers)后,OpenSearch 可以记录内存开销最大的前 N 个搜索任务的 CPU 时间和内存使用情况。默认情况下,任务资源消费者会每隔 60 秒记录前 10 个搜索任务。这些值可以在 `opensearch.yml` 中配置。 + +任务日志可以通过 [Cluster Settings API](/api-reference/cluster-api/cluster-settings) 动态启用: + +```json +PUT _cluster/settings +{ + "persistent" : { + "task_resource_consumers.enabled" : "true" + } +} +``` + +::: tip 提示 +启用任务资源消费者可能会影响搜索延迟。 +::: + +启用后,日志将写入 `logs/opensearch_task_detailslog.json` 和 `logs/opensearch_task_detailslog.log`。 + +要配置日志记录间隔和记录的搜索任务数量,请在 `opensearch.yml` 中添加以下行: + +```yaml +# 要记录的高开销搜索任务数量 +cluster.task.consumers.top_n.size:100 + +# 日志记录间隔 +cluster.task.consumers.top_n.frequency:30s +``` + +## 弃用日志 + +弃用日志记录客户端何时对集群发出了已弃用的 API 调用。这些日志可以帮助你在升级到新的主版本之前发现并修复问题。默认情况下,OpenSearch 以 WARN 级别记录已弃用的 API 调用,这几乎适用于所有用例。如有需要,可以使用 `_cluster/settings`、`opensearch.yml` 或 `log4j2.properties` 配置 `logger.deprecation.level`。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/network-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/network-settings.md new file mode 100644 index 00000000..f8f9b41b --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/network-settings.md @@ -0,0 +1,56 @@ +--- +title: 网络设置 +--- + +# 网络设置 + +OpenSearch 使用 HTTP 设置来配置通过 REST API 与外部客户端的通信,并使用传输(transport)设置来配置 OpenSearch 内部节点之间的通信。 + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +OpenSearch 支持以下常用网络设置: + +- `network.host`(静态,list):将 OpenSearch 节点绑定到一个地址。使用 `0.0.0.0` 可包含所有可用的网络接口,也可以指定分配给特定接口的 IP 地址。如果 `network.bind_host` 和 `network.publish_host` 的值相同,`network.host` 设置就是这两者的组合。作为 `network.host` 的替代方案,你可以根据需要分别配置 `network.bind_host` 和 `network.publish_host`。请参阅[高级网络设置](#advanced-network-settings)。 + +- `http.port`(静态,single value or range):将 OpenSearch 节点绑定到用于 HTTP 通信的自定义端口或端口范围。你可以指定一个地址或地址范围。默认值为 `9200-9300`。 + +- `transport.port`(静态,single value or range):将 OpenSearch 节点绑定到用于节点间通信的自定义端口。你可以指定一个地址或地址范围。默认值为 `9300-9400`。 + +## 高级网络设置 + +OpenSearch 支持以下高级网络设置: + +- `network.bind_host`(静态,list):将 OpenSearch 节点绑定到一个或多个地址,用于接收传入连接。默认值为 `network.host` 中的值。 + +- `network.publish_host`(静态,list):指定 OpenSearch 节点向集群中其他节点发布的一个或多个地址,以便其他节点可以连接到该节点。 + +## 高级 HTTP 设置 + +OpenSearch 支持以下用于 HTTP 通信的高级网络设置: + +- `http.host`(静态,list):设置 OpenSearch 节点用于 HTTP 通信的地址。如果 `http.bind_host` 和 `http.publish_host` 的值相同,`http.host` 设置就是这两者的组合。作为 `http.host` 的替代方案,你可以根据需要分别配置 `http.bind_host` 和 `http.publish_host`。 + +- `http.bind_host`(静态,list):指定 OpenSearch 节点绑定以监听传入 HTTP 连接的一个或多个地址。 + +- `http.publish_host`(静态,list):指定 OpenSearch 节点向其他节点发布的、用于 HTTP 通信的一个或多个地址。 + +- `http.compression`(静态,Boolean):在适用时启用使用 `Accept-Encoding` 的压缩支持。启用 `HTTPS` 时,默认值为 `false`,否则默认值为 `true`。为 HTTPS 禁用压缩有助于降低潜在的安全风险,例如 `BREACH` 攻击。要为 HTTPS 流量启用压缩,请将 `http.compression` 显式设置为 `true`。 + +## 高级传输设置 + +OpenSearch 支持以下用于传输通信的高级网络设置: + +- `transport.host`(静态,list):设置 OpenSearch 节点用于传输通信的地址。如果 `transport.bind_host` 和 `transport.publish_host` 的值相同,`transport.host` 设置就是这两者的组合。作为 `transport.host` 的替代方案,你可以根据需要分别配置 `transport.bind_host` 和 `transport.publish_host`。 + +- `transport.bind_host`(静态,list):指定 OpenSearch 节点绑定以监听传入传输连接的一个或多个地址。 + +- `transport.publish_host`(静态,list):指定 OpenSearch 节点向其他节点发布的、用于传输通信的一个或多个地址。 + +## 选择传输模块 + +OpenSearch 的默认传输由 `transport-netty4` 模块提供,它使用 [Netty 4](https://netty.io/) 引擎来处理集群中节点之间基于 TCP 的内部通信,以及与客户端之间基于 HTTP 的外部通信。这种通信是完全异步且非阻塞的。不过,还有其他可互换使用的传输插件: + +插件 | 描述 +:---------- | :-------- +`transport-nio` | 基于 Java NIO 的 OpenSearch 传输。
安装:`./bin/opensearch-plugin install transport-nio`
配置(使用 `opensearch.yml`):
`transport.type: nio-transport`
`http.type: nio-http-transport` +`transport-reactor-netty4` | 基于 [Project Reactor](https://github.com/reactor/reactor-netty) 和 Netty 4 的 OpenSearch HTTP 传输(**实验性**)
安装:`./bin/opensearch-plugin install transport-reactor-netty4`
配置(使用 `opensearch.yml`):
`http.type: reactor-netty4` diff --git a/i18n/zh/install-and-configure/configuring-opensearch/plugin-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/plugin-settings.md new file mode 100644 index 00000000..8407f393 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/plugin-settings.md @@ -0,0 +1,97 @@ +--- +title: 插件设置 +--- + +# 插件设置 + +以下设置与 OpenSearch 插件(plugin)相关。 + +## Alerting 插件设置 + +有关告警设置的信息,请参阅[告警设置](/observing-your-data/alerting/settings#alerting-settings)。 + +## Anomaly Detection 插件设置 + +有关异常检测设置的信息,请参阅[异常检测设置](/observing-your-data/ad/settings)。 + +## Asynchronous Search 插件设置 + +有关异步搜索设置的信息,请参阅[异步搜索设置](/search-plugins/async/settings)。 + +## Cross-Cluster Replication 插件设置 + +有关跨集群复制设置的信息,请参阅[复制设置](/tuning-your-cluster/replication-plugin/settings)。 + +## Flow Framework 插件设置 + +有关自动化工作流设置的信息,请参阅[工作流设置](/automating-configurations/workflow-settings)。 + +## Geospatial 插件设置 + +有关 Geospatial 插件的 IP2Geo 处理器设置的信息,请参阅[集群设置](/ingest-pipelines/processors/ip2geo#cluster-settings)。 + +## Index Management 插件设置 + +有关索引状态管理(Index State Management,ISM)设置的信息,请参阅 [ISM 设置](/im-plugin/ism/settings)。 + +### 索引汇总设置 + +有关索引汇总(rollup)设置的信息,请参阅[索引汇总设置](/im-plugin/index-rollups/settings)。 + +## Job Scheduler 插件设置 + +有关 Job Scheduler 插件设置的信息,请参阅 [Job Scheduler 集群设置](/monitoring-your-cluster/job-scheduler/#job-scheduler-cluster-settings)。 + +## k-NN 插件设置 + +有关 k-NN 设置的信息,请参阅 [k-NN 设置](/search-plugins/knn/settings)。 + +## ML Commons 插件设置 + +有关机器学习设置的信息,请参阅 [ML Commons 集群设置](/ml-commons-plugin/cluster-settings)。 + +## Neural Search 插件设置 + +Security Analytics 插件支持以下设置: + +- `plugins.neural_search.hybrid_search_disabled`(动态,Boolean):禁用混合搜索(Hybrid Search)。默认值为 `false`。 + +## Notifications 插件设置 + +Notifications 插件支持以下设置。此列表中的所有设置都是动态的: + +- `opensearch.notifications.core.allowed_config_types`(List):Notifications 插件允许的配置类型。使用 `GET /_plugins/_notifications/features` API 获取此设置的值。配置类型包括 `slack`、`chime`、`microsoft_teams`、`webhook`、`email`、`sns`、`ses_account`、`smtp_account` 和 `email_group`。 + +- `opensearch.notifications.core.email.minimum_header_length`(Integer):最小电子邮件标头长度。用于验证电子邮件消息的总长度。默认值为 `160`。 + +- `opensearch.notifications.core.email.size_limit`(Integer):电子邮件大小限制。用于验证电子邮件消息的总长度。默认值为 `10000000`。 + +- `opensearch.notifications.core.http.connection_timeout`(Integer):内部 HTTP 客户端的连接超时时间。该客户端用于基于 webhook 的通知渠道。默认值为 `5000`。 + +- `opensearch.notifications.core.http.host_deny_list`(List):被拒绝的主机列表。HTTP 客户端不会向此列表中的 webhook URL 发送通知。 + +- `opensearch.notifications.core.http.max_connection_per_route`(Integer):内部 HTTP 客户端每个路由的最大 HTTP 连接数。该客户端用于基于 webhook 的通知渠道。默认值为 `20`。 + +- `opensearch.notifications.core.http.max_connections`(Integer):内部 HTTP 客户端的最大 HTTP 连接数。该客户端用于基于 webhook 的通知渠道。默认值为 `60`。 + +- `opensearch.notifications.core.http.socket_timeout`(Integer):内部 HTTP 客户端的套接字超时配置。该客户端用于基于 webhook 的通知渠道。默认值为 `50000`。 + +- `opensearch.notifications.core.tooltip_support`(Boolean):为 Notifications 插件启用工具提示支持。使用 `GET /_plugins/_notifications/features` API 获取此设置的值。默认值为 `true`。 + +- `opensearch.notifications.general.filter_by_backend_roles`(Boolean):启用按后端角色过滤(通知渠道的基于角色的访问控制)。默认值为 `false`。 + +## Query Insights 插件设置 + +有关 Query Insights 插件设置的信息,请参阅[查询洞察设置](/observing-your-data/query-insights/#query-insights-settings)。 + +## Security 插件设置 + +有关 Security 插件设置的信息,请参阅[安全设置](/install-and-configure/configuring-opensearch/security-settings)。 + +## Security Analytics 插件设置 + +有关安全分析设置的信息,请参阅 [Security Analytics 设置](/security-analytics/settings)。 + +## SQL 插件设置 + +有关 SQL 和 PPL 相关设置的信息,请参阅 [SQL 设置](/search-plugins/sql/settings)。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/search-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/search-settings.md new file mode 100644 index 00000000..a6cbe1b8 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/search-settings.md @@ -0,0 +1,39 @@ +--- +title: 搜索设置 +--- + +# 搜索设置 + +OpenSearch 支持以下搜索设置: + +- `search.max_buckets`(动态,integer):单个响应中允许的最大聚合桶数量。默认值为 `65535`。 + +- `search.phase_took_enabled`(动态,Boolean):允许在搜索响应中返回阶段级别的 `took` 耗时值。默认值为 `false`。 + +- `search.allow_expensive_queries`(动态,Boolean):允许或禁止开销大的查询。有关更多信息,请参阅[开销大的查询](/query-dsl/#expensive-queries)。 + +- `search.default_allow_partial_results`(动态,Boolean):一个集群级设置,允许在请求超时或分片失败时返回部分搜索结果。如果搜索请求包含 `allow_partial_search_results` 参数,则该参数优先于此设置。默认值为 `true`。 + +- `search.cancel_after_time_interval`(动态,time unit):一个集群级设置,指定搜索请求在分片级别被取消之前可以运行的最长时间。达到该时间后,请求将被停止,所有相关任务都会被取消。默认值为 `-1`。 + +- `search.default_search_timeout`(动态,time unit):一个集群级设置,在协调节点级别为所有搜索请求设置默认超时时间。如果搜索请求中指定了 `timeout`,则其优先于此设置。默认值为 `-1`(不超时)。 + +- `search.default_keep_alive`(动态,time unit):指定 scroll 和时间点(Point in Time,PIT)搜索的默认保活值。由于一个请求可能会多次到达同一个分片(例如在查询阶段和获取阶段),OpenSearch 会打开一个在请求整个持续期间都存在的_请求上下文_,以确保每个分片请求的分片状态一致。在标准搜索中,获取阶段完成后,请求上下文就会关闭。对于 scroll 或 PIT 搜索,OpenSearch 会保持请求上下文处于打开状态,直到显式关闭(或达到保活时间)。一个后台线程会定期检查所有打开的 scroll 和 PIT 上下文,并删除超过保活超时时间的上下文。`search.keep_alive_interval` 设置指定检查上下文是否过期的频率。`search.default_keep_alive` 设置是默认的过期期限。scroll 或 PIT 请求可以显式指定保活时间,其优先于此设置。默认值为 `5m`。 + +- `search.keep_alive_interval`(静态,time unit):决定 OpenSearch 检查超过保活限制的请求上下文的时间间隔。默认值为 `1m`。 + +- `search.max_keep_alive`(动态,time unit):指定最大保活值。`max_keep_alive` 设置用作对其他 `keep_alive` 设置(例如 `default_keep_alive`)以及请求级保活设置(针对 scroll 和 PIT 上下文)的安全检查。无论哪种情况,如果请求超过 `max_keep_alive` 值,操作都将失败。默认值为 `24h`。 + +- `search.low_level_cancellation`(动态,Boolean):启用低级别请求取消。Lucene 的经典超时机制只在收集搜索结果时检查时间。然而,开销大的查询(例如 wildcard 或 prefix 查询)在开始收集结果之前可能需要很长时间进行扩展。在这种情况下,查询的运行时间可能超过超时值。低级别取消机制解决了这一问题:它不仅在收集搜索结果时会超时,在查询扩展阶段或执行任何 Lucene 操作之前也会超时。默认值为 `true`。 + +- `search.max_open_scroll_context`(动态,integer):一个节点级设置,指定节点打开的 scroll 上下文的最大数量。默认值为 `500`。 + +- `search.request_stats_enabled`(动态,Boolean):从协调节点的角度开启节点级阶段耗时统计信息的收集。请求级统计信息会记录搜索请求在各个搜索阶段中(总共)花费的时间。你可以使用 [Nodes Stats API](/api-reference/nodes-apis/nodes-stats) 获取这些计数器。默认值为 `false`。 + +- `search.highlight.term_vector_multi_value`(静态,Boolean):指定跨多值字段的各个值高亮片段。默认值为 `true`。 + +## 时间点设置 + +有关 PIT 设置的信息,请参阅 [PIT 设置](/search-plugins/searching-data/point-in-time-api#pit-settings)。 + +要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 diff --git a/i18n/zh/install-and-configure/configuring-opensearch/security-settings.md b/i18n/zh/install-and-configure/configuring-opensearch/security-settings.md new file mode 100644 index 00000000..4d409244 --- /dev/null +++ b/i18n/zh/install-and-configure/configuring-opensearch/security-settings.md @@ -0,0 +1,484 @@ +--- +title: 安全设置 +--- + +# 安全设置 + +Security 插件(plugin)提供了许多 YAML 配置文件,用于存储必要的设置,这些设置定义了 Security 插件如何管理集群(Cluster)中的用户、角色(role)和活动。有关 Security 插件配置文件的完整列表,请参阅[修改 YAML 文件](/security/configuration/yaml)。 + +以下各节介绍 `opensearch.yml` 中与安全相关的设置。要了解有关静态设置和动态设置的更多信息,请参阅[配置 OpenSearch](/install-and-configure/configuring-opensearch/)。 + +## 通用设置 + +Security 插件支持以下通用设置: + +- `plugins.security.nodes_dn`(静态):指定一个可分辨名称(Distinguished Name,DN)列表,用于标识集群中的其他节点(Node)。此设置支持通配符和正则表达式。当 `plugins.security.nodes_dn_dynamic_config_enabled` 为 `true` 时,**除了** YAML 配置之外,还会从安全索引(Index)中读取 DN 列表。 + +- `plugins.security.nodes_dn_dynamic_config_enabled`(静态):适用于 `cross_cluster` 场景,在这类场景中需要管理允许列表中的 `nodes_dn`,而无需在每次配置新的 `cross_cluster` 远程集群时重启节点。 + 将 `nodes_dn_dynamic_config_enabled` 设置为 `true` 会启用**仅超级管理员可调用**的 Distinguished Names API,该 API 提供了动态更新或获取 `nodes_dn` 的方法。仅当未设置 `plugins.security.cert.intercluster_request_evaluator_class` 时,此设置才会生效。默认值为 `false`。 + +- `plugins.security.authcz.admin_dn`(静态):定义应被授予管理员权限的证书的 DN。必需。 + +- `plugins.security.roles_mapping_resolution`(静态):定义后端角色如何映射到 Security 角色。 + + 有效值为: + - `MAPPING_ONLY`(默认):必须在 `roles_mapping.yml` 中显式配置映射。 + - `BACKENDROLES_ONLY`:后端角色直接映射到安全角色。`roles_mapping.yml` 中的设置不起作用。 + - `BOTH`:后端角色既直接映射到安全角色,也通过 `roles_mapping.yml` 进行映射。 + +- `plugins.security.dls.mode`(静态):设置文档级安全(Document-level Security,DLS)的评估模式。默认值为 `adaptive`。请参阅[如何设置 DLS 评估模式](/security/access-control/document-level-security#how-to-set-the-dls-evaluation-mode-in-opensearchyml)。 + +- `plugins.security.compliance.salt`(静态):为字段掩码生成哈希值时使用的盐值。长度至少为 32 个字符,只允许使用 ASCII 字符。可选。 + +- `config.dynamic.http.anonymous_auth_enabled`(静态):启用匿名认证。这将使所有 HTTP 认证器都不发起认证质询。默认值为 `false`。 + +## REST 管理 API 设置 + +Security 插件支持以下 REST 管理 API 设置: + +- `plugins.security.restapi.roles_enabled`(静态):为列出的角色启用基于角色的 REST 管理 API 访问。角色之间以逗号分隔。默认值为空列表(不允许任何角色访问 REST 管理 API)。请参阅 [API 的访问控制](/security/access-control/api#access-control-for-the-api)。 + +- `plugins.security.restapi.endpoints_disabled..`(静态):为角色禁用特定的端点及其 HTTP 方法。此设置的值是一个由 HTTP 方法组成的数组。例如:`plugins.security.restapi.endpoints_disabled.all_access.ACTIONGROUPS: ["PUT","POST","DELETE"]`。默认情况下,允许所有端点和方法。现有端点包括 `ACTIONGROUPS`、`CACHE`、`CONFIG`、`ROLES`、`ROLESMAPPING`、`INTERNALUSERS`、`SYSTEMINFO`、`PERMISSIONSINFO` 和 `LICENSE`。请参阅 [API 的访问控制](/security/access-control/api#access-control-for-the-api)。 + +- `plugins.security.restapi.password_validation_regex`(静态):指定一个正则表达式,用于设置登录密码的规则。有关更多信息,请参阅[密码设置](/security/configuration/yaml#password-settings)。 + +- `plugins.security.restapi.password_validation_error_message`(静态):指定密码未通过验证时显示的错误消息。此设置与 `plugins.security.restapi.password_validation_regex` 配合使用。 + +- `plugins.security.restapi.password_min_length`(静态):设置使用基于评分的密码强度评估器时密码的最小字符数。默认值为 8,这也是最小值。有关更多信息,请参阅[密码设置](/security/configuration/yaml#password-settings)。 + +- `plugins.security.restapi.password_score_based_validation_strength`(静态):设置用于判断密码强弱的阈值。有效值为 `fair`、`good`、`strong` 和 `very_strong`。此设置与 `plugins.security.restapi.password_min_length` 配合使用。 + +- `plugins.security.unsupported.restapi.allow_securityconfig_modification`(静态):允许对配置 API 使用 PUT 和 PATCH 方法。 + +## 高级设置 + +Security 插件支持以下高级设置: + +- `plugins.security.authcz.impersonation_dn`(静态):启用传输层模拟。这允许 DN 模拟其他用户。请参阅[用户模拟](/security/access-control/impersonation)。 + +- `plugins.security.authcz.rest_impersonation_user`(静态):启用 REST 层模拟。这允许用户模拟其他用户。请参阅[用户模拟](/security/access-control/impersonation)。 + +- `plugins.security.allow_default_init_securityindex`(静态):设置为 `true` 时,如果配置索引不存在,OpenSearch Security 会使用 `/config` 目录中的文件自动初始化该索引。 + + ::: danger 警告 + 这将使用众所周知的默认密码。仅可在私有网络/环境中使用。 + ::: + +- `plugins.security.allow_unsafe_democertificates`(静态):设置为 `true` 时,OpenSearch 会使用演示证书启动。这些证书仅用于演示目的。 + + ::: danger 警告 + 这些证书是公开已知的,因此在生产环境中并不安全。仅可在私有网络/环境中使用。 + ::: + +- `plugins.security.system_indices.permission.enabled`(静态):启用系统索引权限(permission)功能。设置为 `true` 时启用该功能,拥有修改角色权限的用户可以创建包含授予系统索引访问权限的角色。设置为 `false` 时禁用该权限,只有持有管理员证书的管理员才能更改系统索引。在新集群中,该权限默认设置为 `false`。 + +## 专家级设置 + +::: danger 警告 +专家级设置只应由完全了解该功能的管理员进行配置和部署。对功能的误解可能会带来安全风险、导致 Security 插件无法正常运行或造成数据丢失。 +::: + +Security 插件支持以下专家级设置: + +- `plugins.security.config_index_name`(静态):`.opendistro_security` 存储其配置所使用的索引名称。 + +- `plugins.security.cert.oid`(静态):定义服务器节点证书的对象标识符(Object Identifier,OID)。 + +- `plugins.security.cert.intercluster_request_evaluator_class`(静态):指定用于评估集群间请求的 `org.opensearch.security.transport.InterClusterRequestEvaluator` 实现。`org.opensearch.security.transport.InterClusterRequestEvaluator` 的实例必须实现一个单参数构造函数,该参数为 `org.opensearch.common.settings.Settings` 对象。 + +- `plugins.security.enable_snapshot_restore_privilege`(静态):设置为 `false` 时,此设置会禁止普通用户进行快照(Snapshot)恢复。在这种情况下,只接受使用管理员 TLS 证书签名的快照恢复请求。设置为 `true`(默认值)时,如果普通用户拥有 `cluster:admin/snapshot/restore`、`indices:admin/create` 和 `indices:data/write/index` 权限,则可以恢复快照。 + + ::: info 注意 + 只有当快照不包含全局状态且不恢复 `.opendistro_security` 索引时,才能恢复该快照。 + ::: + +- `plugins.security.check_snapshot_restore_write_privileges`(静态):设置为 `false` 时,会跳过额外的索引检查。设置为默认值 `true` 时,会针对 `indices:admin/create` 和 `"indices:data/write/index` 评估快照恢复操作。 + +- `plugins.security.cache.ttl_minutes`(静态):确定认证缓存的超时时间。认证缓存会临时存储从后端返回的用户对象,使 Security 插件无需重复请求这些对象,从而加快认证速度。该值以分钟为单位。默认值为 `60`。将该值设置为 `0` 可禁用缓存。 + +- `plugins.security.disabled`(静态):禁用 OpenSearch Security。 + + ::: danger 警告 + 禁用此插件可能会将你的配置(包括密码)暴露给公众。 + ::: + +- `plugins.security.protected_indices.enabled`(静态):如果设置为 `true`,则启用受保护索引。受保护索引比普通索引更安全。与其他传统索引一样,访问这些索引需要一个角色,而要使其可见还需要另一个角色。此设置与 `plugins.security.protected_indices.roles` 和 `plugins.security.protected_indices.indices` 设置配合使用。 + +- `plugins.security.protected_indices.roles`(静态):指定一个角色列表,用户必须映射到其中的角色才能访问受保护索引。 + +- `plugins.security.protected_indices.indices`(静态):指定要标记为受保护的索引列表。这些索引仅对映射到 `plugins.security.protected_indices.roles` 中指定角色的用户可见。满足此要求后,用户仍需映射到用于授予该索引访问权限的传统角色。 + +- `plugins.security.system_indices.enabled`(静态):如果设置为 `true`,则启用系统索引。系统索引与安全索引类似,只是其内容不加密。配置为系统索引的索引可以由超级管理员或拥有包含[系统索引权限](/security/access-control/permissions#system-index-permissions)的角色的用户访问。有关系统索引的更多信息,请参阅[系统索引](/security/configuration/system-indices)。 + +- `plugins.security.system_indices.indices`(静态):用作系统索引的索引列表。此设置由 `plugins.security.system_indices.enabled` 设置控制。 + +- `plugins.security.allow_default_init_securityindex`(静态):设置为 `true` 时,如果 OpenSearch 启动时创建安全索引失败,则将 Security 插件设置为其默认安全设置。默认安全设置存储在 `opensearch-project/security/config` 目录下的 YAML 文件中。默认值为 `false`。 + +- `plugins.security.cert.intercluster_request_evaluator_class`(静态):用于评估集群间通信的类。 + +- `plugins.security.enable_snapshot_restore_privilege`(静态):允许授予快照恢复权限。可选。默认值为 `true`。 + +- `plugins.security.check_snapshot_restore_write_privileges`(静态):在创建快照时强制执行写权限评估。默认值为 `true`。 + +## 审计日志设置 + +Security 插件支持以下审计日志设置: + +- `plugins.security.audit.enable_rest`(动态):启用或禁用 REST 请求日志记录。默认值为 `true`(启用)。 + +- `plugins.security.audit.enable_transport`(动态):启用或禁用传输层请求日志记录。默认值为 `false`(禁用)。 + +- `plugins.security.audit.resolve_bulk_requests`(动态):启用或禁用批量请求日志记录。启用后,批量请求中的所有子请求也会被记录。默认值为 `false`(禁用)。 + +- `plugins.security.audit.config.disabled_categories`(动态):禁用指定的事件类别。 + +- `plugins.security.audit.ignore_requests`(动态):将指定的请求排除在日志记录之外。允许使用包含操作或 REST 请求路径的通配符和正则表达式。 + +- `plugins.security.audit.threadpool.size`(静态):确定用于记录事件的线程池中的线程数。默认值为 `10`。将此值设置为 `0` 会禁用线程池,这意味着插件会同步记录事件。 + +- `plugins.security.audit.threadpool.max_queue_len`(静态):设置每个线程的最大队列长度。默认值为 `100000`。 + +- `plugins.security.audit.ignore_users`(动态):一个用户数组。来自列表中用户的审计请求不会被记录。 + +- `plugins.security.audit.type`(静态):审计日志事件的目标位置。有效值为 `internal_opensearch`、`external_opensearch`、`debug` 和 `webhook`。 + +- `plugins.security.audit.config.http_endpoints`(静态):`localhost` 的端点列表。 + +- `plugins.security.audit.config.index`(静态):审计日志索引。默认值为 `auditlog6`。该索引可以是静态索引,也可以是包含日期以便按天滚动的索引,例如 `"'auditlog6-'YYYY.MM.dd"`。无论哪种情况,都要确保妥善保护该索引。 + +- `plugins.security.audit.config.type`(静态):将审计日志类型指定为 `auditlog`。 + +- `plugins.security.audit.config.username`(静态):审计日志配置的用户名。 + +- `plugins.security.audit.config.password`(静态):审计日志配置的密码。 + +- `plugins.security.audit.config.enable_ssl`(静态):为审计日志启用或禁用 SSL。 + +- `plugins.security.audit.config.verify_hostnames`(静态):启用或禁用 SSL/TLS 证书的主机名验证。默认值为 `true`(启用)。 + +- `plugins.security.audit.config.enable_ssl_client_auth`(静态):启用或禁用 SSL/TLS 客户端认证。默认值为 `false`(禁用)。 + +- `plugins.security.audit.config.cert_alias`(静态):用于访问审计日志的证书别名。 + +- `plugins.security.audit.config.pemkey_filepath`(静态):用于审计日志的 Privacy Enhanced Mail(PEM)密钥的文件路径(相对于 `/config`)。 + +- `plugins.security.audit.config.pemkey_content`(静态):用于审计日志的 PEM 密钥的 base64 编码内容。可用于替代 `...config.pemkey_filepath`。 + +- `plugins.security.audit.config.pemkey_password`(静态):客户端使用的 PEM 格式私钥的密码。 + +- `plugins.security.audit.config.pemcert_filepath`(静态):用于审计日志的 PEM 证书的文件路径(相对于 `/config`)。 + +- `plugins.security.audit.config.pemcert_content`(静态):用于审计日志的 PEM 证书的 base64 编码内容。可用于替代通过 `...config.pemcert_filepath` 指定文件路径的方式。 + +- `plugins.security.audit.config.pemtrustedcas_filepath`(静态):受信任的根证书颁发机构的文件路径(相对于 `/config`)。 + +- `plugins.security.audit.config.pemtrustedcas_content`(静态):根证书颁发机构的 base64 编码内容。可用于替代 `...config.pemtrustedcas_filepath`。 + +- `plugins.security.audit.config.webhook.url`(静态):webhook 的 URL。 + +- `plugins.security.audit.config.webhook.format`(静态):webhook 使用的格式。有效值为 `URL_PARAMETER_GET`、`URL_PARAMETER_POST`、`TEXT`、`JSON` 和 `SLACK`。 + +- `plugins.security.audit.config.webhook.ssl.verify`(静态):启用或禁用对随 webhook 请求发送的 SSL/TLS 证书的验证。默认值为 `true`(启用)。 + +- `plugins.security.audit.config.webhook.ssl.pemtrustedcas_filepath`(静态):用于验证 webhook 请求的受信任证书颁发机构的文件路径(相对于 `/config`)。 + +- `plugins.security.audit.config.webhook.ssl.pemtrustedcas_content`(静态):用于验证 webhook 请求的证书颁发机构的 base64 编码内容。可用于替代 `...config.pemtrustedcas_filepath`。 + +- `plugins.security.audit.config.log4j.logger_name`(静态):Log4j 日志记录器的自定义名称。 + +- `plugins.security.audit.config.log4j.level`(静态):为 Log4j 日志记录器提供默认日志级别。有效值为 `OFF`、`FATAL`、`ERROR`、`WARN`、`INFO`、`DEBUG`、`TRACE` 和 `ALL`。默认值为 `INFO`。 + +- `opendistro_security.audit.config.disabled_rest_categories`(动态):日志记录器要忽略的 REST 类别列表。有效值为 `AUTHENTICATED` 和 `GRANTED_PRIVILEGES`。 + +- `opendistro_security.audit.config.disabled_transport_categories`(动态):日志记录器要忽略的传输层类别列表。有效值为 `AUTHENTICATED` 和 `GRANTED_PRIVILEGES`。 + +## 主机名验证和 DNS 查找设置 + +Security 插件支持以下主机名验证和 DNS 查找设置: + +- `plugins.security.ssl.transport.enforce_hostname_verification`(静态):是否在传输层验证主机名。可选。默认值为 `true`。 + +- `plugins.security.ssl.transport.resolve_hostname`(静态):是否在传输层通过 DNS 解析主机名。可选。默认值为 `true`。仅在启用主机名验证时有效。 + +有关更多信息,请参阅[主机名验证和 DNS 查找](/security/configuration/tls#advanced-hostname-verification-and-dns-lookup)。 + +## 客户端认证设置 + +Security 插件支持以下客户端认证设置: + +- `plugins.security.ssl.http.clientauth_mode`(静态):要使用的 TLS 客户端认证模式。有效值为 `OPTIONAL`(默认)、`REQUIRE` 和 `NONE`。可选。 + +有关更多信息,请参阅[客户端认证](/security/configuration/tls#advanced-client-authentication)。 + +## 启用的密码套件和协议设置 + +Security 插件支持以下启用的密码套件和协议设置。每个设置都必须以数组形式表示: + +- `plugins.security.ssl.http.enabled_ciphers`(静态):REST 层启用的 TLS 密码套件。仅支持 Java 格式。 + +- `plugins.security.ssl.http.enabled_protocols`(静态):REST 层启用的 TLS 协议。仅支持 Java 格式。 + +- `plugins.security.ssl.transport.enabled_ciphers`(静态):传输层启用的 TLS 密码套件。仅支持 Java 格式。 + +- `plugins.security.ssl.transport.enabled_protocols`(静态):传输层启用的 TLS 协议。仅支持 Java 格式。 + +有关更多信息,请参阅[启用的密码套件和协议](/security/configuration/tls#advanced-enabled-ciphers-and-protocols)。 + +## 密钥库和信任库文件——传输层 TLS 设置 {#key-store-and-trust-store-files---transport-layer-tls-settings} + +Security 插件支持以下传输层 TLS 密钥库和信任库设置: + +- `plugins.security.ssl.transport.keystore_type`(静态):密钥库文件的类型。可选。有效值为 `JKS` 或 `PKCS12/PFX`。默认值为 `JKS`。 + +- `plugins.security.ssl.transport.keystore_filepath`(静态):密钥库文件的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.transport.keystore_alias`(静态):密钥库别名。可选。默认为第一个别名。 + +- `plugins.security.ssl.transport.keystore_password`(静态):密钥库密码。默认值为 `changeit`。 + +- `plugins.security.ssl.transport.truststore_type`(静态):信任库文件的类型。可选。有效值为 `JKS` 或 `PKCS12/PFX`。默认值为 `JKS`。 + +- `plugins.security.ssl.transport.truststore_filepath`(静态):信任库文件的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.transport.truststore_alias`(静态):信任库别名。可选。默认为所有证书。 + +- `plugins.security.ssl.transport.truststore_password`(静态):信任库密码。默认值为 `changeit`。 + +有关密钥库和信任库文件的更多信息,请参阅[传输层 TLS](/security/configuration/tls#transport-layer-tls-1)。 + +## 密钥库和信任库文件——REST 层 TLS 设置 {#key-store-and-trust-store-files---rest-layer-tls-settings} + +Security 插件支持以下 REST 层 TLS 密钥库和信任库设置: + +- `plugins.security.ssl.http.enabled`(静态):是否在 REST 层启用 TLS。如果启用,则只允许使用 HTTPS。可选。默认值为 `false`。 + +- `plugins.security.ssl.http.keystore_type`(静态):密钥库文件的类型。可选。有效值为 `JKS` 或 `PKCS12/PFX`。默认值为 `JKS`。 + +- `plugins.security.ssl.http.keystore_filepath`(静态):密钥库文件的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.http.keystore_alias`(静态):密钥库别名。可选。默认为第一个别名。 + +- `plugins.security.ssl.http.keystore_password`:密钥库密码。默认值为 `changeit`。 + +- `plugins.security.ssl.http.truststore_type`:信任库文件的类型。可选。有效值为 `JKS` 或 `PKCS12/PFX`。默认值为 `JKS`。 + +- `plugins.security.ssl.http.truststore_filepath`:信任库文件的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.http.truststore_alias`(静态):信任库别名。可选。默认为所有证书。 + +- `plugins.security.ssl.http.truststore_password`(静态):信任库密码。默认值为 `changeit`。 + +有关更多信息,请参阅 [REST 层 TLS](/security/configuration/tls#rest-layer-tls-1)。 + +## OpenSSL 设置 + +Security 插件支持以下 OpenSSL 设置: + +- `plugins.security.ssl.transport.enable_openssl_if_available`(静态):如果可用,则在传输层启用 OpenSSL。可选。默认值为 `true`。 + +- `plugins.security.ssl.http.enable_openssl_if_available`(静态):如果可用,则在 REST 层启用 OpenSSL。可选。默认值为 `true`。 + +有关更多信息,请参阅 [OpenSSL](/security/configuration/tls#advanced-openssl)。 + +## X.509 PEM 证书和 PKCS #8 密钥——传输层 TLS 设置 {#x509-pem-certificates-and-pkcs-8-keys---transport-layer-tls-settings} + +Security 插件支持以下与 X.509 PEM 证书和 PKCS #8 密钥相关的传输层 TLS 设置: + +- `plugins.security.ssl.transport.pemkey_filepath`(静态):证书密钥文件(PKCS #8)的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.transport.pemkey_password`(静态):密钥密码。如果密钥没有密码,请省略此设置。可选。 + +- `plugins.security.ssl.transport.pemcert_filepath`(静态):X.509 节点证书链(PEM 格式)的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.transport.pemtrustedcas_filepath`(静态):根证书颁发机构(PEM 格式)的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +有关更多信息,请参阅 [REST 层 TLS](/security/configuration/tls#transport-layer-tls)。 + +## X.509 PEM 证书和 PKCS #8 密钥——REST 层 TLS 设置 {#x509-pem-certificates-and-pkcs-8-keys---rest-layer-tls-settings} + +Security 插件支持以下与 X.509 PEM 证书和 PKCS #8 密钥相关的 REST 层 TLS 设置: + +- `plugins.security.ssl.http.enabled`(静态):是否在 REST 层启用 TLS。如果启用,则只允许使用 HTTPS。可选。默认值为 `false`。 + +- `plugins.security.ssl.http.pemkey_filepath`(静态):证书密钥文件(PKCS #8)的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.http.pemkey_password`(静态):密钥密码。如果密钥没有密码,请省略此设置。可选。 + +- `plugins.security.ssl.http.pemcert_filepath`(静态):X.509 节点证书链(PEM 格式)的路径,该文件必须位于 `config` 目录下,使用相对路径指定。必需。 + +- `plugins.security.ssl.http.pemtrustedcas_filepath`:根证书颁发机构(PEM 格式)的路径,该文件必须位于 config 目录下,使用相对路径指定。必需。 + +有关更多信息,请参阅 [REST 层 TLS](/security/configuration/tls#rest-layer-tls)。 + +## 传输层安全设置 + +Security 插件支持以下传输层安全设置: + +- `plugins.security.ssl.transport.enabled`(静态):是否在 REST 层启用 TLS。 + +- `plugins.security.ssl.transport.client.pemkey_password`(静态):传输客户端使用的 PEM 格式私钥的密码。 + +- `plugins.security.ssl.transport.keystore_keypassword`(静态):密钥库中密钥的密码。 + +- `plugins.security.ssl.transport.server.keystore_keypassword`(静态):服务器密钥库中密钥的密码。 + +- `plugins.sercurity.ssl.transport.server.keystore_alias`(静态):服务器密钥库的别名。 + +- `plugins.sercurity.ssl.transport.client.keystore_alias`(静态):客户端密钥库的别名。 + +- `plugins.sercurity.ssl.transport.server.truststore_alias`(静态):服务器信任库的别名。 + +- `plugins.sercurity.ssl.transport.client.truststore_alias`(静态):客户端信任库的别名。 + +- `plugins.security.ssl.client.external_context_id`(静态):为传输客户端提供一个 ID,用于外部 SSL 上下文。 + +- `plugins.secuirty.ssl.transport.principal_extractor_class`(静态):指定一个实现了提取器的类,以便将证书的自定义部分用作主体(principal)。 + +- `plugins.security.ssl.http.crl.file_path`(静态):证书吊销列表文件的路径。 + +- `plugins.security.ssl.http.crl.validate`(静态):启用证书吊销列表(Certificate Revocation List,CRL)验证。默认值为 `false`(禁用)。 + +- `plugins.security.ssl.http.crl.prefer_crlfile_over_ocsp`(静态):当证书同时包含 CRL 证书条目和在线证书状态协议(Online Certificate Status Protocol,OCSP)条目时,是否优先使用 CRL 条目。可选。默认值为 `false`。 + +- `plugins.security.ssl.http.crl.check_only_end_entitites`(静态):为 `true` 时,只验证叶证书。默认值为 `true`。 + +- `plugins.security.ssl.http.crl.disable_ocsp`(静态):禁用 OCSP。默认值为 `false`(启用 OCSP)。 + +- `plugins.security.ssl.http.crl.disable_crldp`(静态):禁用证书中的 CRL 端点。默认值为 `false`(启用 CRL 端点)。 + +- `plugins.security.ssl.allow_client_initiated_renegotiation`(静态):启用或禁用客户端重新协商。默认值为 `false`(不允许客户端发起的重新协商)。 + +## Security 插件设置示例 + +```yml +# 通用配置设置 +plugins.security.nodes_dn: + - "CN=*.example.com, OU=SSL, O=Test, L=Test, C=DE" + - "CN=node.other.com, OU=SSL, O=Test, L=Test, C=DE" +plugins.security.authcz.admin_dn: + - CN=kirk,OU=client,O=client,L=test, C=de +plugins.security.roles_mapping_resolution: MAPPING_ONLY +plugins.security.ssl.transport.pemcert_filepath: esnode.pem +plugins.security.ssl.transport.pemkey_filepath: esnode-key.pem +plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem +plugins.security.ssl.transport.enforce_hostname_verification: false +plugins.security.ssl.http.enabled: true +plugins.security.ssl.http.pemcert_filepath: esnode.pem +plugins.security.ssl.http.pemkey_filepath: esnode-key.pem +plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem +plugins.security.allow_unsafe_democertificates: true +plugins.security.allow_default_init_securityindex: true +plugins.security.nodes_dn_dynamic_config_enabled: false +plugins.security.cert.intercluster_request_evaluator_class: # 此处需要示例值。 +plugins.security.audit.type: internal_opensearch +plugins.security.enable_snapshot_restore_privilege: true +plugins.security.check_snapshot_restore_write_privileges: true +plugins.security.cache.ttl_minutes: 60 +plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"] +plugins.security.system_indices.enabled: true +plugins.security.system_indices.indices: [".opendistro-alerting-config", ".opendistro-alerting-alert*", ".opendistro-anomaly-results*", ".opendistro-anomaly-detector*", ".opendistro-anomaly-checkpoints", ".opendistro-anomaly-detection-state", ".opendistro-reports-*", ".opendistro-notifications-*", ".opendistro-notebooks", ".opendistro-asynchronous-search-response*"] +node.max_local_storage_nodes: 3 +plugins.security.restapi.password_validation_regex: '(?=.*[A-Z])(?=.*[^a-zA-Z\d])(?=.*[0-9])(?=.*[a-z]).{8,}' +plugins.security.restapi.password_validation_error_message: "Password must be minimum 8 characters long and must contain at least one uppercase letter, one lowercase letter, one digit, and one special character." +plugins.security.allow_default_init_securityindex: true +plugins.security.cache.ttl_minutes: 60 +# +# REST 管理 API 配置设置 +plugins.security.restapi.roles_enabled: ["all_access","xyz_role"] +plugins.security.restapi.endpoints_disabled.all_access.ACTIONGROUPS: ["PUT","POST","DELETE"] # 另一个示例:plugins.security.restapi.endpoints_disabled.xyz_role.LICENSE: ["DELETE"] # +# 审计日志配置设置 +plugins.security.audit.enable_rest: true +plugins.security.audit.enable_transport: false +plugins.security.audit.resolve_bulk_requests: false +plugins.security.audit.config.disabled_categories: ["AUTHENTICATED","GRANTED_PRIVILEGES"] +plugins.security.audit.ignore_requests: ["indices:data/read/*","*_bulk"] +plugins.security.audit.threadpool.size: 10 +plugins.security.audit.threadpool.max_queue_len: 100000 +plugins.security.audit.ignore_users: ['kibanaserver','some*user','/also.*regex possible/'] +plugins.security.audit.type: internal_opensearch +# +# external_opensearch 设置 +plugins.security.audit.config.http_endpoints: ['localhost:9200','localhost:9201','localhost:9202'] +plugins.security.audit.config.index: "'auditlog6-'2023.06.15" +plugins.security.audit.config.type: auditlog +plugins.security.audit.config.username: auditloguser +plugins.security.audit.config.password: auditlogpassword +plugins.security.audit.config.enable_ssl: false +plugins.security.audit.config.verify_hostnames: false +plugins.security.audit.config.enable_ssl_client_auth: false +plugins.security.audit.config.cert_alias: mycert +plugins.security.audit.config.pemkey_filepath: key.pem +plugins.security.audit.config.pemkey_content: <...pem base 64 content> +plugins.security.audit.config.pemkey_password: secret +plugins.security.audit.config.pemcert_filepath: cert.pem +plugins.security.audit.config.pemcert_content: <...pem base 64 content> +plugins.security.audit.config.pemtrustedcas_filepath: ca.pem +plugins.security.audit.config.pemtrustedcas_content: <...pem base 64 content> +# +# Webhook 设置 +plugins.security.audit.config.webhook.url: "http://mywebhook/endpoint" +plugins.security.audit.config.webhook.format: JSON +plugins.security.audit.config.webhook.ssl.verify: false +plugins.security.audit.config.webhook.ssl.pemtrustedcas_filepath: ca.pem +plugins.security.audit.config.webhook.ssl.pemtrustedcas_content: <...pem base 64 content> +# +# log4j 设置 +plugins.security.audit.config.log4j.logger_name: auditlogger +plugins.security.audit.config.log4j.level: INFO +# +# 高级配置设置 +plugins.security.authcz.impersonation_dn: + "CN=spock,OU=client,O=client,L=Test,C=DE": + - worf + "cn=webuser,ou=IT,ou=IT,dc=company,dc=com": + - user2 + - user1 +plugins.security.authcz.rest_impersonation_user: + "picard": + - worf + "john": + - steve + - martin +plugins.security.allow_default_init_securityindex: false +plugins.security.allow_unsafe_democertificates: false +plugins.security.cache.ttl_minutes: 60 +plugins.security.restapi.password_validation_regex: '(?=.*[A-Z])(?=.*[^a-zA-Z\d])(?=.*[0-9])(?=.*[a-z]).{8,}' +plugins.security.restapi.password_validation_error_message: "A password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one digit, and one special character." +plugins.security.restapi.password_min_length: 8 +plugins.security.restapi.password_score_based_validation_strength: very_strong +# +# 高级 SSL 设置 - 仅在你完全了解 SSL 的来龙去脉时使用 +plugins.security.ssl.transport.client.pemkey_password: superSecurePassword1 +plugins.security.ssl.transport.keystore_keypassword: superSecurePassword2 +plugins.security.ssl.transport.server.keystore_keypassword: superSecurePassword3 +plugins.security.ssl.http.keystore_keypassword: superSecurePassword4 +plugins.security.ssl.http.clientauth_mode: REQUIRE +plugins.security.ssl.transport.enabled: true +plugins.security.ssl.transport.server.keystore_alias: my_alias +plugins.security.ssl.transport.client.keystore_alias: my_other_alias +plugins.security.ssl.transport.server.truststore_alias: trustore_alias_1 +plugins.security.ssl.transport.client.truststore_alias: trustore_alias_2 +plugins.security.ssl.client.external_context_id: my_context_id +plugins.security.ssl.transport.principal_extractor_class: org.opensearch.security.ssl.ExampleExtractor +plugins.security.ssl.http.crl.file_path: ssl/crl/revoked.crl +plugins.security.ssl.http.crl.validate: true +plugins.security.ssl.http.crl.prefer_crlfile_over_ocsp: true +plugins.security.ssl.http.crl.check_only_end_entitites: false +plugins.security.ssl.http.crl.disable_ocsp: true +plugins.security.ssl.http.crl.disable_crldp: true +plugins.security.ssl.allow_client_initiated_renegotiation: true +# +# 专家设置 - 仅在你完全了解其用途时使用:误设的值可能会带来安全风险或导致 OpenSearch Security 出现故障。 +plugins.security.config_index_name: .opendistro_security +plugins.security.cert.oid: '1.2.3.4.5.5' +plugins.security.cert.intercluster_request_evaluator_class: org.opensearch.security.transport.DefaultInterClusterRequestEvaluator +plugins.security.enable_snapshot_restore_privilege: true +plugins.security.check_snapshot_restore_write_privileges: true +plugins.security.cache.ttl_minutes: 60 +plugins.security.disabled: false +plugins.security.protected_indices.enabled: true +plugins.security.protected_indices.roles: ['all_access'] +plugins.security.protected_indices.indices: [] +plugins.security.system_indices.enabled: true +plugins.security.system_indices.indices: ['.opendistro-alerting-config', '.opendistro-ism-*', '.opendistro-reports-*', '.opensearch-notifications-*', '.opensearch-notebooks', '.opensearch-observability', '.opendistro-asynchronous-search-response*', '.replication-metadata-store'] +``` diff --git a/i18n/zh/install-and-configure/index.md b/i18n/zh/install-and-configure/index.md new file mode 100644 index 00000000..cb442ce0 --- /dev/null +++ b/i18n/zh/install-and-configure/index.md @@ -0,0 +1,27 @@ +--- +title: 安装和升级 OpenSearch +--- + +# 安装和升级 OpenSearch + +OpenSearch 和 OpenSearch Dashboards 可以在任何支持 Docker 的兼容主机(例如 Linux、MacOS 或 Windows)上运行。此外,你还可以在多种 Linux 发行版和 Windows 上安装这两个产品。 + +针对你的平台[下载 OpenSearch](https://opensearch.org/downloads.html),然后选择以下任一安装指南。 + +| OpenSearch | OpenSearch Dashboards | +| :--- | :--- | +| [Docker](/install-and-configure/install-opensearch/docker) | [Docker](/install-and-configure/install-dashboards/docker) | +| [Helm](/install-and-configure/install-opensearch/helm) | [Helm](/install-and-configure/install-dashboards/helm) | +| [Tarball](/install-and-configure/install-opensearch/tar) | [Tarball](/install-and-configure/install-dashboards/tar) | +| [RPM](/install-and-configure/install-opensearch/rpm) | [RPM](/install-and-configure/install-dashboards/rpm) | +| [Debian](/install-and-configure/install-opensearch/debian) | [Debian](/install-and-configure/install-dashboards/debian) | +| [Ansible playbook](/install-and-configure/install-opensearch/ansible) | | +| [Windows](/install-and-configure/install-opensearch/windows) | [Windows](/install-and-configure/install-dashboards/windows) | + +安装 OpenSearch 后,请了解如何针对你的部署[配置](/install-and-configure/configuring-opensearch/) OpenSearch。 + +有关升级 OpenSearch 集群(Cluster)的更多信息,请参阅[升级指南](/install-and-configure/upgrade-opensearch/)。 + +有关升级工具的信息,请参阅 [OpenSearch 升级、迁移和比较工具](/tools/#opensearch-upgrade-migration-and-comparison-tools)。 + +有关插件安装,请参阅[安装插件](/install-and-configure/plugins)。 diff --git a/i18n/zh/install-and-configure/install-dashboards/debian.md b/i18n/zh/install-and-configure/install-dashboards/debian.md new file mode 100644 index 00000000..ef5b8a5c --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/debian.md @@ -0,0 +1,132 @@ +--- +title: Debian +--- + +# 安装 OpenSearch Dashboards(Debian) + +与 [Tarball](/install-and-configure/install-dashboards/tar) 方式相比,使用高级包管理工具(Advanced Packaging Tool,APT)安装 OpenSearch Dashboards 会大大简化安装过程。例如,包管理器会处理多项技术细节,如安装路径、配置文件位置,以及创建由 `systemd` 管理的服务。 + +::: warning 重要 +在安装 OpenSearch Dashboards 之前,你必须先配置一个 OpenSearch 集群(Cluster)。具体步骤请参阅 OpenSearch 的 [Debian](/install-and-configure/install-opensearch/debian) 安装指南。 +::: + +::: info 注意 +本指南假定你熟悉 Linux 命令行界面(CLI)的使用。你应当了解如何输入命令、在目录之间切换以及编辑文本文件。部分示例命令使用 `vi` 文本编辑器,但你可以使用任何可用的文本编辑器。 +::: + +## 从安装包安装 OpenSearch Dashboards + +1. 直接从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载所需版本的 Debian 包。Debian 包提供 **x64** 和 **arm64** 两种架构的版本。 +1. 在 CLI 中使用 `dpkg` 安装。 + ```bash + # x64 + sudo dpkg -i opensearch-dashboards-2.12.0-linux-x64.deb + # arm64 + sudo dpkg -i opensearch-dashboards-2.12.0-linux-arm64.deb + ``` +1. 安装完成后,重新加载 systemd 管理器配置。 + ```bash + sudo systemctl daemon-reload + ``` +1. 将 OpenSearch 启用为服务。 + ```bash + sudo systemctl enable opensearch-dashboards + ``` +1. 启动 OpenSearch 服务。 + ```bash + sudo systemctl start opensearch-dashboards + ``` +1. 验证 OpenSearch 是否正确启动。 + ```bash + sudo systemctl status opensearch-dashboards + ``` + +### 指纹验证 + +Debian 包未签名。如果你希望验证指纹,OpenSearch 项目除了 `.deb` 包之外还提供了 `.sig` 文件,可配合 GNU Privacy Guard(GPG)使用。 + +1. 下载所需的 Debian 包。 + ```bash + curl -SLO https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.12.0/opensearch-dashboards-2.12.0-linux-x64.deb + ``` +1. 下载对应的签名文件。 + ```bash + curl -SLO https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.12.0/opensearch-dashboards-2.12.0-linux-x64.deb.sig + ``` +1. 下载并导入 GPG 密钥。 + ```bash + curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --import - + ``` +1. 验证签名。 + ```bash + gpg --verify opensearch-dashboards-2.12.0-linux-x64.deb.sig opensearch-dashboards-2.12.0-linux-x64.deb + ``` + +## 从 APT 仓库安装 OpenSearch Dashboards + +APT 是基于 Debian 的操作系统的主要包管理工具,可以从 APT 仓库下载并安装 Debian 包。 + +1. 安装必要的软件包。 + ```bash + sudo apt-get update && sudo apt-get -y install lsb-release ca-certificates curl gnupg2 + ``` +1. 导入公共 GPG 密钥。该密钥用于验证 APT 仓库已签名。 + ```bash + curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring + ``` +1. 为 OpenSearch 创建 APT 仓库。 + ```bash + echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-dashboards-2.x.list + ``` +1. 验证仓库是否创建成功。 + ```bash + sudo apt-get update + ``` +1. 添加仓库信息后,列出 OpenSearch 的所有可用版本: + ```bash + sudo apt list -a opensearch-dashboards + ``` +1. 选择要安装的 OpenSearch 版本: + - 除非另行指定,否则会安装 OpenSearch 的最新可用版本。 + ```bash + sudo apt-get install opensearch-dashboards + ``` + - 要安装特定版本的 OpenSearch Dashboards,请在包名后传入版本号。 + ```bash + # 使用 opensearch= 手动指定版本 + sudo apt-get install opensearch-dashboards=2.12.0 + ``` +1. 完成后,启用 OpenSearch。 + ```bash + sudo systemctl enable opensearch-dashboards + ``` +1. 启动 OpenSearch。 + ```bash + sudo systemctl start opensearch-dashboards + ``` +1. 验证 OpenSearch 是否正确启动。 + ```bash + sudo systemctl status opensearch-dashboards + ``` + +## 探索 OpenSearch Dashboards + +默认情况下,与 OpenSearch 一样,OpenSearch Dashboards 在初次安装时会绑定到 `localhost`。因此,除非更新配置,否则无法从远程主机访问 OpenSearch Dashboards。 + +1. 打开 `opensearch_dashboards.yml`。 + ```bash + sudo vi /etc/opensearch-dashboards/opensearch_dashboards.yml + ``` +1. 指定 OpenSearch Dashboards 应绑定的网络接口。 + ```bash + # 使用 0.0.0.0 绑定到任意可用接口。 + server.host: 0.0.0.0 + ``` +1. 保存并退出。 +1. 重启 OpenSearch Dashboards 以应用配置更改。 + ```bash + sudo systemctl restart opensearch-dashboards + ``` +1. 在 Web 浏览器中访问 OpenSearch Dashboards。默认端口为 5601。 +1. 使用默认用户名 `admin` 和默认密码 `admin` 登录。(对于 OpenSearch 2.12 及更高版本,密码应为自定义的 admin 密码) +1. 访问 [OpenSearch Dashboards 入门](/dashboards/)以了解更多信息。 diff --git a/i18n/zh/install-and-configure/install-dashboards/docker.md b/i18n/zh/install-and-configure/install-dashboards/docker.md new file mode 100644 index 00000000..82f92aae --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/docker.md @@ -0,0 +1,21 @@ +--- +title: Docker +--- + +# 使用 Docker 运行 OpenSearch Dashboards + +你*可以*在[创建 Docker 网络](https://docs.docker.com/engine/reference/commandline/network_create/)并启动 OpenSearch 之后,使用 `docker run` 启动 OpenSearch Dashboards,但使用 Docker Compose 文件将 OpenSearch Dashboards 连接到 OpenSearch 要容易得多。 + +1. 运行 `docker pull opensearchproject/opensearch-dashboards:2`。 + +1. 创建适合你环境的 [`docker-compose.yml`](https://docs.docker.com/compose/compose-file/) 文件。OpenSearch 的 [Docker 安装页面](/install-and-configure/install-opensearch/docker#sample-docker-composeyml)提供了一个包含 OpenSearch Dashboards 的示例文件。 + + ::: tip 提示 + 与 `opensearch.yml` 一样,你也可以在 Docker Compose 文件中将自定义的 `opensearch_dashboards.yml` 传递给容器。 + ::: + +1. 运行 `docker-compose up`。 + + 等待容器启动,然后参阅 [OpenSearch Dashboards 文档](/dashboards/)。 + +1. 完成后,运行 `docker-compose down`。 diff --git a/i18n/zh/install-and-configure/install-dashboards/helm.md b/i18n/zh/install-and-configure/install-dashboards/helm.md new file mode 100644 index 00000000..b069b3e1 --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/helm.md @@ -0,0 +1,132 @@ +--- +title: Helm +--- + +# 使用 Helm 运行 OpenSearch Dashboards + +Helm 是一个包管理器,可以让你在 Kubernetes 集群(Cluster)中轻松安装和管理 OpenSearch Dashboards。你可以在 YAML 文件中定义 OpenSearch 配置,并使用 Helm 以版本可控、可重现的方式部署应用程序。 + +Helm chart 包含下表所述的资源。 + +资源 | 描述 +:--- | :--- +`Chart.yaml` | chart 的相关信息。 +`values.yaml` | chart 的默认配置值。 +`templates` | 与配置值组合以生成 Kubernetes 清单文件的模板。 + +默认 Helm chart 中的规范支持许多标准用例和部署方式。你可以修改默认 chart 以配置所需的规范,并设置传输层安全(Transport Layer Security,TLS)和基于角色的访问控制(Role-based Access Control,RBAC)。 + +有关默认配置、安全配置步骤和可配置参数的信息,请参阅 +[README](https://github.com/opensearch-project/helm-charts/tree/main/charts)。 + +::: info 注意 +此处的说明假定你已有一个预装了 Helm 的 Kubernetes 集群。有关配置 Kubernetes 集群的步骤,请参阅 [Kubernetes 文档](https://kubernetes.io/docs/setup/);有关安装 Helm 的步骤,请参阅 [Helm 文档](https://helm.sh/docs/intro/install/)。 +::: + +## 前提条件 + +开始之前,你必须先[使用 Helm 安装 OpenSearch](/install-and-configure/install-opensearch/helm)。 + +确保你可以向 OpenSearch pod 发送请求: + +```json +$ curl -XGET https://localhost:9200 -u 'admin:' --insecure +{ + "name" : "opensearch-cluster-master-1", + "cluster_name" : "opensearch-cluster", + "cluster_uuid" : "hP2gq5bPS3SLp8Z7wXm8YQ", + "version" : { + "distribution" : "opensearch", + "number" : "1.0.0", + "build_type" : "tar", + "build_hash" : "34550c5b17124ddc59458ef774f6b43a086522e3", + "build_date" : "2021-07-02T23:22:21.383695Z", + "build_snapshot" : false, + "lucene_version" : "8.8.2", + "minimum_wire_compatibility_version" : "6.8.0", + "minimum_index_compatibility_version" : "6.0.0-beta1" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" +} +``` + +## 使用 Helm 安装 OpenSearch Dashboards + +1. 切换到 `opensearch-dashboards` 目录: + + ```bash + cd opensearch-dashboards + ``` + +1. 打包 Helm chart: + + ```bash + helm package . + ``` + +1. 部署 OpenSearch Dashboards: + + ```bash + helm install --generate-name opensearch-dashboards-1.0.0.tgz + ``` + 输出会显示本次安装实例化的规范。 + 要自定义部署,请通过自定义 YAML 文件传入要覆盖的值: + + ```bash + helm install --values=customvalues.yaml opensearch-dashboards-1.0.0.tgz + ``` + +#### 示例输出 + +```yaml +NAME: opensearch-dashboards-1-1629223356 +LAST DEPLOYED: Tue Aug 17 18:02:37 2021 +NAMESPACE: default +STATUS: deployed +REVISION: 1 +TEST SUITE: None +NOTES: +1. Get the application URL by running these commands: + export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=opensearch-dashboards,app.kubernetes.io/instance=op +ensearch-dashboards-1-1629223356" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT +``` + +要确认 OpenSearch Dashboards pod 已启动并正常运行,请运行以下命令: + +```bash +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +opensearch-cluster-master-0 1/1 Running 0 4m35s +opensearch-cluster-master-1 1/1 Running 0 4m35s +opensearch-cluster-master-2 1/1 Running 0 4m35s +opensearch-dashboards-1-1629223356-758bd8747f-8www5 1/1 Running 0 66s +``` + +要设置端口转发以访问 OpenSearch Dashboards,请退出 OpenSearch shell 并运行以下命令: + +```bash +$ kubectl port-forward deployment/opensearch-dashboards-1-1629223356 5601 +``` + +现在,你可以在浏览器中通过 http://localhost:5601 访问 OpenSearch Dashboards。 + +## 使用 Helm 卸载 + +确定要删除的 OpenSearch Dashboards 部署: + +```bash +$ helm list +NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION +opensearch-1-1629223146 default 1 2021-08-17 17:59:07.664498239 +0000 UTCdeployedopensearch-1.0.0 1.0.0 +opensearch-dashboards-1-1629223356 default 1 2021-08-17 18:02:37.600796946 +0000 UTCdepl +oyedopensearch-dashboards-1.0.0 1.0.0 +``` + +要删除或卸载某个部署,请运行以下命令: + +```bash +helm delete opensearch-dashboards-1-1629223356 +``` diff --git a/i18n/zh/install-and-configure/install-dashboards/index.md b/i18n/zh/install-and-configure/install-dashboards/index.md new file mode 100644 index 00000000..aa16d9c0 --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/index.md @@ -0,0 +1,64 @@ +--- +title: 安装 OpenSearch Dashboards +--- + +# 安装 OpenSearch Dashboards + +OpenSearch Dashboards 提供了一个完全集成的解决方案,用于以可视化方式探索、发现和查询可观测性(Observability)数据。你可以通过以下任一方式安装 OpenSearch Dashboards: + +- [Docker](/install-and-configure/install-dashboards/docker) +- [Tarball](/install-and-configure/install-dashboards/tar) +- [RPM](/install-and-configure/install-dashboards/rpm) +- [Debian](/install-and-configure/install-dashboards/debian) +- [Helm](/install-and-configure/install-dashboards/helm) +- [Windows](/install-and-configure/install-dashboards/windows) + +## 浏览器兼容性 + +OpenSearch Dashboards 支持以下 Web 浏览器: + +- Chrome +- Firefox +- Safari +- Edge (Chromium) + +其他基于 Chromium 的浏览器也可能可以使用。**不**支持 Internet Explorer 和 Microsoft Edge Legacy。 + +## Node.js 兼容性 {#nodejs-compatibility} + +OpenSearch Dashboards 需要 Node.js 运行时二进制文件才能运行。[OpenSearch 下载页面](https://opensearch.org/downloads.html)提供的发行包中已包含该文件。 + +OpenSearch Dashboards 2.8.0 及更高版本可以使用 Node.js 14、16 和 18 版本。OpenSearch Dashboards 2.10.0 及更高版本的发行包包含 Node.js 18 和 14(用于向后兼容)。 + +要使用发行包自带版本以外的 Node.js 运行时二进制文件,请按照以下步骤操作: + +1. 下载并安装 [Node.js](https://nodejs.org/en/download);兼容的版本为 `>=14.20.1 <19`。 +2. 将安装路径设置到 `NODE_HOME` 或 `NODE_OSD_HOME` 环境变量。 + + - 在 UNIX 上,如果 Node.js 安装在 `/usr/local/nodejs`,且运行时二进制文件为 `/usr/local/nodejs/bin/node`: + ```bash + export NODE_HOME=/usr/local/nodejs + ``` + + - 如果 Node.js 是通过 NVM 安装的,且运行时二进制文件为 `/Users/user/.nvm/versions/node/v18.19.0/bin/node`: + ```bash + export NODE_HOME=/Users/user/.nvm/versions/node/v18.19.0 + # 或者,如果 NODE_HOME 已用于其他用途: + export NODE_OSD_HOME=/Users/user/.nvm/versions/node/v18.19.0 + ``` + + - 在 Windows 上,如果 Node.js 安装在 `C:\Program Files\nodejs`,且运行时二进制文件为 `C:\Program Files\nodejs\node.exe`: + ```powershell + set "NODE_HOME=C:\Program Files\nodejs" + # 或者使用 PowerShell: + $Env:NODE_HOME = 'C:\Program Files\nodejs' + ``` + + 请查阅操作系统文档,了解如何持久化地修改环境变量。 + +OpenSearch Dashboards 启动脚本 `bin/opensearch-dashboards` 会先使用 `NODE_OSD_HOME`, +然后使用 `NODE_HOME` 查找 Node.js 运行时二进制文件,找不到时才使用发行包自带的二进制文件。如果找不到可用的 Node.js 运行时二进制文件,启动脚本会尝试在系统级 `PATH` 中查找,仍然找不到则启动失败。 + +## 配置 + +要了解如何为 OpenSearch Dashboards 配置 TLS,请参阅[配置 TLS](/install-and-configure/install-dashboards/tls)。 diff --git a/i18n/zh/install-and-configure/install-dashboards/plugins.md b/i18n/zh/install-and-configure/install-dashboards/plugins.md new file mode 100644 index 00000000..ba044237 --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/plugins.md @@ -0,0 +1,105 @@ +--- +title: 管理 OpenSearch Dashboards 插件 +--- + +# 管理 OpenSearch Dashboards 插件 + +OpenSearch Dashboards 提供了一个名为 `opensearch-dashboards-plugin` 的命令行工具,用于管理插件(plugin)。使用该工具,你可以: + +- 列出已安装的插件。 +- 安装插件。 +- 删除已安装的插件。 + +## 插件兼容性 + +::: danger 警告 +插件的主版本号、次版本号和补丁版本号必须与 OpenSearch 的主版本号、次版本号和补丁版本号一致,才能兼容。例如,2.3.0.x 版本的插件只能与 OpenSearch 2.3.0 配合使用。 +::: + +## 前提条件 + +- 一个兼容的 OpenSearch 集群(Cluster) +- [已在该集群上安装](/install-and-configure/plugins)对应的 OpenSearch 插件 +- 对应版本的 [OpenSearch Dashboards](/)(例如,OpenSearch Dashboards 2.3.0 与 OpenSearch 2.3.0 配合使用) + +## 可用插件 + +下表列出了可用的 OpenSearch Dashboards 插件。 + +| 插件名称 | 仓库 | 最早可用版本 | +| :--- | :--- | :--- | +| Alerting Dashboards | [alerting-dashboards-plugin](https://github.com/opensearch-project/alerting-dashboards-plugin) | 1.0.0 | +| Anomaly Detection Dashboards | [anomaly-detection-dashboards-plugin](https://github.com/opensearch-project/anomaly-detection-dashboards-plugin) | 1.0.0 | +| Custom Import Maps Dashboards | [dashboards-maps](https://github.com/opensearch-project/dashboards-maps) | 2.2.0 | +| Search Relevance Dashboards | [dashboards-search-relevance](https://github.com/opensearch-project/dashboards-search-relevance) | 2.4.0 | +| Gantt Chart Dashboards | [gantt-chart](https://github.com/opensearch-project/dashboards-visualizations) | 1.0.0 | +| Index Management Dashboards | [index-management-dashboards-plugin](https://github.com/opensearch-project/index-management-dashboards-plugin) | 1.0.0 | +| Notebooks Dashboards | [dashboards-notebooks](https://github.com/opensearch-project/dashboards-notebooks) | 1.0.0 | +| Notifications Dashboards | [dashboards-notifications](https://github.com/opensearch-project/dashboards-notifications) | 2.0.0 | +| Observability Dashboards | [dashboards-observability](https://github.com/opensearch-project/dashboards-observability) | 2.0.0 | +| Query Workbench Dashboards | [query-workbench](https://github.com/opensearch-project/dashboards-query-workbench) | 1.0.0 | +| Reports Dashboards | [dashboards-reporting](https://github.com/opensearch-project/dashboards-reporting) | 1.0.0 | +| Security Analytics Dashboards | [security-analytics-dashboards-plugin](https://github.com/opensearch-project/security-analytics-dashboards-plugin)| 2.4.0 | +| Security Dashboards | [security-dashboards-plugin](https://github.com/opensearch-project/security-dashboards-plugin) | 1.0.0 | + +## 安装 + +进入 OpenSearch Dashboards 主目录(例如 `/usr/share/opensearch-dashboards`),然后为每个插件运行安装命令。 + +## 查看已安装插件列表 + +要在命令行中查看已安装插件列表,请使用以下命令: + +```bash +sudo bin/opensearch-dashboards-plugin list +``` + +## 删除插件 + +要删除插件: + +```bash +sudo bin/opensearch-dashboards-plugin remove +``` + +然后从 `opensearch_dashboards.yml` 中删除所有相关条目。 + +对于某些插件,你还必须删除「optimize」bundle。以下是 Anomaly Detection 插件的示例命令: + +```bash +sudo rm /usr/share/opensearch-dashboards/optimize/bundles/opensearch-anomaly-detection-opensearch-dashboards.* +``` + +然后重启 OpenSearch Dashboards。删除任何插件后,OpenSearch Dashboards 会在下次启动时执行一次 optimize 操作。即使在性能很好的机器上,该操作也需要几分钟,请耐心等待。 + +## 更新插件 + +OpenSearch Dashboards 不会更新插件。你需要删除旧版本及其 optimize bundle,重新安装,然后重启 OpenSearch Dashboards: + +1. 删除旧版本: + + ```bash + sudo bin/opensearch-dashboards-plugin remove + ``` + +1. 删除 optimize bundle: + + ```bash + sudo rm /usr/share/opensearch-dashboards/optimize/bundles/ + ``` + +1. 重新安装新版本: + + ```bash + sudo bin/opensearch-dashboards-plugin install + ``` + +1. 重启 OpenSearch Dashboards。 + +例如,要删除并重新安装 Anomaly Detection 插件: + +```bash +sudo bin/opensearch-dashboards-plugin remove anomalyDetectionDashboards +sudo rm /usr/share/opensearch-dashboards/optimize/bundles/opensearch-anomaly-detection-opensearch-dashboards.* +sudo bin/opensearch-dashboards-plugin install +``` diff --git a/i18n/zh/install-and-configure/install-dashboards/rpm.md b/i18n/zh/install-and-configure/install-dashboards/rpm.md new file mode 100644 index 00000000..b8f88b0d --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/rpm.md @@ -0,0 +1,81 @@ +--- +title: RPM +--- + +# 使用 RPM 包管理器(RPM)运行 OpenSearch Dashboards + +OpenSearch Dashboards 是 OpenSearch 数据的默认可视化工具。它还是许多 OpenSearch 插件(plugin)的用户界面,包括安全、告警(alerting)、索引状态管理(Index State Management,ISM)、SQL 等。 + +## 从安装包安装 OpenSearch Dashboards + +1. 直接从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载所需版本的 RPM 包。RPM 包提供 **x64** 和 **arm64** 两种架构的版本。 +1. 导入公共 GPG 密钥。该密钥用于验证你的 OpenSearch 实例已签名。 + ```bash + sudo rpm --import https://artifacts.opensearch.org/publickeys/opensearch.pgp + ``` +1. 在命令行界面(CLI)中,你可以使用 `rpm` 或 `yum` 安装该软件包。 + **x64** + ```bash + # 使用 yum 安装 x64 软件包。 + sudo yum install opensearch-dashboards-2.12.0-linux-x64.rpm + # 使用 rpm 安装 x64 软件包。 + sudo rpm -ivh opensearch-dashboards-2.12.0-linux-x64.rpm + ``` + **arm64** + ```bash + # 使用 yum 安装 arm64 软件包。 + sudo yum install opensearch-dashboards-2.12.0-linux-arm64.rpm + # 使用 rpm 安装 arm64 软件包。 + sudo rpm -ivh opensearch-dashboards-2.12.0-linux-arm64.rpm + ``` +1. 安装成功后,将 OpenSearch Dashboards 启用为服务。 + ```bash + sudo systemctl enable opensearch-dashboards + ``` +1. 启动 OpenSearch Dashboards。 + ```bash + sudo systemctl start opensearch-dashboards + ``` +1. 验证 OpenSearch Dashboards 是否正确启动。 + ```bash + sudo systemctl status opensearch-dashboards + ``` + +## 从本地 YUM 仓库安装 OpenSearch Dashboards + +YUM 是基于 Red Hat 的操作系统的主要包管理工具,可以从 YUM 仓库库中下载并安装 RPM 包。 + +1. 为 OpenSearch Dashboards 创建本地仓库文件: + ```bash + sudo curl -SL https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/opensearch-dashboards-2.x.repo -o /etc/yum.repos.d/opensearch-dashboards-2.x.repo + ``` +1. 验证仓库是否创建成功。 + ```bash + sudo yum repolist + ``` +1. 清理 YUM 缓存,以确保顺利安装: + ```bash + sudo yum clean all + ``` +1. 下载仓库文件后,列出 OpenSearch Dashboards 的所有可用版本: + ```bash + sudo yum list opensearch-dashboards --showduplicates + ``` +1. 选择要安装的 OpenSearch Dashboards 版本: + - 除非另行指定,否则会安装 OpenSearch 的最高次要版本。 + ```bash + sudo yum install opensearch-dashboards + ``` + - 要安装特定版本的 OpenSearch Dashboards: + ```bash + sudo yum install 'opensearch-dashboards-2.12.0' + ``` +1. 安装过程中,安装程序会显示 GPG 密钥指纹。请验证其与以下信息一致: + ```bash + Fingerprint: c5b7 4989 65ef d1c2 924b a9d5 39d3 1987 9310 d3fc + ``` + - 如果一致,输入 `yes` 或 `y`,OpenSearch 安装将继续进行。 +1. 完成后,即可运行 OpenSearch Dashboards。 + ```bash + sudo systemctl start opensearch-dashboards + ``` diff --git a/i18n/zh/install-and-configure/install-dashboards/tar.md b/i18n/zh/install-and-configure/install-dashboards/tar.md new file mode 100644 index 00000000..3e8e38bb --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/tar.md @@ -0,0 +1,26 @@ +--- +title: Tarball +--- + +# 使用 tarball 运行 OpenSearch Dashboards + +1. 从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载 tarball。 + +1. 将 TAR 文件解压到一个目录,并切换到该目录: + + ```bash + # x64 + tar -zxf opensearch-dashboards-2.12.0-linux-x64.tar.gz + cd opensearch-dashboards + # ARM64 + tar -zxf opensearch-dashboards-2.12.0-linux-arm64.tar.gz + cd opensearch-dashboards + ``` + +1. 如有需要,修改 `config/opensearch_dashboards.yml`。 + +1. 运行 OpenSearch Dashboards: + + ```bash + ./bin/opensearch-dashboards + ``` diff --git a/i18n/zh/install-and-configure/install-dashboards/tls.md b/i18n/zh/install-and-configure/install-dashboards/tls.md new file mode 100644 index 00000000..b3206cc5 --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/tls.md @@ -0,0 +1,55 @@ +--- +title: 配置 TLS +--- + +# 为 OpenSearch Dashboards 配置 TLS + +默认情况下,为了便于测试和入门,OpenSearch Dashboards 通过 HTTP 运行。要为 HTTPS 启用 TLS,请在 `opensearch_dashboards.yml` 中更新以下设置。 + +设置 | 描述 +:--- | :--- +`server.ssl.enabled` | 启用 OpenSearch Dashboards 服务器与用户 Web 浏览器之间的 SSL 通信。设置为 `true` 表示使用 HTTPS,设置为 `false` 表示使用 HTTP。 +`server.ssl.supportedProtocols` | 指定支持的 TLS 协议数组。可选值为 `TLSv1`、`TLSv1.1`、`TLSv1.2` 和 `TLSv1.3`。默认值为 `['TLSv1.1', 'TLSv1.2', and 'TLSv1.3']`。 +`server.ssl.cipherSuites` | 指定 TLS 密码套件数组。可选。 +`server.ssl.certificate` | 如果 `server.ssl.enabled` 设置为 `true`,则指定 OpenSearch Dashboards 有效的 Privacy Enhanced Mail(PEM)服务器证书的完整路径。你可以[生成自己的证书](/security/configuration/generate-certificates),也可以从证书颁发机构(CA)获取证书。 +`server.ssl.key` | 如果 `server.ssl.enabled` 设置为 `true`,则指定服务器证书密钥的完整路径,例如 `/usr/share/opensearch-dashboards-1.0.0/config/my-client-cert-key.pem`。你可以[生成自己的证书](/security/configuration/generate-certificates),也可以从 CA 获取证书。 +`server.ssl.keyPassphrase` | 设置密钥的密码。如果密钥没有密码,请省略此设置。可选。 +`server.ssl.keystore.path` | 使用 JKS(Java KeyStore)或 PKCS12/PFX(Public-Key Cryptography Standards)文件代替 PEM 证书和密钥。 +`server.ssl.keystore.password` | 设置密钥库的密码。必需。 +`server.ssl.clientAuthentication` | 指定要使用的 TLS 客户端认证模式。可以是以下值之一:`none`、`optional` 或 `required`。如果设置为 `required`,Web 浏览器需要发送由 `server.ssl.certificateAuthorities` 中配置的 CA 签名的有效客户端证书。默认值为 `none`。 +`server.ssl.certificateAuthorities` | 以数组形式指定一个或多个 CA 证书的完整路径,这些 CA 签发了用于客户端认证的证书。如果 `server.ssl.clientAuthentication` 设置为 `optional` 或 `required`,则此项必需。 +`server.ssl.truststore.path` | 使用 JKS 或 PKCS12/PFX 信任库文件代替 PEM CA 证书。 +`server.ssl.truststore.password` | 设置信任库的密码。必需。 +`opensearch.ssl.verificationMode` | 建立 OpenSearch 与 OpenSearch Dashboards 之间的通信。有效值为 `full`、`certificate` 或 `none`。如果启用了 TLS,建议使用 `full`,它会启用主机名验证。`certificate` 会检查证书,但不检查主机名。`none` 不执行任何检查(适用于 HTTP)。默认值为 `full`。 +`opensearch.ssl.certificateAuthorities` | 如果 `opensearch.ssl.verificationMode` 设置为 `full` 或 `certificate`,则以数组形式指定一个或多个 CA 证书的完整路径,这些证书构成 OpenSearch 集群(Cluster)的可信证书链。例如,如果你使用中间 CA 签发了 admin 证书、客户端证书和节点证书,则可能需要同时包含根 CA *和*中间 CA。 +`opensearch.ssl.truststore.path` | 使用 JKS 或 PKCS12/PFX 信任库文件代替 PEM CA 证书。 +`opensearch.ssl.truststore.password` | 设置信任库的密码。必需。 +`opensearch.ssl.alwaysPresentCertificate` | 如果设置为 `true`,则向 OpenSearch 集群发送客户端证书;在 OpenSearch 中启用 mTLS 时必须如此设置。默认值为 `false`。 +`opensearch.ssl.certificate` | 如果 `opensearch.ssl.alwaysPresentCertificate` 设置为 `true`,则指定用于 OpenSearch 集群的有效客户端证书的完整路径。你可以[生成自己的证书](/security/configuration/generate-certificates),也可以从 CA 获取证书。 +`opensearch.ssl.key` | 如果 `opensearch.ssl.alwaysPresentCertificate` 设置为 `true`,则指定客户端证书密钥的完整路径。你可以[生成自己的证书](/security/configuration/generate-certificates),也可以从 CA 获取证书。 +`opensearch.ssl.keyPassphrase` | 设置密钥的密码。如果密钥没有密码,请省略此设置。可选。 +`opensearch.ssl.keystore.path` | 使用 JKS 或 PKCS12/PFX 密钥库文件代替 PEM 证书和密钥。 +`opensearch.ssl.keystore.password` | 设置密钥库的密码。必需。 +`opensearch_security.cookie.secure` | 如果为 OpenSearch Dashboards 启用了 TLS,请将此设置改为 `true`。对于 HTTP,请设置为 `false`。 + +以下 `opensearch_dashboards.yml` 配置展示了 OpenSearch 和 OpenSearch Dashboards 使用演示配置在同一台机器上运行的情形: + +```yml +server.ssl.enabled: true +server.ssl.certificate: /usr/share/opensearch-dashboards/config/client-cert.pem +server.ssl.key: /usr/share/opensearch-dashboards/config/client-cert-key.pem +opensearch.hosts: ["https://localhost:9200"] +opensearch.ssl.verificationMode: full +opensearch.ssl.certificateAuthorities: [ "/usr/share/opensearch-dashboards/config/root-ca.pem", "/usr/share/opensearch-dashboards/config/intermediate-ca.pem" ] +opensearch.username: "kibanaserver" +opensearch.password: "kibanaserver" +opensearch.requestHeadersAllowlist: [ authorization,securitytenant ] +opensearch_security.multitenancy.enabled: true +opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"] +opensearch_security.readonly_mode.roles: ["kibana_read_only"] +opensearch_security.cookie.secure: true +``` + +如果你使用 Docker 安装方式,可以将自定义的 `opensearch_dashboards.yml` 文件传递给容器。要了解更多信息,请参阅 [Docker 安装页面](/install-and-configure/install-opensearch/docker)。 + +启用这些设置并启动应用程序后,你可以通过 `https://localhost:5601` 连接到 OpenSearch Dashboards。如果你的证书是自签名的,可能需要确认浏览器警告。为了避免此类警告(或浏览器完全不兼容),最佳实践是使用来自受信任 CA 的证书。 diff --git a/i18n/zh/install-and-configure/install-dashboards/windows.md b/i18n/zh/install-and-configure/install-dashboards/windows.md new file mode 100644 index 00000000..4897551d --- /dev/null +++ b/i18n/zh/install-and-configure/install-dashboards/windows.md @@ -0,0 +1,51 @@ +--- +title: Windows +--- + +# 在 Windows 上运行 OpenSearch Dashboards + +按照以下步骤在 Windows 上安装 OpenSearch Dashboards。 + +::: info 注意 +确保已安装 zip 解压工具。 +::: + +1. 下载 [`opensearch-dashboards-2.12.0-windows-x64.zip`](https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.12.0/opensearch-dashboards-2.12.0-windows-x64.zip) 压缩包。 + +1. 要解压压缩包内容,请右键单击并选择 **Extract All**(全部解压缩)。 + + **注意**:某些版本的 Windows 操作系统会限制文件路径长度。如果解压时遇到与路径长度相关的错误,请执行以下步骤启用长路径支持: + + 1. 在任务栏 **Start**(开始)旁的搜索框中输入 `powershell`,打开 Powershell。 + 1. 在 Powershell 中运行以下命令: + ```bat + Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled -Type DWORD -Value 1 -Force + ``` + 1. 重启计算机。 + +1. 运行 OpenSearch Dashboards。 + + 有两种方式可以运行 OpenSearch Dashboards: + + 1. 使用 Windows 图形界面运行批处理脚本: + + 1. 进入 OpenSearch Dashboards 安装的顶层目录,打开 `opensearch-dashboards-2.12.0` 文件夹。 + 1. 如有需要,修改 `config` 文件夹中的 `opensearch_dashboards.yml`,以更改 OpenSearch Dashboards 的默认设置。 + 1. 打开 `bin` 文件夹,双击 `opensearch-dashboards.bat` 文件运行批处理脚本。这会打开一个命令提示符窗口,其中运行着一个 OpenSearch Dashboards 实例。 + + 1. 从命令提示符或 Powershell 运行批处理脚本: + + 1. 在任务栏 **Start**(开始)旁的搜索框中输入 `cmd` 打开命令提示符,或输入 `powershell` 打开 Powershell。 + 1. 切换到 OpenSearch Dashboards 安装的顶层目录。 + ```bat + cd \path\to\opensearch-dashboards-2.12.0 + ``` + 1. 如有需要,修改 `config\opensearch_dashboards.yml`。 + 1. 运行批处理脚本以启动 OpenSearch Dashboards。 + ```bat + .\bin\opensearch-dashboards.bat + ``` + +::: tip 提示 +要停止 OpenSearch Dashboards,请在命令提示符或 Powershell 中按 `Ctrl+C`,或者直接关闭命令提示符或 Powershell 窗口。 +::: diff --git a/i18n/zh/install-and-configure/install-opensearch/ansible.md b/i18n/zh/install-and-configure/install-opensearch/ansible.md new file mode 100644 index 00000000..2db8590c --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/ansible.md @@ -0,0 +1,65 @@ +--- +title: Ansible playbook +--- + +# Ansible playbook + +你可以使用 Ansible playbook 安装和配置可用于生产环境的 OpenSearch 集群(Cluster)以及 OpenSearch Dashboards。 + +::: info 注意 +Ansible playbook 仅支持将 OpenSearch 和 OpenSearch Dashboards 部署到 CentOS7 主机。 +::: + +## 前提条件 + +确保已安装 [Ansible](https://www.ansible.com/) 和 [Java 8](https://www.java.com/en/download/manual.jsp)。 + +## 配置 + +1. 克隆 OpenSearch 的 [ansible-playbook](https://github.com/opensearch-project/ansible-playbook) 仓库: + + ```bash + git clone https://github.com/opensearch-project/ansible-playbook + ``` + +2. 在 `inventories/opensearch/hosts` 文件中配置节点(Node)属性: + + ```bash + ansible_host= ansible_user=root ip= + ``` + + 其中: + + - `ansible_host` 是你希望 Ansible playbook 在其上安装 OpenSearch 和 OpenSearch Dashboards 的目标节点的 IP 地址。 + - `ip` 是你希望 OpenSearch 和 OpenSearch Dashboards 绑定的 IP 地址。你可以指定目标节点的私有 IP、localhost 或 0.0.0.0。 + +3. 你可以在 `inventories/opensearch/group_vars/all/all.yml` 文件中修改默认配置值。例如,你可以增大 Java 堆内存大小: + + ```bash + xms_value: 8 + xmx_value: 8 + ``` + +::: info 注意 +确保你可以通过 SSH 直接以 root 用户访问目标节点。 +::: + +## 使用 Ansible playbook 运行 OpenSearch 和 OpenSearch Dashboards + +1. 以 root 权限运行 Ansible playbook: + + ```bash + ansible-playbook -i inventories/opensearch/hosts opensearch.yml --extra-vars "admin_password=Test@123 kibanaserver_password=Test@6789 logstash_password=Test@456" + ``` + + 你可以使用 `admin_password`、`kibanaserver_password` 和 `logstash_password` 变量为保留用户(`admin`、`kibanaserver` 和 `logstash`)设置密码。 + +2. 部署完成后,你可以使用用户名 `admin` 和为 `admin_password` 变量设置的密码访问 OpenSearch 和 OpenSearch Dashboards。 + + 如果将 `ip` 绑定到私有 IP 或 localhost,请确保已登录到部署 playbook 的服务器,以访问 OpenSearch 和 OpenSearch Dashboards: + + ```bash + curl https://localhost:9200 -u 'admin:Test@123' --insecure + ``` + + 如果将 `ip` 绑定到 0.0.0.0,则将 `localhost` 替换为公有 IP 或私有 IP(如果位于同一网络中)。 diff --git a/i18n/zh/install-and-configure/install-opensearch/debian.md b/i18n/zh/install-and-configure/install-opensearch/debian.md new file mode 100644 index 00000000..0462536d --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/debian.md @@ -0,0 +1,514 @@ +--- +title: Debian +--- + +# Debian + +与 [Tarball](/install-and-configure/install-opensearch/tar) 方式相比,使用高级软件包工具(Advanced Packaging Tool,APT)包管理器安装 OpenSearch 要简单得多。安装路径、配置文件位置以及创建由 `systemd` 管理的服务等技术细节,都由包管理器自动处理。 + +总体来说,通过 Debian 发行包安装 OpenSearch 可以分为以下几个步骤: + +1. **下载并安装 OpenSearch。** + - 通过 Debian 软件包手动安装,或从 APT 仓库安装。 +1. **(可选)测试 OpenSearch。** + - 在应用任何自定义配置之前,确认 OpenSearch 能够正常运行。 + - 可以在不启用任何安全功能(无密码、无证书)的情况下测试,也可以使用由打包脚本应用的演示安全配置进行测试。 +1. **根据你的环境配置 OpenSearch。** + - 为 OpenSearch 应用基本设置,并开始在你的环境中使用它。 + +Debian 发行包提供了在基于 Debian 的 Linux 发行版(例如 Ubuntu)中运行 OpenSearch 所需的一切。 + +::: info 注意 +本指南假定你熟悉 Linux 命令行界面(CLI),了解如何输入命令、在目录之间切换以及编辑文本文件。部分示例命令使用 `vi` 文本编辑器,你也可以使用任何其他可用的文本编辑器。 +::: + +## 步骤 1:下载并安装 OpenSearch + +### 通过软件包安装 OpenSearch + +1. 直接从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载所需版本的 Debian 软件包。Debian 软件包提供 **x64** 和 **arm64** 两种架构。 +1. 在命令行中使用 `dpkg` 进行安装。 + ```bash + # x64 + sudo dpkg -i opensearch-2.12.0-linux-x64.deb + + # arm64 + sudo dpkg -i opensearch-2.12.0-linux-arm64.deb + ``` + 对于 OpenSearch 2.12 及更高版本,设置安全演示配置时必须提供自定义的管理员密码。要设置自定义管理员密码,请使用以下命令之一: + ```bash + # x64 + sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD= dpkg -i opensearch-2.12.0-linux-x64.deb + + # arm64 + sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD= dpkg -i opensearch-2.12.0-linux-arm64.deb + ``` + +1. 安装成功后,将 OpenSearch 启用为服务。 + ```bash + sudo systemctl enable opensearch + ``` + +1. 启动 OpenSearch 服务。 + ```bash + sudo systemctl start opensearch + ``` + +1. 验证 OpenSearch 是否已正确启动。 + ```bash + sudo systemctl status opensearch + ``` + +### 指纹验证 + +Debian 软件包未经签名。如果你想验证指纹,OpenSearch 项目在提供 `.deb` 软件包的同时还提供了 `.sig` 文件,可配合 GNU Privacy Guard(GPG)使用。 + +1. 下载所需的 Debian 软件包。 + ```bash + curl -SLO https://artifacts.opensearch.org/releases/bundle/opensearch/2.12.0/opensearch-2.12.0-linux-x64.deb + ``` + +1. 下载对应的签名文件。 + ```bash + curl -SLO https://artifacts.opensearch.org/releases/bundle/opensearch/2.12.0/opensearch-2.12.0-linux-x64.deb.sig + ``` + +1. 下载并导入 GPG 密钥。 + ```bash + curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --import - + ``` + +1. 验证签名。 + ```bash + gpg --verify opensearch-2.12.0-linux-x64.deb.sig opensearch-2.12.0-linux-x64.deb + ``` + +### 从 APT 仓库安装 OpenSearch + +APT 是基于 Debian 的操作系统的主要包管理工具,可用于从 APT 仓库下载并安装 Debian 软件包。 + +1. 安装必要的软件包。 + ```bash + sudo apt-get update && sudo apt-get -y install lsb-release ca-certificates curl gnupg2 + ``` + +1. 导入 GPG 公钥。该密钥用于验证 APT 仓库的签名。 + ```bash + curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring + ``` + +1. 为 OpenSearch 创建 APT 仓库: + ```bash + echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-2.x.list + ``` + +1. 验证仓库是否创建成功。 + ```bash + sudo apt-get update + ``` + +1. 添加仓库信息后,列出 OpenSearch 的所有可用版本: + ```bash + sudo apt list -a opensearch + ``` + +1. 选择要安装的 OpenSearch 版本: + - 除非另行指定,否则将安装 OpenSearch 的最新可用版本。 + ```bash + sudo apt-get install opensearch + ``` + + - 安装特定版本的 OpenSearch: + ```bash + # 使用 opensearch= 手动指定版本 + sudo apt-get install opensearch=2.12.0 + ``` + +1. 安装过程中,安装程序会显示 GPG 密钥指纹。请确认该信息与以下内容一致: + ```bash + Fingerprint: c5b7 4989 65ef d1c2 924b a9d5 39d3 1987 9310 d3fc + ``` + +1. 安装完成后,启用 OpenSearch。 + ```bash + sudo systemctl enable opensearch + ``` + +1. 启动 OpenSearch。 + ```bash + sudo systemctl start opensearch + ``` + +1. 验证 OpenSearch 是否已正确启动。 + ```bash + sudo systemctl status opensearch + ``` + +## 步骤 2:(可选)测试 OpenSearch + +在进行任何配置之前,你应该先测试 OpenSearch 的安装情况。否则,以后出现问题时,很难判断问题是由安装引起的,还是由安装后应用的自定义设置引起的。 + +使用 Debian 软件包安装 OpenSearch 时,会自动应用一些演示安全设置,包括自签名 TLS 证书以及若干用户和角色(Role)。如果你想自行配置这些内容,请参阅[在你的环境中设置 OpenSearch](#step-3-set-up-opensearch-in-your-environment)。 + +::: danger 警告 +默认配置下的 OpenSearch 节点(Node)(使用演示证书和默认密码的用户)不适用于生产环境。如果你计划在生产环境中使用该节点,至少应将演示 TLS 证书替换为你自己的 TLS 证书,并[更新内部用户和密码列表](/security/configuration/yaml)。请参阅[安全配置](/security/configuration/)获取更多指导,确保你的节点按照安全要求进行配置。 +::: + +1. 向服务器发送请求,验证 OpenSearch 是否正在运行。注意这里使用了 `--insecure` 标志,这是因为 TLS 证书是自签名的。 + - 向 9200 端口发送请求: + ```bash + curl -X GET https://localhost:9200 -u 'admin:' --insecure + ``` + + 你应该会得到类似如下的响应: + ```bash + { + "name":"hostname", + "cluster_name":"opensearch", + "cluster_uuid":"QqgpHCbnSRKcPAizqjvoOw", + "version":{ + "distribution":"opensearch", + "number":, + "build_type":, + "build_hash":, + "build_date":, + "build_snapshot":false, + "lucene_version":, + "minimum_wire_compatibility_version":"7.10.0", + "minimum_index_compatibility_version":"7.0.0" + }, + "tagline":"The OpenSearch Project: https://opensearch.org/" + } + ``` + - 查询插件端点: + ```bash + curl -X GET https://localhost:9200/_cat/plugins?v -u 'admin:' --insecure + ``` + + 响应应类似如下: + ```bash + name component version + hostname opensearch-alerting 2.12.0 + hostname opensearch-anomaly-detection 2.12.0 + hostname opensearch-asynchronous-search 2.12.0 + hostname opensearch-cross-cluster-replication 2.12.0 + hostname opensearch-geospatial 2.12.0 + hostname opensearch-index-management 2.12.0 + hostname opensearch-job-scheduler 2.12.0 + hostname opensearch-knn 2.12.0 + hostname opensearch-ml 2.12.0 + hostname opensearch-neural-search 2.12.0 + hostname opensearch-notifications 2.12.0 + hostname opensearch-notifications-core 2.12.0 + hostname opensearch-observability 2.12.0 + hostname opensearch-performance-analyzer 2.12.0 + hostname opensearch-reports-scheduler 2.12.0 + hostname opensearch-security 2.12.0 + hostname opensearch-security-analytics 2.12.0 + hostname opensearch-sql 2.12.0 + ``` + +## 步骤 3:在你的环境中设置 OpenSearch + +没有 OpenSearch 使用经验的用户可能需要一份推荐设置清单,以便开始使用该服务。默认情况下,OpenSearch 不绑定到网络接口,外部主机无法访问。此外,安全设置中填充的是默认用户名和密码。以下建议将帮助你把 OpenSearch 绑定到网络接口、创建并签发 TLS 证书,以及配置基本身份验证。 + +以下推荐设置可以帮助你: + +- 将 OpenSearch 绑定到主机上的某个 IP 或网络接口。 +- 设置 JVM 堆的初始大小和最大大小。 +- 定义一个指向捆绑 JDK 的环境变量。 +- 配置你自己的 TLS 证书——无需第三方证书颁发机构(CA)。 +- 创建一个使用自定义密码的管理员用户。 + +::: info 注意 +如果你运行过安全演示脚本,则需要手动重新配置被修改过的设置。在继续操作之前,请参阅[安全配置](/install-and-configure/configuring-opensearch/)获取指导。 +::: + +::: tip 提示 +在修改任何配置文件之前,最好先保存一份备份。备份文件可用于解决错误配置引起的问题。 +::: + +1. 打开 `opensearch.yml`。 + ```bash + sudo vi /etc/opensearch/opensearch.yml + ``` + +1. 添加以下内容: + ```bash + # 将 OpenSearch 绑定到正确的网络接口。使用 0.0.0.0 + # 表示包含所有可用接口,也可以指定分配给 + # 特定接口的 IP 地址。 + network.host: 0.0.0.0 + + # 除非你已经配置了集群,否则应将 discovery.type + # 设置为 single-node,不然启动服务时 + # 引导检查(bootstrap check)会失败。 + discovery.type: single-node + + # 如果你之前在 opensearch.yml 中禁用了 Security 插件, + # 请务必重新启用它。否则可以跳过此设置。 + plugins.security.disabled: false + ``` + +1. 保存更改并关闭文件。 +1. 指定 JVM 堆的初始大小和最大大小。 + 1. 打开 `jvm.options`。 + ```bash + vi /etc/opensearch/jvm.options + ``` + + 1. 修改堆的初始大小和最大大小。一开始,你应将这两个值设置为可用系统内存的一半。对于专用主机,可以根据工作负载的需求适当调大该值。 + - 例如,如果主机有 8 GB 内存,你可以将堆的初始大小和最大大小设置为 4 GB: + ```bash + -Xms4g + -Xmx4g + ``` + + 1. 保存更改并关闭文件。 + +### 配置 TLS + +TLS 证书允许客户端确认主机的身份,并对客户端与主机之间的流量进行加密,从而为集群(Cluster)提供额外的安全保障。更多信息,请参阅 [Security 插件](/security/)文档中的[配置 TLS 证书](/security/configuration/tls)和[生成证书](/security/configuration/generate-certificates)。对于开发环境中的工作,自签名证书通常就足够了。本节将引导你完成生成自己的 TLS 证书并将其应用到 OpenSearch 主机所需的基本步骤。 + +1. 切换到用于存放证书的目录。 + ```bash + cd /etc/opensearch + ``` + +1. 删除演示证书。 + ```bash + sudo rm -f *pem + ``` + +1. 生成根证书。你将使用它来签发其他证书。 + ```bash + # 为根证书创建私钥 + sudo openssl genrsa -out root-ca-key.pem 2048 + + # 使用私钥创建自签名根证书。请务必 + # 替换传给 -subj 的参数,使其与你的主机相符。 + sudo openssl req -new -x509 -sha256 -key root-ca-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=ROOT" -out root-ca.pem -days 730 + ``` +1. 接下来,创建管理员证书。该证书用于获取提升的权限,以执行与 Security 插件相关的管理任务。 + ```bash + # 为管理员证书创建私钥。 + sudo openssl genrsa -out admin-key-temp.pem 2048 + + # 将私钥转换为 PKCS#8 格式。 + sudo openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem + + # 创建证书签名请求(CSR)。通用名称(CN)使用 "A" 即可,因为该证书 + # 用于验证提升的访问权限,并不与某个主机绑定。 + sudo openssl req -new -key admin-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=A" -out admin.csr + + # 使用之前创建的根证书和私钥签发管理员证书。 + sudo openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 730 + ``` +1. 为正在配置的节点创建证书。 + ```bash + # 为节点证书创建私钥。 + sudo openssl genrsa -out node1-key-temp.pem 2048 + + # 将私钥转换为 PKCS#8 格式。 + sudo openssl pkcs8 -inform PEM -outform PEM -in node1-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node1-key.pem + + # 创建 CSR,并替换传给 -subj 的参数,使其与你的主机相符。 + # CN 应与该主机的 DNS A 记录一致——不要使用主机名。 + sudo openssl req -new -key node1-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=node1.dns.a-record" -out node1.csr + + # 创建一个扩展文件,为该主机定义 SAN DNS 名称。 + # 该名称应与主机的 DNS A 记录一致。 + sudo sh -c 'echo subjectAltName=DNS:node1.dns.a-record > node1.ext' + + # 使用之前创建的根证书和私钥签发节点证书。 + sudo openssl x509 -req -in node1.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node1.pem -days 730 -extfile node1.ext + ``` +1. 删除不再需要的临时文件。 + ```bash + sudo rm -f *temp.pem *csr *ext + ``` + +1. 确保剩余证书的所有者为 opensearch 用户。 + ```bash + sudo chown opensearch:opensearch admin-key.pem admin.pem node1-key.pem node1.pem root-ca-key.pem root-ca.pem root-ca.srl + ``` + +1. 按照[生成证书](/security/configuration/generate-certificates#add-distinguished-names-to-opensearchyml)中的说明,将这些证书添加到 `opensearch.yml`。高级用户也可以选择使用脚本追加这些设置: + ```bash + #! /bin/bash + + # 运行此脚本之前,请务必将节点可分辨名称中的 CN + # 替换为真实的 DNS A 记录。 + + echo "plugins.security.ssl.transport.pemcert_filepath: /etc/opensearch/node1.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.transport.pemkey_filepath: /etc/opensearch/node1-key.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.transport.pemtrustedcas_filepath: /etc/opensearch/root-ca.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.enabled: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.pemcert_filepath: /etc/opensearch/node1.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.pemkey_filepath: /etc/opensearch/node1-key.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.pemtrustedcas_filepath: /etc/opensearch/root-ca.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.allow_default_init_securityindex: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.authcz.admin_dn:" | sudo tee -a /etc/opensearch/opensearch.yml + echo " - 'CN=A,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.nodes_dn:" | sudo tee -a /etc/opensearch/opensearch.yml + echo " - 'CN=node1.dns.a-record,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.audit.type: internal_opensearch" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.enable_snapshot_restore_privilege: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.check_snapshot_restore_write_privileges: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.restapi.roles_enabled: [\"all_access\", \"security_rest_api_access\"]" | sudo tee -a /etc/opensearch/opensearch.yml + ``` + +1. (可选)为自签名根证书添加信任。 + ```bash + # 将根证书复制到正确的目录 + sudo cp /etc/opensearch/root-ca.pem /etc/pki/ca-trust/source/anchors/ + + # 添加信任 + sudo update-ca-trust + ``` + +### 配置用户 + +OpenSearch 可以通过多种方式定义和验证用户。其中一种无需额外后端基础设施的方法是在 `internal_users.yml` 中手动配置用户。有关配置用户的更多信息,请参阅 [YAML 文件](/security/configuration/yaml)。以下步骤说明了如何添加新的内部用户,以及如何使用脚本替换 `admin` 的默认密码。 + +1. 切换到 Security 插件的工具目录。 + ```bash + cd /usr/share/opensearch/plugins/opensearch-security/tools + ``` + +1. 运行 `hash.sh` 生成新密码。 + - 如果未定义 JDK 的路径,该脚本会运行失败。 + ```bash + # 未找到 JDK 时的输出示例…… + $ ./hash.sh + ************************************************************************** + ** This tool will be deprecated in the next major release of OpenSearch ** + ** https://github.com/opensearch-project/security/issues/1755 ** + ************************************************************************** + which: no java in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/user/.local/bin:/home/user/bin) + WARNING: nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is set, will use + ./hash.sh: line 35: java: command not found + ``` + + - 为避免出现问题,请在调用脚本时声明环境变量: + ```bash + OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk ./hash.sh + ``` + + - 在提示符处输入所需的密码,并记下输出的哈希值。 +1. 打开 `internal_users.yml`。 + ```bash + sudo vi /etc/opensearch/opensearch-security/internal_users.yml + ``` + +1. 添加一个新的内部用户,并将 `internal_users.yml` 中的哈希值替换为第 2 步中 `hash.sh` 输出的值。该文件应类似以下示例: + ```bash + --- + # 这是内部用户数据库 + # 哈希值为 bcrypt 哈希,可以使用 plugin/tools/hash.sh 生成 + + _meta: + type: "internalusers" + config_version: 2 + + # 在此处定义你的内部用户 + + admin: + hash: "$2y$1EXAMPLEQqwS8TUcoEXAMPLEeZ3lEHvkEXAMPLERqjyh1icEXAMPLE." + reserved: true + backend_roles: + - "admin" + description: "Admin user" + + user1: + hash: "$2y$12$zoHpvTCRjjQr6h0PEaabueCaGam3/LDvT6rZZGDGMusD7oehQjw/O" + reserved: false + backend_roles: [] + description: "New internal user" + + # 其他用户 + ... + ``` + +### 应用更改 + +现在 TLS 证书已经安装完毕,演示用户也已删除或分配了新密码,最后一步是应用这些配置更改。这最后一个配置步骤需要在主机上运行 OpenSearch 的同时调用 `securityadmin.sh`。 + +1. `securityadmin.sh` 只有在 OpenSearch 运行时才能应用更改。如果你修改了 `opensearch.yml`,请重启 OpenSearch。 + ```bash + sudo systemctl restart opensearch + ``` + +1. 在主机上另开一个终端会话,并切换到包含 `securityadmin.sh` 的目录。 + ```bash + # 切换到正确的目录 + cd /usr/share/opensearch/plugins/opensearch-security/tools + ``` +1. 调用该脚本。有关必须传入的参数的定义,请参阅[使用 securityadmin.sh 应用更改](/security/configuration/security-admin)。 + ```bash + # 如果已在 $PATH 中声明了该环境变量,则可以省略。 + OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk ./securityadmin.sh -cd /etc/opensearch/opensearch-security/ -cacert /etc/opensearch/root-ca.pem -cert /etc/opensearch/admin.pem -key /etc/opensearch/admin-key.pem -icl -nhnv + ``` + +### 验证服务是否正在运行 + +现在,OpenSearch 已在你的主机上运行,并使用了自定义 TLS 证书和用于基本身份验证的安全用户。你可以从另一台主机向 OpenSearch 节点发送 API 请求,以验证外部连通性。 + +在之前的测试中,你将请求发送到了 `localhost`。现在已应用了 TLS 证书,且新证书引用的是主机的实际 DNS 记录,因此发往 `localhost` 的请求将无法通过 CN 检查,证书会被视为无效。你应该将请求发送到生成证书时指定的地址。 + +::: tip 提示 +在发送请求之前,你应该在客户端上添加对根证书的信任。如果不添加信任,则必须使用 `-k` 选项,让 cURL 忽略 CN 和根证书校验。 +::: + +```bash +$ curl https://your.host.address:9200 -u admin:yournewpassword -k +{ + "name":"hostname", + "cluster_name":"opensearch", + "cluster_uuid":"QqgpHCbnSRKcPAizqjvoOw", + "version":{ + "distribution":"opensearch", + "number":, + "build_type":, + "build_hash":, + "build_date":, + "build_snapshot":false, + "lucene_version":, + "minimum_wire_compatibility_version":"7.10.0", + "minimum_index_compatibility_version":"7.0.0" + }, + "tagline":"The OpenSearch Project: https://opensearch.org/" +} +``` + +## 升级到新版本 + +使用 `dpkg` 或 `apt-get` 安装的 OpenSearch 实例可以轻松升级到新版本。 + +### 使用 DPKG 手动升级 + +直接从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载目标升级版本的 Debian 软件包。 + +切换到发行包所在的目录,然后运行以下命令: +```bash +sudo dpkg -i opensearch-2.12.0-linux-x64.deb +``` + +### APT-GET + +使用 `apt-get` 升级到 OpenSearch 的最新版本: +```bash +sudo apt-get upgrade opensearch +``` + +你也可以升级到特定的 OpenSearch 版本: +```bash +sudo apt-get upgrade opensearch= +``` + +## 相关链接 + +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [安装和配置 OpenSearch Dashboards](/install-and-configure/install-dashboards/) +- [OpenSearch 插件安装](/install-and-configure/plugins) +- [关于 Security 插件](/security/) diff --git a/i18n/zh/install-and-configure/install-opensearch/docker.md b/i18n/zh/install-and-configure/install-opensearch/docker.md new file mode 100644 index 00000000..39c80505 --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/docker.md @@ -0,0 +1,500 @@ +--- +title: Docker +--- + +# Docker + +[Docker](https://www.docker.com/) 极大地简化了 OpenSearch 集群(Cluster)的配置和管理过程。你可以从 [Docker Hub](https://hub.docker.com/u/opensearchproject) 或 [Amazon Elastic Container Registry(Amazon ECR)](https://gallery.ecr.aws/opensearchproject/)拉取官方镜像,并使用 [Docker Compose](https://github.com/docker/compose) 和本指南提供的任一示例 Docker Compose 文件快速部署集群。有经验的 OpenSearch 用户还可以通过创建自定义 Docker Compose 文件,进一步定制自己的部署。 + +Docker 容器具有可移植性,可以在任何支持 Docker 的兼容主机(例如 Linux、MacOS 或 Windows)上运行。与 [RPM](/install-and-configure/install-opensearch/rpm) 或手动 [Tarball](/install-and-configure/install-opensearch/tar) 安装等其他安装方式相比,Docker 容器的可移植性带来了更大的灵活性,因为后两者在下载和解压之后都需要额外的配置。 + +::: info 注意 +本指南假定你熟悉 Linux 命令行界面(CLI),了解如何输入命令、在目录之间切换以及编辑文本文件。有关 [Docker](https://www.docker.com/) 或 [Docker Compose](https://github.com/docker/compose) 的帮助,请参阅其官方网站上的文档。 +::: + +## 安装 Docker 和 Docker Compose + +请访问 [Get Docker](https://docs.docker.com/get-docker/),了解如何为你的环境安装和配置 Docker。如果你使用 CLI 安装 Docker Engine,默认情况下 Docker 不会对可用的主机资源做任何限制。根据你的环境,你可能需要在 Docker 中配置资源限制。相关信息请参阅 [Runtime options with Memory, CPUs, and GPUs](https://docs.docker.com/config/containers/resource_constraints/)。 + +::: tip 提示 +Docker Desktop 用户应打开 Docker Desktop,选择 **Settings** → **Resources**,将主机内存使用量设置为至少 4 GB。 +::: + +Docker Compose 是一个让用户通过一条命令启动多个容器的工具。调用 Docker Compose 时需要向它传入一个文件,Docker Compose 会读取其中的设置并启动所需的容器。Docker Compose 会随 Docker Desktop 自动安装,但在命令行环境中操作的用户必须手动安装 Docker Compose。你可以在官方的 [Docker Compose GitHub 页面](https://github.com/docker/compose)上找到安装 Docker Compose 的相关信息。 + +::: tip 提示 +如果你需要手动安装 Docker Compose,并且你的主机支持 Python,可以使用 [pip](https://pypi.org/project/pip/) 自动安装 [Docker Compose 软件包](https://pypi.org/project/docker-compose/)。 +::: + +## 配置重要的主机设置 +在使用 Docker 安装 OpenSearch 之前,请先配置以下设置。这些是可能影响服务性能的最重要的设置,更多信息请参阅[重要的系统设置](/install-and-configure/install-opensearch/#important-settings)。 + +### Linux 设置 +在 Linux 环境中,运行以下命令: + +1. 在主机上禁用内存分页和交换,以提高性能。 + ```bash + sudo swapoff -a + ``` +1. 增加 OpenSearch 可用的内存映射数量。 + ```bash + # 编辑 sysctl 配置文件 + sudo vi /etc/sysctl.conf + + # 添加一行来定义所需的值, + # 如果该键已存在则修改其值, + # 然后保存更改。 + vm.max_map_count=262144 + + # 使用 sysctl 重新加载内核参数 + sudo sysctl -p + + # 检查该值,确认更改已生效 + cat /proc/sys/vm/max_map_count + ``` + +### Windows 设置 +对于通过 Docker Desktop 使用 WSL 的 Windows 工作负载,请在终端中运行以下命令来设置 `vm.max_map_count`: + +```bash +wsl -d docker-desktop +sysctl -w vm.max_map_count=262144 +``` + +## 在 Docker 容器中运行 OpenSearch + +OpenSearch 官方镜像托管在 [Docker Hub](https://hub.docker.com/u/opensearchproject/) 和 [Amazon ECR](https://gallery.ecr.aws/opensearchproject/) 上。如果你想查看这些镜像,可以使用 `docker pull` 逐个拉取,如以下示例所示。 + +[Docker Hub](https://hub.docker.com/u/opensearchproject/): +```bash +docker pull opensearchproject/opensearch:2 +``` + +```bash +docker pull opensearchproject/opensearch-dashboards:2 +``` + +[Amazon ECR](https://gallery.ecr.aws/opensearchproject/): +```bash +docker pull public.ecr.aws/opensearchproject/opensearch:2 +``` + +```bash +docker pull public.ecr.aws/opensearchproject/opensearch-dashboards:2 +``` + +::: tip 提示 +要下载最新可用版本以外的特定版本的 OpenSearch 或 OpenSearch Dashboards,请修改引用镜像处的镜像标签(命令行中或 Docker Compose 文件中)。例如,`opensearchproject/opensearch:2.12.0` 将拉取 OpenSearch 2.12.0 版本。要拉取最新版本,请使用 `opensearchproject/opensearch:latest`。有关可用版本,请参阅官方镜像仓库。 +::: + +在继续之前,你应该先在单个容器中部署 OpenSearch,以验证 Docker 是否正常工作。 + +1. 运行以下命令: + ```bash + # 此命令映射 9200 和 9600 端口,将发现类型设置为 "single-node",并请求最新的 OpenSearch 镜像 + docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:latest + ``` + 对于 OpenSearch 2.12 或更高版本,请在安装之前使用以下命令设置新的自定义管理员密码: + ```bash + docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=" opensearchproject/opensearch:latest + ``` +1. 向 9200 端口发送请求。默认用户名和密码均为 `admin`。 + ```bash + curl https://localhost:9200 -ku 'admin:' + ``` + + - 你应该会得到类似如下的响应: + ```bash + { + "name" : "a937e018cee5", + "cluster_name" : "docker-cluster", + "cluster_uuid" : "GLAjAG6bTeWErFUy_d-CLw", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` +1. 在停止正在运行的容器之前,先列出所有正在运行的容器,并复制你正在测试的 OpenSearch 节点(Node)的容器 ID。在以下示例中,容器 ID 为 `a937e018cee5`: + ```bash + $ docker container ls + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + a937e018cee5 opensearchproject/opensearch:latest "./opensearch-docker…" 19 minutes ago Up 19 minutes 0.0.0.0:9200->9200/tcp, 9300/tcp, 0.0.0.0:9600->9600/tcp, 9650/tcp wonderful_boyd + ``` +1. 将容器 ID 传给 `docker stop`,停止正在运行的容器。 + ```bash + docker stop + ``` + +::: tip 提示 +请记住,`docker container ls` 不会列出已停止的容器。如果你想查看已停止的容器,请使用 `docker container ls -a`。你可以使用 `docker container rm [...]` 手动删除不需要的容器(传入所有要删除的容器 ID,以空格分隔);如果想删除所有已停止的容器,可以使用更简短的命令 `docker container prune`。 +::: + +## 使用 Docker Compose 部署 OpenSearch 集群 + +虽然从技术上讲,可以通过逐条命令创建容器来构建 OpenSearch 集群,但在 YAML 文件中定义环境并让 Docker Compose 管理集群要容易得多。下一节包含一些示例 YAML 文件,你可以使用它们启动一个包含 OpenSearch 和 OpenSearch Dashboards 的预定义集群。这些示例适用于测试和开发,但不适用于生产环境。如果你之前没有使用 Docker Compose 的经验,在修改示例中的字典结构之前,建议先查阅 Docker 的 [Compose 规范](https://docs.docker.com/compose/compose-file/),了解语法和格式方面的指导。 + +定义环境的 YAML 文件称为 Docker Compose 文件。默认情况下,`docker-compose` 命令会首先在当前目录中查找与以下任一名称匹配的文件: +- `docker-compose.yml` +- `docker-compose.yaml` +- `compose.yml` +- `compose.yaml` + +如果当前目录中不存在这些文件,`docker-compose` 命令将会失败。 + +调用 `docker-compose` 时,可以使用 `-f` 标志指定自定义的文件位置和名称: +```bash +# 使用文件的相对路径或绝对路径。 +docker-compose -f /path/to/your-file.yml up +``` + +如果这是你第一次使用 Docker Compose 启动 OpenSearch 集群,请使用以下示例 `docker-compose.yml` 文件。将其保存在主机的主目录中,并命名为 `docker-compose.yml`。该文件会创建一个包含三个容器的集群:两个运行 OpenSearch 服务的容器,以及一个运行 OpenSearch Dashboards 的容器。这些容器通过名为 `opensearch-net` 的桥接网络进行通信,并使用两个卷,每个 OpenSearch 节点各一个。由于该文件没有显式禁用演示安全配置,因此会安装自签名 TLS 证书,并创建使用默认名称和密码的内部用户。 + +### 设置自定义管理员密码 + +从 OpenSearch 2.12 开始,设置演示安全配置时必须提供自定义的管理员密码。请执行以下操作之一: + +- 在运行 `docker-compose.yml` 之前,使用以下命令设置新的自定义管理员密码: + ``` + export OPENSEARCH_INITIAL_ADMIN_PASSWORD= + ``` + +- 在 `docker-compose.yml` 文件所在的文件夹中创建一个 `.env` 文件,在其中设置 `OPENSEARCH_INITIAL_ADMIN_PASSWORD` 并指定一个强密码值。 + +### 示例 docker-compose.yml {#sample-docker-composeyml} + +```yml +version: '3' +services: + opensearch-node1: # 这也是该容器在 Docker 网络中的主机名(即 https://opensearch-node1/) + image: opensearchproject/opensearch:latest # 指定最新可用的镜像——如需特定版本请修改 + container_name: opensearch-node1 + environment: + - cluster.name=opensearch-cluster # 为集群命名 + - node.name=opensearch-node1 # 为在此容器中运行的节点命名 + - discovery.seed_hosts=opensearch-node1,opensearch-node2 # 发现集群时要查找的节点 + - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # 有资格担任集群管理节点的节点 + - bootstrap.memory_lock=true # 禁用 JVM 堆内存交换 + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # 将 JVM 堆的最小值和最大值设置为至少系统内存的 50% + - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD} # 使用演示配置时设置演示管理员用户的密码,OpenSearch 2.12 及更高版本必需 + ulimits: + memlock: + soft: -1 # 将 memlock 设置为不受限制(无软限制或硬限制) + hard: -1 + nofile: + soft: 65536 # opensearch 用户可打开文件的最大数量——至少设置为 65536 + hard: 65536 + volumes: + - opensearch-data1:/usr/share/opensearch/data # 创建名为 opensearch-data1 的卷并将其挂载到容器 + ports: + - 9200:9200 # REST API + - 9600:9600 # Performance Analyzer + networks: + - opensearch-net # 所有容器都将加入同一个 Docker 桥接网络 + opensearch-node2: + image: opensearchproject/opensearch:latest # 应与 opensearch-node1 使用相同的镜像,以免出现问题 + container_name: opensearch-node2 + environment: + - cluster.name=opensearch-cluster + - node.name=opensearch-node2 + - discovery.seed_hosts=opensearch-node1,opensearch-node2 + - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 + - bootstrap.memory_lock=true + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" + - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD} + ulimits: + memlock: + soft: -1 + hard: -1 + nofile: + soft: 65536 + hard: 65536 + volumes: + - opensearch-data2:/usr/share/opensearch/data + networks: + - opensearch-net + opensearch-dashboards: + image: opensearchproject/opensearch-dashboards:latest # 确保 opensearch-dashboards 的版本与其他节点上安装的 opensearch 版本一致 + container_name: opensearch-dashboards + ports: + - 5601:5601 # 将主机端口 5601 映射到容器端口 5601 + expose: + - "5601" # 开放 5601 端口,以便通过 Web 访问 OpenSearch Dashboards + environment: + OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # 定义 OpenSearch Dashboards 要查询的 OpenSearch 节点 + networks: + - opensearch-net + +volumes: + opensearch-data1: + opensearch-data2: + +networks: + opensearch-net: +``` + +::: info 注意 +如果你在 compose 文件中使用环境变量覆盖 `opensearch_dashboards.yml` 设置,请全部使用大写字母,并将句点替换为下划线(例如,对于 `opensearch.hosts`,应使用 `OPENSEARCH_HOSTS`)。这与覆盖 `opensearch.yml` 设置的方式不同,后者只需更改赋值运算符(例如,`opensearch.yml` 中的 `discovery.type: single-node` 在 `docker-compose.yml` 中定义为 `discovery.type=single-node`)。 +::: + +在主机的主目录(包含 `docker-compose.yml` 的目录)中,以分离模式创建并启动容器: +```bash +docker-compose up -d +``` + +验证服务容器是否已正确启动: +```bash +docker-compose ps +``` + +如果某个容器启动失败,你可以查看服务日志: +```bash +# 如果不传入服务名称,docker-compose 将显示所有节点的日志 +docker-compose logs +``` + +在浏览器中访问 http://localhost:5601,验证能否访问 OpenSearch Dashboards。默认用户名和密码均为 `admin`。在你定制部署的安全配置之前,我们不建议在可从公共互联网访问的主机上使用此配置。 + +::: info 注意 +请记住,`localhost` 无法被远程访问。如果你将这些容器部署到远程主机,则需要建立网络连接,并将 `localhost` 替换为该主机对应的 IP 或 DNS 记录。 +::: + +停止集群中正在运行的容器: +```bash +docker-compose down +``` + +::: tip 提示 +`docker-compose down` 会停止正在运行的容器,但不会删除主机上已有的 Docker 卷。如果你不关心这些卷中的内容,可以使用 `-v` 选项删除所有卷,例如 `docker-compose down -v`。 +::: + +## 配置 OpenSearch + +OpenSearch 的 RPM 发行包在安装后需要进行大量配置,而使用 Docker 运行 OpenSearch 集群则不同,你甚至可以在创建容器之前就定义好环境。无论使用 Docker 还是 Docker Compose,都可以做到这一点。 + +例如,请看以下命令: +```bash +docker run \ + -p 9200:9200 -p 9600:9600 \ + -e "discovery.type=single-node" \ + -v /path/to/custom-opensearch.yml:/usr/share/opensearch/config/opensearch.yml \ + opensearchproject/opensearch:latest +``` + +逐一查看该命令的各个部分,可以看到它: +- 映射 `9200` 和 `9600` 端口(`HOST_PORT`:`CONTAINER_PORT`)。 +- 将 `discovery.type` 设置为 `single-node`,以免此单节点部署的引导检查失败。 +- 使用 [-v 标志](https://docs.docker.com/engine/reference/commandline/run#mount-volume--v---read-only)将名为 `custom-opensearch.yml` 的本地文件传入容器,替换镜像中自带的 `opensearch.yml` 文件。 +- 从 Docker Hub 请求 `opensearchproject/opensearch:latest` 镜像。 +- 运行容器。 + +如果将此命令与[示例 docker-compose.yml](#sample-docker-composeyml) 文件进行比较,你可能会注意到一些共同的设置,例如端口映射和镜像引用。不过,该命令只部署了一个运行 OpenSearch 的容器,不会为 OpenSearch Dashboards 创建容器。此外,如果你想使用自定义 TLS 证书、用户或角色(Role),或者定义额外的卷和网络,这条「单行」命令很快就会变得冗长而难以使用。这正是 Docker Compose 发挥作用的地方。 + +使用 Docker Compose 构建 OpenSearch 集群时,你可能会发现,将自定义配置文件从主机传入容器,要比在 `docker-compose.yml` 中逐一列出每项设置更容易。与示例 `docker run` 命令使用 `-v` 标志将主机上的卷挂载到容器类似,compose 文件可以在相应服务下通过子选项指定要挂载的卷。以下截取的 YAML 文件演示了如何将文件或目录挂载到容器。有关卷的用法和语法的完整信息,请参阅 Docker 官方文档中的[卷](https://docs.docker.com/storage/volumes/)。 + +```yml +services: + opensearch-node1: + volumes: + - opensearch-data1:/usr/share/opensearch/data + - ./custom-opensearch.yml:/usr/share/opensearch/config/opensearch.yml + opensearch-node2: + volumes: + - opensearch-data2:/usr/share/opensearch/data + - ./custom-opensearch.yml:/usr/share/opensearch/config/opensearch.yml + opensearch-dashboards: + volumes: + - ./custom-opensearch_dashboards.yml:/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml +``` + +### 用于开发的示例 Docker Compose 文件 + +如果你想基于示例构建自己的 compose 文件,请参考以下示例 `docker-compose.yml` 文件。该示例文件会创建两个 OpenSearch 节点和一个 OpenSearch Dashboards 节点,并禁用了 Security 插件。在阅读[配置基本安全设置](#configuring-basic-security-settings)时,你可以将此示例文件作为起点。 +```yml +version: '3' +services: + opensearch-node1: + image: opensearchproject/opensearch:latest + container_name: opensearch-node1 + environment: + - cluster.name=opensearch-cluster # 为集群命名 + - node.name=opensearch-node1 # 为在此容器中运行的节点命名 + - discovery.seed_hosts=opensearch-node1,opensearch-node2 # 发现集群时要查找的节点 + - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # 有资格担任集群管理节点的节点 + - bootstrap.memory_lock=true # 禁用 JVM 堆内存交换 + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # 将 JVM 堆的最小值和最大值设置为至少系统内存的 50% + - "DISABLE_INSTALL_DEMO_CONFIG=true" # 阻止执行捆绑的演示脚本(该脚本会向 OpenSearch 安装演示证书和安全配置) + - "DISABLE_SECURITY_PLUGIN=true" # 禁用 Security 插件 + ulimits: + memlock: + soft: -1 # 将 memlock 设置为不受限制(无软限制或硬限制) + hard: -1 + nofile: + soft: 65536 # opensearch 用户可打开文件的最大数量——至少设置为 65536 + hard: 65536 + volumes: + - opensearch-data1:/usr/share/opensearch/data # 创建名为 opensearch-data1 的卷并将其挂载到容器 + ports: + - 9200:9200 # REST API + - 9600:9600 # Performance Analyzer + networks: + - opensearch-net # 所有容器都将加入同一个 Docker 桥接网络 + opensearch-node2: + image: opensearchproject/opensearch:latest + container_name: opensearch-node2 + environment: + - cluster.name=opensearch-cluster # 为集群命名 + - node.name=opensearch-node2 # 为在此容器中运行的节点命名 + - discovery.seed_hosts=opensearch-node1,opensearch-node2 # 发现集群时要查找的节点 + - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # 有资格担任集群管理节点的节点 + - bootstrap.memory_lock=true # 禁用 JVM 堆内存交换 + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # 将 JVM 堆的最小值和最大值设置为至少系统内存的 50% + - "DISABLE_INSTALL_DEMO_CONFIG=true" # 阻止执行捆绑的演示脚本(该脚本会向 OpenSearch 安装演示证书和安全配置) + - "DISABLE_SECURITY_PLUGIN=true" # 禁用 Security 插件 + ulimits: + memlock: + soft: -1 # 将 memlock 设置为不受限制(无软限制或硬限制) + hard: -1 + nofile: + soft: 65536 # opensearch 用户可打开文件的最大数量——至少设置为 65536 + hard: 65536 + volumes: + - opensearch-data2:/usr/share/opensearch/data # 创建名为 opensearch-data2 的卷并将其挂载到容器 + networks: + - opensearch-net # 所有容器都将加入同一个 Docker 桥接网络 + opensearch-dashboards: + image: opensearchproject/opensearch-dashboards:latest + container_name: opensearch-dashboards + ports: + - 5601:5601 # 将主机端口 5601 映射到容器端口 5601 + expose: + - "5601" # 开放 5601 端口,以便通过 Web 访问 OpenSearch Dashboards + environment: + - 'OPENSEARCH_HOSTS=["http://opensearch-node1:9200","http://opensearch-node2:9200"]' + - "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # 在 OpenSearch Dashboards 中禁用 Security Dashboards 插件 + networks: + - opensearch-net + +volumes: + opensearch-data1: + opensearch-data2: + +networks: + opensearch-net: +``` + +### 配置基本安全设置 + +在让外部主机访问你的 OpenSearch 集群之前,最好先检查一下部署的安全配置。你可能还记得,在第一个[示例 docker-compose.yml](#sample-docker-composeyml) 文件中,除非通过设置 `DISABLE_SECURITY_PLUGIN=true` 禁用,否则捆绑的脚本会为集群中的节点应用默认的演示安全配置。由于该配置用于演示目的,其默认用户名和密码是公开已知的。因此,我们建议你创建自己的安全配置文件,并使用 `volumes` 将这些文件传入容器。有关 OpenSearch 安全设置的具体指导,请参阅[安全配置](/security/configuration/)。 + +要在配置中使用你自己的证书,请将所有必要的证书添加到 compose 文件的 volumes 部分: +```yml +volumes: + - ./root-ca.pem:/usr/share/opensearch/config/root-ca.pem + - ./admin.pem:/usr/share/opensearch/config/admin.pem + - ./admin-key.pem:/usr/share/opensearch/config/admin-key.pem + - ./node1.pem:/usr/share/opensearch/config/node1.pem + - ./node1-key.pem:/usr/share/opensearch/config/node1-key.pem +``` + +使用 Docker Compose 卷为 OpenSearch 节点添加 TLS 证书时,还应包含一个定义这些证书的自定义 `opensearch.yml` 文件。例如: +```yml +volumes: + - ./root-ca.pem:/usr/share/opensearch/config/root-ca.pem + - ./admin.pem:/usr/share/opensearch/config/admin.pem + - ./admin-key.pem:/usr/share/opensearch/config/admin-key.pem + - ./node1.pem:/usr/share/opensearch/config/node1.pem + - ./node1-key.pem:/usr/share/opensearch/config/node1-key.pem + - ./custom-opensearch.yml:/usr/share/opensearch/config/opensearch.yml +``` + +请记住,compose 文件中指定的证书必须与自定义 `opensearch.yml` 文件中定义的证书相同。你应该将根证书、管理员证书和节点证书替换为你自己的证书。更多信息,请参阅[配置 TLS 证书](/security/configuration/tls)。 +```yml +plugins.security.ssl.transport.pemcert_filepath: node1.pem +plugins.security.ssl.transport.pemkey_filepath: node1-key.pem +plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem +plugins.security.ssl.http.pemcert_filepath: node1.pem +plugins.security.ssl.http.pemkey_filepath: node1-key.pem +plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem +plugins.security.authcz.admin_dn: + - CN=admin,OU=SSL,O=Test,L=Test,C=DE +``` + +配置安全设置后,你的自定义 `opensearch.yml` 文件可能类似以下示例。该示例添加了 TLS 证书和管理员证书的可分辨名称(Distinguished Name,DN),定义了一些权限,并启用了详细的审计日志: +```yml +plugins.security.ssl.transport.pemcert_filepath: node1.pem +plugins.security.ssl.transport.pemkey_filepath: node1-key.pem +plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem +plugins.security.ssl.transport.enforce_hostname_verification: false +plugins.security.ssl.http.enabled: true +plugins.security.ssl.http.pemcert_filepath: node1.pem +plugins.security.ssl.http.pemkey_filepath: node1-key.pem +plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem +plugins.security.allow_default_init_securityindex: true +plugins.security.authcz.admin_dn: + - CN=A,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA +plugins.security.nodes_dn: + - 'CN=N,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA' +plugins.security.audit.type: internal_opensearch +plugins.security.enable_snapshot_restore_privilege: true +plugins.security.check_snapshot_restore_write_privileges: true +plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"] +cluster.routing.allocation.disk.threshold_enabled: false +opendistro_security.audit.config.disabled_rest_categories: NONE +opendistro_security.audit.config.disabled_transport_categories: NONE +``` + +完整的设置列表请参阅 [Security](/security/configuration/)。 + +使用相同的流程,在 `/usr/share/opensearch/config/opensearch-security/config.yml` 中指定[后端配置](/security/configuration/configuration),并在各自的 [YAML 文件](/security/configuration/yaml)中定义新的内部用户、角色、映射、操作组和租户(tenant)。 + +替换证书并创建你自己的内部用户、角色、映射、操作组和租户之后,使用 Docker Compose 启动集群: +```bash +docker-compose up -d +``` + +### 使用插件 + +要将 OpenSearch 镜像与自定义插件(plugin)一起使用,必须先创建一个 [`Dockerfile`](https://docs.docker.com/engine/reference/builder/)。有关创建 Dockerfile 的信息,请参阅 Docker 官方文档。 +``` +FROM opensearchproject/opensearch:latest +RUN /usr/share/opensearch/bin/opensearch-plugin install --batch +``` + +然后运行以下命令: +```bash +# 基于 Dockerfile 构建镜像 +docker build --tag=opensearch-custom-plugin . +# 基于自定义镜像启动容器 +docker run -p 9200:9200 -p 9600:9600 -v /usr/share/opensearch/data opensearch-custom-plugin +``` + +或者,你可能希望在部署之前从镜像中移除某个插件。以下示例 Dockerfile 移除了 Security 插件: +``` +FROM opensearchproject/opensearch:latest +RUN /usr/share/opensearch/bin/opensearch-plugin remove opensearch-security +``` + +你还可以使用 Dockerfile 传入你自己的证书,供 [Security 插件](/security/)使用: +``` +FROM opensearchproject/opensearch:latest +COPY --chown=opensearch:opensearch opensearch.yml /usr/share/opensearch/config/ +COPY --chown=opensearch:opensearch my-key-file.pem /usr/share/opensearch/config/ +COPY --chown=opensearch:opensearch my-certificate-chain.pem /usr/share/opensearch/config/ +COPY --chown=opensearch:opensearch my-root-cas.pem /usr/share/opensearch/config/ +``` + +## 相关链接 + +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [Performance Analyzer](/monitoring-your-cluster/pa/) +- [安装和配置 OpenSearch Dashboards](/install-and-configure/install-dashboards/) +- [关于 OpenSearch 中的安全功能](/security/) diff --git a/i18n/zh/install-and-configure/install-opensearch/helm.md b/i18n/zh/install-and-configure/install-opensearch/helm.md new file mode 100644 index 00000000..9ae0ec59 --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/helm.md @@ -0,0 +1,166 @@ +--- +title: Helm +--- + +# Helm + +Helm 是一个包管理器,可以让你在 Kubernetes 集群(Cluster)中轻松安装和管理 OpenSearch。你可以在 YAML 文件中定义 OpenSearch 配置,并使用 Helm 以版本可控、可重现的方式部署应用程序。 + +Helm chart 包含下表所述的资源。 + +资源 | 描述 +:--- | :--- +`Chart.yaml` | chart 的相关信息。 +`values.yaml` | chart 的默认配置值。 +`templates` | 与配置值组合以生成 Kubernetes 清单文件的模板。 + +默认 Helm chart 中的规范支持许多标准用例和部署方式。你可以修改默认 chart 以配置所需的规范,并设置传输层安全(Transport Layer Security,TLS)和基于角色的访问控制(Role-based Access Control,RBAC)。 + +有关默认配置、安全配置步骤和可配置参数的信息,请参阅 +[README](https://github.com/opensearch-project/helm-charts/blob/main/README.md)。 + +::: info 注意 +此处的说明假定你已有一个预装了 Helm 的 Kubernetes 集群。有关配置 Kubernetes 集群的步骤,请参阅 [Kubernetes 文档](https://kubernetes.io/docs/setup/);有关安装 Helm 的步骤,请参阅 [Helm 文档](https://helm.sh/docs/intro/install/)。 +::: + +## 前提条件 + +默认 Helm chart 会部署一个三节点(Node)集群。我们建议为此部署准备至少 8 GiB 的可用内存。如果可用内存少于 4 GiB,部署很可能会失败。 + +## 使用 Helm 安装 OpenSearch + +1. 将 `opensearch` [helm-charts](https://github.com/opensearch-project/helm-charts) 仓库添加到 Helm: + + ```bash + helm repo add opensearch https://opensearch-project.github.io/helm-charts/ + ``` + +1. 从 chart 仓库更新本地可用的 chart: + + ```bash + helm repo update + ``` + +1. 搜索与 OpenSearch 相关的 Helm chart: + + ```bash + helm search repo opensearch + ``` + + ```bash + NAME CHART VERSION APP VERSION DESCRIPTION + opensearch/opensearch 1.0.7 1.0.0 A Helm chart for OpenSearch + opensearch/opensearch-dashboards 1.0.4 1.0.0 A Helm chart for OpenSearch Dashboards + ``` + +1. 部署 OpenSearch: + + ```bash + helm install my-deployment opensearch/opensearch + ``` + +你也可以手动构建 `opensearch-1.0.0.tgz` 文件: + +1. 切换到 `opensearch` 目录: + + ```bash + cd charts/opensearch + ``` + +1. 打包 Helm chart: + + ```bash + helm package . + ``` + +1. 部署 OpenSearch: + + ```bash + helm install --generate-name opensearch-1.0.0.tgz + ``` + + 输出会显示本次安装实例化的规范。 + 要自定义部署,请通过自定义 YAML 文件传入要覆盖的值: + + ```bash + helm install --values=customvalues.yaml opensearch-1.0.0.tgz + ``` + +对于 OpenSearch 2.12 或更高版本,请在 `values.yaml` 的 `extraEnvs` 下自定义 admin 密码,如下例所示: + +```yaml +extraEnvs: + - name: OPENSEARCH_INITIAL_ADMIN_PASSWORD + value: +``` + +#### 示例输出 + + ```yaml + NAME: opensearch-1-1629223146 + LAST DEPLOYED: Tue Aug 17 17:59:07 2021 + NAMESPACE: default + STATUS: deployed + REVISION: 1 + TEST SUITE: None + NOTES: + Watch all cluster members come up. + $ kubectl get pods --namespace=default -l app=opensearch-cluster-master -w + ``` + +要确认 OpenSearch pod 已启动并正常运行,请运行以下命令: + +```bash +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +opensearch-cluster-master-0 1/1 Running 0 3m56s +opensearch-cluster-master-1 1/1 Running 0 3m56s +opensearch-cluster-master-2 1/1 Running 0 3m56s +``` + +要访问 OpenSearch shell: + +```bash +$ kubectl exec -it opensearch-cluster-master-0 -- /bin/bash +``` + +你可以向该 pod 发送请求,以验证 OpenSearch 已启动并正常运行: + +```json +$ curl -XGET https://localhost:9200 -u 'admin:admin' --insecure +{ + "name" : "opensearch-cluster-master-1", + "cluster_name" : "opensearch-cluster", + "cluster_uuid" : "hP2gq5bPS3SLp8Z7wXm8YQ", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "6.8.0", + "minimum_index_compatibility_version" : "6.0.0-beta1" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" +} +``` + +## 使用 Helm 卸载 + +确定要删除的 OpenSearch 部署: + +```bash +$ helm list +NAME NAMESPACEREVISIONUPDATED STATUS CHART APP VERSION +opensearch-1-1629223146 default 1 2021-08-17 17:59:07.664498239 +0000 UTCdeployedopensearch-1.0.0 1.0.0 +``` + +要删除或卸载某个部署,请运行以下命令: + +```bash +helm delete opensearch-1-1629223146 +``` + +有关安装 OpenSearch Dashboards 的步骤,请参阅[使用 Helm 安装 OpenSearch Dashboards](/install-and-configure/install-dashboards/helm)。 diff --git a/i18n/zh/install-and-configure/install-opensearch/index.md b/i18n/zh/install-and-configure/install-opensearch/index.md new file mode 100644 index 00000000..661ff6a8 --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/index.md @@ -0,0 +1,112 @@ +--- +title: 安装 OpenSearch +--- + +# 安装 OpenSearch + +本节详细介绍如何在主机上安装 OpenSearch,包括哪些操作系统[与 OpenSearch 兼容](#operating-system-compatibility)、需要[开放哪些端口](#network-requirements),以及需要在主机上配置哪些[重要设置](#important-settings)。 + +## 操作系统兼容性 + +OpenSearch 和 OpenSearch Dashboards 兼容使用 [`systemd`](https://en.wikipedia.org/wiki/Systemd) 的 Red Hat Enterprise Linux(RHEL)和基于 Debian 的 Linux 发行版,例如 CentOS、Amazon Linux 2 和 Ubuntu 长期支持版(Long-Term Support,LTS)。虽然 OpenSearch 和 OpenSearch Dashboards 应该可以在大多数 Linux 发行版上运行,但我们只测试了其中一部分。 + +下表列出了我们当前支持的操作系统版本。 + +操作系统 | 版本 +:---------- | :-------- +RHEL/CentOS | 7/8 +Rocky Linux | 8 +Ubuntu | 16.04/18.04/20.04 +Windows Server | 2019 + +## 文件系统建议 + +在生产环境中,请避免使用网络文件系统作为节点(Node)存储。由于网络状况(例如延迟或吞吐量受限)或读写速度等因素,使用网络文件系统作为节点存储可能会导致集群(Cluster)出现性能问题。应尽可能使用安装在主机上的固态硬盘(SSD)作为节点存储。 + +## Java 兼容性 + +适用于 Linux 的 OpenSearch 发行版在 `jdk` 目录中附带了兼容的 [Adoptium JDK](https://adoptium.net/) 版 Java。要查看 JDK 版本,请运行 `./jdk/bin/java -version`。例如,OpenSearch 1.0.0 tarball 附带 Java 15.0.1+9(非 LTS),OpenSearch 1.3.0 附带 Java 11.0.14.1+1(LTS),OpenSearch 2.0.0 附带 Java 17.0.2+8(LTS)。OpenSearch 已在所有兼容的 Java 版本上经过测试。 + +OpenSearch 版本 | 兼容的 Java 版本 | 内置的 Java 版本 +:---------- | :-------- | :----------- +1.0--1.2.x | 11, 15 | 15.0.1+9 +1.3.x | 8, 11, 14 | 11.0.22+7 +2.0.0--2.11.x | 11, 17 | 17.0.2+8 +2.12.0 | 11, 17, 21 | 21.0.2+13 + +要使用其他 Java 安装,请将 `OPENSEARCH_JAVA_HOME` 或 `JAVA_HOME` 环境变量设置为 Java 的安装位置。例如: +```bash +export OPENSEARCH_JAVA_HOME=/path/to/opensearch-2.12.0/jdk +``` + +## 网络要求 + +需要为 OpenSearch 组件开放以下端口。 + +端口号 | OpenSearch 组件 +:--- | :--- +443 | 启用传输中加密(TLS)的 AWS OpenSearch Service 中的 OpenSearch Dashboards +5601 | OpenSearch Dashboards +9200 | OpenSearch REST API +9250 | 跨集群搜索 +9300 | 节点通信和传输 +9600 | Performance Analyzer + +## 重要设置 + +对于生产工作负载,请确保 [Linux 设置](https://www.kernel.org/doc/Documentation/sysctl/vm.txt) `vm.max_map_count` 至少设置为 262144。即使使用 Docker 镜像,也要在*宿主机*上设置该值。要查看当前值,请运行以下命令: + +```bash +cat /proc/sys/vm/max_map_count +``` + +要增大该值,请在 `/etc/sysctl.conf` 中添加以下行: + +``` +vm.max_map_count=262144 +``` + +然后运行 `sudo sysctl -p` 重新加载。 + +对于 Windows 工作负载,可以运行以下命令设置 `vm.max_map_count`: + +```bash +wsl -d docker-desktop +sysctl -w vm.max_map_count=262144 +``` + +[示例 docker-compose.yml](/install-and-configure/install-opensearch/docker#sample-docker-composeyml) 文件中还包含几项关键设置: + +- `bootstrap.memory_lock=true` + + 禁用内存交换(与 `memlock` 配合使用)。内存交换会大幅降低性能和稳定性,因此应确保在生产集群上禁用它。 + + 启用 `bootstrap.memory_lock` 设置会使 JVM 预留其所需的全部内存。[Java SE Hotspot VM 垃圾回收调优指南](https://docs.oracle.com/javase/9/gctuning/other-considerations.htm#JSGCT-GUID-B29C9153-3530-4C15-9154-E74F44E3DAD9)记录了默认 1 GB 的 Class Metadata 本机内存预留。再加上 Java 堆,在内存低于这些要求的虚拟机上,可能会因本机内存不足而出错。为防止出错,请使用 `-XX:CompressedClassSpaceSize` 或 `-XX:MaxMetaspaceSize` 限制预留内存的大小,并设置 Java 堆的大小,以确保有足够的系统内存。 + +- `OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m` + + 设置 Java 堆的大小(我们建议设置为系统内存的一半)。 + +- `nofile 65536` + + 将 OpenSearch 用户可打开的文件数上限设置为 65536。 + +- `port 9600` + + 允许你通过 9600 端口访问 Performance Analyzer。 + +::: info 注意 +不要在多个位置声明相同的 JVM 选项,否则可能导致意外行为或 OpenSearch 服务无法启动。如果使用环境变量声明 JVM 选项(例如 `OPENSEARCH_JAVA_OPTS=-Xms3g -Xmx3g`),则应注释掉 `config/jvm.options` 中对该 JVM 选项的所有引用。反之,如果在 `config/jvm.options` 中定义了 JVM 选项,则不应再使用环境变量定义这些 JVM 选项。 +::: + +## 重要系统属性 + +OpenSearch 提供了许多系统属性(如下表所示),你可以使用 `-D` 命令行参数形式在 `config/jvm.options` 或 `OPENSEARCH_JAVA_OPTS` 中指定这些属性。 + +属性 | 描述 +:---------- | :-------- +`opensearch.xcontent.string.length.max=` | 默认情况下,OpenSearch 不限制 JSON/YAML/CBOR/Smile 字符串字段(Field)的最大长度。为了保护集群免受潜在的分布式拒绝服务(DDoS)攻击或内存问题的影响,你可以将 `opensearch.xcontent.string.length.max` 系统属性设置为合理的上限(最大值为 2,147,483,647),例如 `-Dopensearch.xcontent.string.length.max=5000000`。 | +`opensearch.xcontent.fast_double_writer=[true|false]` | 默认情况下,OpenSearch 使用 Java 运行时环境提供的默认实现序列化浮点数。将此值设置为 `true` 可使用 Schubfach 算法,该算法速度更快,但可能导致精度上的细微差异。默认值为 `false`。 | +`opensearch.xcontent.name.length.max=` | 默认情况下,OpenSearch 不限制 JSON/YAML/CBOR/Smile 字段名的最大长度。为了保护集群免受潜在的 DDoS 攻击或内存问题的影响,你可以将 `opensearch.xcontent.name.length.max` 系统属性设置为合理的上限(最大值为 2,147,483,647),例如 `-Dopensearch.xcontent.name.length.max=50000`。 | +`opensearch.xcontent.depth.max=` | 默认情况下,OpenSearch 不限制 JSON/YAML/CBOR/Smile 文档(Document)的最大嵌套深度。为了保护集群免受潜在的 DDoS 攻击或内存问题的影响,你可以将 `opensearch.xcontent.depth.max` 系统属性设置为合理的上限(最大值为 2,147,483,647),例如 `-Dopensearch.xcontent.name.length.max=1000`。 | +`opensearch.xcontent.codepoint.max=` | 默认情况下,OpenSearch 将 YAML 文档的最大大小(以码位计)限制为 `52428800`。为了保护集群免受潜在的 DDoS 攻击或内存问题的影响,你可以将 `opensearch.xcontent.codepoint.max` 系统属性更改为合理的上限(最大值为 2,147,483,647)。例如 `-Dopensearch.xcontent.codepoint.max=5000000`。 | diff --git a/i18n/zh/install-and-configure/install-opensearch/rpm.md b/i18n/zh/install-and-configure/install-opensearch/rpm.md new file mode 100644 index 00000000..5a55ea68 --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/rpm.md @@ -0,0 +1,492 @@ +--- +title: RPM +--- + +# RPM + +与 [Tarball](/install-and-configure/install-opensearch/tar) 方式相比,使用 RPM 包管理器(RPM Package Manager,RPM)安装 OpenSearch 要简单得多。安装路径、配置文件位置以及创建由 `systemd` 管理的服务等技术细节,都由包管理器自动处理。 + +总体来说,通过 RPM 发行包安装 OpenSearch 可以分为以下几个步骤: + +1. **下载并安装 OpenSearch。** + - 通过 RPM 软件包手动安装,或从 YUM 仓库安装。 +1. **(可选)测试 OpenSearch。** + - 在应用任何自定义配置之前,确认 OpenSearch 能够正常运行。 + - 可以在不启用任何安全功能(无密码、无证书)的情况下测试,也可以使用由打包脚本应用的演示安全配置进行测试。 +1. **根据你的环境配置 OpenSearch。** + - 为 OpenSearch 应用基本设置,并开始在你的环境中使用它。 + +RPM 发行包提供了在 Red Hat 或基于 Red Hat 的 Linux 发行版中运行 OpenSearch 所需的一切。有关支持的操作系统列表,请参阅[操作系统兼容性](/install-and-configure/install-opensearch/#operating-system-compatibility)。 + +::: info 注意 +本指南假定你熟悉 Linux 命令行界面(CLI),了解如何输入命令、在目录之间切换以及编辑文本文件。部分示例命令使用 `vi` 文本编辑器,你也可以使用任何其他可用的文本编辑器。 +::: + +## 步骤 1:下载并安装 OpenSearch + +### 通过软件包安装 OpenSearch + +1. 直接从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载所需版本的 RPM 软件包。RPM 软件包提供 **x64** 和 **arm64** 两种架构。 +1. 导入 GNU Privacy Guard(GPG)公钥。该密钥用于验证你的 OpenSearch 实例是否经过签名。 + + ```bash + sudo rpm --import https://artifacts.opensearch.org/publickeys/opensearch.pgp + ``` + +1. 对于 OpenSearch 2.12 及更高版本,设置安全演示配置时必须提供自定义的管理员密码。要设置自定义管理员密码,请使用以下命令之一: + + ```bash + # 使用 yum 安装 x64 软件包。 + sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD= yum install opensearch-2.12.0-linux-x64.rpm + + # 使用 rpm 安装 x64 软件包。 + sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD= rpm -ivh opensearch-2.12.0-linux-x64.rpm + + # 使用 yum 安装 arm64 软件包。 + sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD= yum install opensearch-2.12.0-linux-x64.rpm + + # 使用 rpm 安装 arm64 软件包。 + sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD= rpm -ivh opensearch-2.12.0-linux-x64.rpm + ``` + +1. 在命令行中,你可以使用 `rpm` 或 `yum` 安装该软件包。 + + ```bash + # 使用 yum 安装 x64 软件包。 + sudo yum install opensearch-2.12.0-linux-x64.rpm + + # 使用 rpm 安装 x64 软件包。 + sudo rpm -ivh opensearch-2.12.0-linux-x64.rpm + + # 使用 yum 安装 arm64 软件包。 + sudo yum install opensearch-2.12.0-linux-x64.rpm + + # 使用 rpm 安装 arm64 软件包。 + sudo rpm -ivh opensearch-2.12.0-linux-x64.rpm + ``` + +1. 安装成功后,将 OpenSearch 启用为服务。 + + ```bash + sudo systemctl enable opensearch + ``` + +1. 启动 OpenSearch。 + + ```bash + sudo systemctl start opensearch + ``` + +1. 验证 OpenSearch 是否已正确启动: + + ```bash + sudo systemctl status opensearch + ``` + +### 从 YUM 仓库安装 OpenSearch + +YUM 是基于 Red Hat 的操作系统的主要包管理工具,可用于从 YUM 仓库下载并安装 RPM 软件包。 + +1. 为 OpenSearch 创建本地仓库文件: + ```bash + sudo curl -SL https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/opensearch-2.x.repo -o /etc/yum.repos.d/opensearch-2.x.repo + ``` + +1. 清理 YUM 缓存,以确保安装顺利进行: + ```bash + sudo yum clean all + ``` + +1. 验证仓库是否创建成功。 + ```bash + sudo yum repolist + ``` + +1. 下载仓库文件后,列出 OpenSearch 的所有可用版本: + ```bash + sudo yum list opensearch --showduplicates + ``` + +1. 选择要安装的 OpenSearch 版本: + - 除非另行指定,否则将安装 OpenSearch 的最新可用版本。 + ```bash + sudo yum install opensearch + ``` + + - 安装特定版本的 OpenSearch: + ```bash + sudo yum install 'opensearch-2.12.0' + ``` + +1. 安装过程中,安装程序会显示 GPG 密钥指纹。请确认该信息与以下内容一致: + ```bash + Fingerprint: c5b7 4989 65ef d1c2 924b a9d5 39d3 1987 9310 d3fc + ``` + + - 如果正确,请输入 `yes` 或 `y`,OpenSearch 将继续安装。 +1. 安装完成后,即可运行 OpenSearch。 + ```bash + sudo systemctl start opensearch + ``` + +1. 验证 OpenSearch 是否已正确启动。 + ```bash + sudo systemctl status opensearch + ``` + +## 步骤 2:(可选)测试 OpenSearch + +在进行任何配置之前,你应该先测试 OpenSearch 的安装情况。否则,以后出现问题时,很难判断问题是由安装引起的,还是由安装后应用的自定义设置引起的。 + +使用 RPM 软件包安装 OpenSearch 时,会自动应用一些演示安全设置,包括自签名 TLS 证书以及若干用户和角色(Role)。如果你想自行配置这些内容,请参阅[在你的环境中设置 OpenSearch](#step-3-set-up-opensearch-in-your-environment)。 + +::: danger 警告 +默认配置下的 OpenSearch 节点(Node)(使用演示证书和默认密码的用户)不适用于生产环境。如果你计划在生产环境中使用该节点,至少应将演示 TLS 证书替换为你自己的 TLS 证书,并[更新内部用户和密码列表](/security/configuration/yaml)。请参阅[安全配置](/security/configuration/)获取更多指导,确保你的节点按照安全要求进行配置。 +::: + +1. 向服务器发送请求,验证 OpenSearch 是否正在运行。注意这里使用了 `--insecure` 标志,这是因为 TLS 证书是自签名的。 + - 向 9200 端口发送请求: + ```bash + curl -X GET https://localhost:9200 -u 'admin:' --insecure + ``` + + 你应该会得到类似如下的响应: + ```bash + { + "name" : "hostname", + "cluster_name" : "opensearch", + "cluster_uuid" : "6XNc9m2gTUSIoKDqJit0PA", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` + - 查询插件端点: + ```bash + curl -X GET https://localhost:9200/_cat/plugins?v -u 'admin:' --insecure + ``` + + 响应应类似如下: + ```bash + name component version + hostname opensearch-alerting 2.12.0 + hostname opensearch-anomaly-detection 2.12.0 + hostname opensearch-asynchronous-search 2.12.0 + hostname opensearch-cross-cluster-replication 2.12.0 + hostname opensearch-index-management 2.12.0 + hostname opensearch-job-scheduler 2.12.0 + hostname opensearch-knn 2.12.0 + hostname opensearch-ml 2.12.0 + hostname opensearch-notifications 2.12.0 + hostname opensearch-notifications-core 2.12.0 + hostname opensearch-observability 2.12.0 + hostname opensearch-performance-analyzer 2.12.0 + hostname opensearch-reports-scheduler 2.12.0 + hostname opensearch-security 2.12.0 + hostname opensearch-sql 2.12.0 + ``` + +## 步骤 3:在你的环境中设置 OpenSearch + +没有 OpenSearch 使用经验的用户可能需要一份推荐设置清单,以便开始使用该服务。默认情况下,OpenSearch 不绑定到网络接口,外部主机无法访问。此外,安全设置中填充的是默认用户名和密码。以下建议将帮助你把 OpenSearch 绑定到网络接口、创建并签发 TLS 证书,以及配置基本身份验证。 + +以下推荐设置可以帮助你: + +- 将 OpenSearch 绑定到主机上的某个 IP 或网络接口。 +- 设置 JVM 堆的初始大小和最大大小。 +- 定义一个指向捆绑 JDK 的环境变量。 +- 配置你自己的 TLS 证书——无需第三方证书颁发机构(CA)。 +- 创建一个使用自定义密码的管理员用户。 + +::: info 注意 +如果你运行过安全演示脚本,则需要手动重新配置被修改过的设置。在继续操作之前,请参阅[安全配置](/install-and-configure/configuring-opensearch/)获取指导。 +::: + +::: tip 提示 +在修改任何配置文件之前,最好先保存一份备份。备份文件可用于解决错误配置引起的问题。 +::: + +1. 打开 `opensearch.yml`。 + ```bash + sudo vi /etc/opensearch/opensearch.yml + ``` + +1. 添加以下内容: + ```bash + # 将 OpenSearch 绑定到正确的网络接口。使用 0.0.0.0 + # 表示包含所有可用接口,也可以指定分配给 + # 特定接口的 IP 地址。 + network.host: 0.0.0.0 + + # 除非你已经配置了集群,否则应将 discovery.type + # 设置为 single-node,不然启动服务时 + # 引导检查(bootstrap check)会失败。 + discovery.type: single-node + + # 如果你之前在 opensearch.yml 中禁用了 Security 插件, + # 请务必重新启用它。否则可以跳过此设置。 + plugins.security.disabled: false + ``` + +1. 保存更改并关闭文件。 +1. 指定 JVM 堆的初始大小和最大大小。 + 1. 打开 `jvm.options`。 + ```bash + vi /etc/opensearch/jvm.options + ``` + + 1. 修改堆的初始大小和最大大小。一开始,你应将这两个值设置为可用系统内存的一半。对于专用主机,可以根据工作负载的需求适当调大该值。 + - 例如,如果主机有 8 GB 内存,你可以将堆的初始大小和最大大小设置为 4 GB: + ```bash + -Xms4g + -Xmx4g + ``` + + 1. 保存更改并关闭文件。 + +### 配置 TLS + +TLS 证书允许客户端确认主机的身份,并对客户端与主机之间的流量进行加密,从而为集群(Cluster)提供额外的安全保障。更多信息,请参阅 [Security 插件](/security/)文档中的[配置 TLS 证书](/security/configuration/tls)和[生成证书](/security/configuration/generate-certificates)。对于开发环境中的工作,自签名证书通常就足够了。本节将引导你完成生成自己的 TLS 证书并将其应用到 OpenSearch 主机所需的基本步骤。 + +1. 切换到用于存放证书的目录。 + ```bash + cd /etc/opensearch + ``` + +1. 删除演示证书。 + ```bash + sudo rm -f *pem + ``` + +1. 生成根证书。你将使用它来签发其他证书。 + ```bash + # 为根证书创建私钥 + sudo openssl genrsa -out root-ca-key.pem 2048 + + # 使用私钥创建自签名根证书。请务必 + # 替换传给 -subj 的参数,使其与你的主机相符。 + sudo openssl req -new -x509 -sha256 -key root-ca-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=ROOT" -out root-ca.pem -days 730 + ``` +1. 接下来,创建管理员证书。该证书用于获取提升的权限,以执行与 Security 插件相关的管理任务。 + ```bash + # 为管理员证书创建私钥。 + sudo openssl genrsa -out admin-key-temp.pem 2048 + + # 将私钥转换为 PKCS#8 格式。 + sudo openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem + + # 创建证书签名请求(CSR)。通用名称(CN)使用 "A" 即可,因为该证书 + # 用于验证提升的访问权限,并不与某个主机绑定。 + sudo openssl req -new -key admin-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=A" -out admin.csr + + # 使用之前创建的根证书和私钥签发管理员证书。 + sudo openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 730 + ``` +1. 为正在配置的节点创建证书。 + ```bash + # 为节点证书创建私钥。 + sudo openssl genrsa -out node1-key-temp.pem 2048 + + # 将私钥转换为 PKCS#8 格式。 + sudo openssl pkcs8 -inform PEM -outform PEM -in node1-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node1-key.pem + + # 创建 CSR,并替换传给 -subj 的参数,使其与你的主机相符。 + # CN 应与该主机的 DNS A 记录一致——不要使用主机名。 + sudo openssl req -new -key node1-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=node1.dns.a-record" -out node1.csr + + # 创建一个扩展文件,为该主机定义 SAN DNS 名称。 + # 该名称应与主机的 DNS A 记录一致。 + sudo sh -c 'echo subjectAltName=DNS:node1.dns.a-record > node1.ext' + + # 使用之前创建的根证书和私钥签发节点证书。 + sudo openssl x509 -req -in node1.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node1.pem -days 730 -extfile node1.ext + ``` +1. 删除不再需要的临时文件。 + ```bash + sudo rm -f *temp.pem *csr *ext + ``` + +1. 确保剩余证书的所有者为 opensearch 用户。 + ```bash + sudo chown opensearch:opensearch admin-key.pem admin.pem node1-key.pem node1.pem root-ca-key.pem root-ca.pem root-ca.srl + ``` + +1. 按照[生成证书](/security/configuration/generate-certificates#add-distinguished-names-to-opensearchyml)中的说明,将这些证书添加到 `opensearch.yml`。高级用户也可以选择使用脚本追加这些设置: + ```bash + #! /bin/bash + + # 运行此脚本之前,请务必将节点可分辨名称中的 CN + # 替换为真实的 DNS A 记录。 + + echo "plugins.security.ssl.transport.pemcert_filepath: /etc/opensearch/node1.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.transport.pemkey_filepath: /etc/opensearch/node1-key.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.transport.pemtrustedcas_filepath: /etc/opensearch/root-ca.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.enabled: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.pemcert_filepath: /etc/opensearch/node1.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.pemkey_filepath: /etc/opensearch/node1-key.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.ssl.http.pemtrustedcas_filepath: /etc/opensearch/root-ca.pem" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.allow_default_init_securityindex: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.authcz.admin_dn:" | sudo tee -a /etc/opensearch/opensearch.yml + echo " - 'CN=A,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.nodes_dn:" | sudo tee -a /etc/opensearch/opensearch.yml + echo " - 'CN=node1.dns.a-record,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.audit.type: internal_opensearch" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.enable_snapshot_restore_privilege: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.check_snapshot_restore_write_privileges: true" | sudo tee -a /etc/opensearch/opensearch.yml + echo "plugins.security.restapi.roles_enabled: [\"all_access\", \"security_rest_api_access\"]" | sudo tee -a /etc/opensearch/opensearch.yml + ``` + +1. (可选)为自签名根证书添加信任。 + ```bash + # 将根证书复制到正确的目录 + sudo cp /etc/opensearch/root-ca.pem /etc/pki/ca-trust/source/anchors/ + + # 添加信任 + sudo update-ca-trust + ``` + +### 配置用户 + +OpenSearch 可以通过多种方式定义和验证用户。其中一种无需额外后端基础设施的方法是在 `internal_users.yml` 中手动配置用户。有关配置用户的更多信息,请参阅 [YAML 文件](/security/configuration/yaml)。以下步骤说明了如何删除除 `admin` 用户之外的所有演示用户,以及如何使用脚本替换 `admin` 的默认密码。 + +1. 切换到 Security 插件的工具目录。 + ```bash + cd /usr/share/opensearch/plugins/opensearch-security/tools + ``` + +1. 运行 `hash.sh` 生成新密码。 + - 如果未定义 JDK 的路径,该脚本会运行失败。 + ```bash + # 未找到 JDK 时的输出示例…… + $ ./hash.sh + ************************************************************************** + ** This tool will be deprecated in the next major release of OpenSearch ** + ** https://github.com/opensearch-project/security/issues/1755 ** + ************************************************************************** + which: no java in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/user/.local/bin:/home/user/bin) + WARNING: nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is set, will use + ./hash.sh: line 35: java: command not found + ``` + - 为避免出现问题,请在调用脚本时声明环境变量: + ```bash + OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk ./hash.sh + ``` + + - 在提示符处输入所需的密码,并记下输出的哈希值。 +1. 打开 `internal_users.yml`。 + ```bash + sudo vi /etc/opensearch/opensearch-security/internal_users.yml + ``` + +1. 删除除 `admin` 之外的所有演示用户,并将哈希值替换为之前步骤中 `hash.sh` 输出的值。该文件应类似以下示例: + ```bash + --- + # 这是内部用户数据库 + # 哈希值为 bcrypt 哈希,可以使用 plugin/tools/hash.sh 生成 + + _meta: + type: "internalusers" + config_version: 2 + + # 在此处定义你的内部用户 + + admin: + hash: "$2y$1EXAMPLEQqwS8TUcoEXAMPLEeZ3lEHvkEXAMPLERqjyh1icEXAMPLE." + reserved: true + backend_roles: + - "admin" + description: "Admin user" + ``` + +### 应用更改 + +现在 TLS 证书已经安装完毕,演示用户也已删除或分配了新密码,最后一步是应用这些配置更改。这最后一个配置步骤需要在主机上运行 OpenSearch 的同时调用 `securityadmin.sh`。 + +1. `securityadmin.sh` 只有在 OpenSearch 运行时才能应用更改。如果你修改了 `opensearch.yml`,请重启 OpenSearch。 + ```bash + sudo systemctl restart opensearch + ``` + +1. 在主机上另开一个终端会话,并切换到包含 `securityadmin.sh` 的目录。 + ```bash + # 切换到正确的目录 + cd /usr/share/opensearch/plugins/opensearch-security/tools + ``` + +1. 调用该脚本。有关必须传入的参数的定义,请参阅[使用 securityadmin.sh 应用更改](/security/configuration/security-admin)。 + ```bash + # 如果已在 $PATH 中声明了该环境变量,则可以省略。 + OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk ./securityadmin.sh -cd /etc/opensearch/opensearch-security/ -cacert /etc/opensearch/root-ca.pem -cert /etc/opensearch/admin.pem -key /etc/opensearch/admin-key.pem -icl -nhnv + ``` + +### 验证服务是否正在运行 + +现在,OpenSearch 已在你的主机上运行,并使用了自定义 TLS 证书和用于基本身份验证的安全用户。你可以从另一台主机向 OpenSearch 节点发送 API 请求,以验证外部连通性。 + +在之前的测试中,你将请求发送到了 `localhost`。现在已应用了 TLS 证书,且新证书引用的是主机的实际 DNS 记录,因此发往 `localhost` 的请求将无法通过 CN 检查,证书会被视为无效。你应该将请求发送到生成证书时指定的地址。 + +::: tip 提示 +在发送请求之前,你应该在客户端上添加对根证书的信任。如果不添加信任,则必须使用 `-k` 选项,让 cURL 忽略 CN 和根证书校验。 +::: + +```bash +$ curl https://your.host.address:9200 -u admin:yournewpassword -k +{ + "name" : "hostname-here", + "cluster_name" : "opensearch", + "cluster_uuid" : "efC0ANNMQlGQ5TbhNflVPg", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" +} +``` + +## 升级到新版本 + +使用 RPM 或 YUM 安装的 OpenSearch 实例可以轻松升级到新版本。我们建议使用 YUM 进行升级,但你也可以使用 RPM 升级。 + +### 使用 RPM 手动升级 + +直接从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)下载目标升级版本的 RPM 软件包。 + +切换到发行包所在的目录,然后运行以下命令: +```bash +rpm -Uvh opensearch-2.12.0-linux-x64.rpm +``` + +### YUM + +使用 YUM 升级到 OpenSearch 的最新版本: +```bash +sudo yum update +``` + + 你也可以升级到特定的 OpenSearch 版本: + ```bash + sudo yum update opensearch- + ``` + +## 相关链接 + +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [安装和配置 OpenSearch Dashboards](/install-and-configure/install-dashboards/) +- [OpenSearch 插件安装](/install-and-configure/plugins) +- [关于 Security 插件](/security/) diff --git a/i18n/zh/install-and-configure/install-opensearch/tar.md b/i18n/zh/install-and-configure/install-opensearch/tar.md new file mode 100644 index 00000000..141a58b6 --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/tar.md @@ -0,0 +1,568 @@ +--- +title: Tarball +--- + +# Tarball + +通过 tarball(也称为 tar 归档文件)安装 OpenSearch,适合希望对文件权限、安装路径等安装细节进行精细控制的用户。 + +总体来说,通过 tarball 安装 OpenSearch 可以分为以下几个步骤: + +1. **下载并解压 OpenSearch。** +1. **配置重要的系统设置。** + - 这些设置在修改任何 OpenSearch 文件之前应用于主机。 +1. **(可选)测试 OpenSearch。** + - 在应用任何自定义配置之前,确认 OpenSearch 能够正常运行。 + - 可以在不启用任何安全功能(无密码、无证书)的情况下测试,也可以使用由打包脚本应用的演示安全配置进行测试。 +1. **根据你的环境配置 OpenSearch。** + - 为 OpenSearch 应用基本设置,并开始在你的环境中使用它。 + +tarball 是一个自包含的目录,其中包含运行 OpenSearch 所需的一切,包括集成的 Java 开发工具包(Java Development Kit,JDK)。这种安装方式兼容大多数 Linux 发行版,包括 CentOS 7、Amazon Linux 2 和 Ubuntu 18.04。如果你有自己的 Java 安装,并在终端中设置了环境变量 `JAVA_HOME`,那么在 macOS 上也可以使用。 + +::: info 注意 +本指南假定你熟悉 Linux 命令行界面(CLI),了解如何输入命令、在目录之间切换以及编辑文本文件。部分示例命令使用 `vi` 文本编辑器,你也可以使用任何其他可用的文本编辑器。 +::: + +## 步骤 1:下载并解压 OpenSearch + +1. 从 [OpenSearch 下载页面](https://opensearch.org/downloads.html)或通过命令行(例如使用 `wget`)下载相应的 tar.gz 归档文件。 + ```bash + # x64 + wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.12.0/opensearch-2.12.0-linux-x64.tar.gz + + # ARM64 + wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.12.0/opensearch-2.12.0-linux-arm64.tar.gz + ``` +1. 解压 tarball 的内容。 + ```bash + # x64 + tar -xvf opensearch-2.12.0-linux-x64.tar.gz + + # ARM64 + tar -xvf opensearch-2.12.0-linux-arm64.tar.gz + ``` + +## 步骤 2:配置重要的系统设置 + +在启动 OpenSearch 之前,你应该检查一些[重要的系统设置](/install-and-configure/install-opensearch/)。 +1. 在主机上禁用内存分页和交换,以提高性能。 + ```bash + sudo swapoff -a + ``` + +1. 增加 OpenSearch 可用的内存映射数量。 + ```bash + # 编辑 sysctl 配置文件 + sudo vi /etc/sysctl.conf + + # 添加一行来定义所需的值, + # 如果该键已存在则修改其值, + # 然后保存更改。 + vm.max_map_count=262144 + + # 使用 sysctl 重新加载内核参数 + sudo sysctl -p + + # 检查该值,确认更改已生效 + cat /proc/sys/vm/max_map_count + ``` + +## 步骤 3:(可选)测试 OpenSearch + +在继续之前,你应该先测试 OpenSearch 的安装情况。否则,以后出现问题时,很难判断问题是由安装引起的,还是由安装后应用的自定义设置引起的。在这一阶段,有两种快速测试 OpenSearch 的方法: + +1. **(启用安全功能)** 使用 tar 归档文件中包含的演示安全脚本应用通用配置。 +1. **(禁用安全功能)** 手动禁用 Security 插件,并在应用你自己的自定义安全设置之前测试实例。 + +演示安全脚本会为你的 OpenSearch 实例应用一套通用配置。该配置定义了一些环境变量,并应用自签名 TLS 证书。如果你想自行配置这些内容,请参阅[步骤 4:在你的环境中设置 OpenSearch](#step-4-set-up-opensearch-in-your-environment)。 + +如果你只想验证服务是否配置正确,并打算自行配置安全设置,则可以禁用 Security 插件,在不加密、不进行身份验证的情况下启动服务。 + +::: danger 警告 +由演示安全脚本配置的 OpenSearch 节点(Node)不适用于生产环境。如果你计划在运行 `opensearch-tar-install.sh` 之后将该节点用于生产环境,至少应将演示 TLS 证书替换为你自己的 TLS 证书,并[更新内部用户和密码列表](/security/configuration/yaml)。请参阅[安全配置](/security/configuration/)获取更多指导,确保你的节点按照安全要求进行配置。 +::: + +### 方式 1:在启用安全功能的情况下测试 OpenSearch 设置 + +1. 切换到 OpenSearch 安装的顶层目录。 + ```bash + cd /path/to/opensearch-2.12.0 + ``` + +1. 使用安全演示配置运行 OpenSearch 启动脚本。 + ```bash + ./opensearch-tar-install.sh + ``` + + 对于 OpenSearch 2.12 或更高版本,请在安装之前使用以下命令设置新的自定义管理员密码: + ```bash + $ export OPENSEARCH_INITIAL_ADMIN_PASSWORD= + ``` + +1. 打开另一个终端会话,向服务器发送请求,验证 OpenSearch 是否正在运行。注意这里使用了 `--insecure` 标志,这是因为 TLS 证书是自签名的。 + - 向 9200 端口发送请求: + ```bash + curl -X GET https://localhost:9200 -u 'admin:' --insecure + ``` + + 你应该会得到类似如下的响应: + ```bash + { + "name" : "hostname", + "cluster_name" : "opensearch", + "cluster_uuid" : "6XNc9m2gTUSIoKDqJit0PA", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` + - 查询插件端点: + ```bash + curl -X GET https://localhost:9200/_cat/plugins?v -u 'admin:' --insecure + ``` + + 响应应类似如下: + ```bash + name component version + hostname opensearch-alerting 2.12.0 + hostname opensearch-anomaly-detection 2.12.0 + hostname opensearch-asynchronous-search 2.12.0 + hostname opensearch-cross-cluster-replication 2.12.0 + hostname opensearch-index-management 2.12.0 + hostname opensearch-job-scheduler 2.12.0 + hostname opensearch-knn 2.12.0 + hostname opensearch-ml 2.12.0 + hostname opensearch-notifications 2.12.0 + hostname opensearch-notifications-core 2.12.0 + hostname opensearch-observability 2.12.0 + hostname opensearch-performance-analyzer 2.12.0 + hostname opensearch-reports-scheduler 2.12.0 + hostname opensearch-security 2.12.0 + hostname opensearch-sql 2.12.0 + ``` +1. 返回最初的终端会话,按 `CTRL + C` 停止该进程。 + +### 方式 2:在禁用安全功能的情况下测试 OpenSearch 设置 + +1. 打开配置文件。 + ```bash + vi /path/to/opensearch-2.12.0/config/opensearch.yml + ``` + +1. 添加以下内容以禁用 Security 插件: + ```bash + plugins.security.disabled: true + ``` + +1. 保存更改并关闭文件。 +1. 打开另一个终端会话,向服务器发送请求,验证 OpenSearch 是否正在运行。由于 Security 插件已被禁用,你将使用 `HTTP` 而不是 `HTTPS` 发送命令。 + - 向 9200 端口发送请求。 + ```bash + curl -X GET http://localhost:9200 + ``` + + 你应该会得到类似如下的响应: + ```bash + { + "name" : "hostname", + "cluster_name" : "opensearch", + "cluster_uuid" : "6XNc9m2gTUSIoKDqJit0PA", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` + - 查询插件端点。 + ```bash + curl -X GET http://localhost:9200/_cat/plugins?v + ``` + + 响应应类似如下: + ```bash + name component version + hostname opensearch-alerting 2.12.0 + hostname opensearch-anomaly-detection 2.12.0 + hostname opensearch-asynchronous-search 2.12.0 + hostname opensearch-cross-cluster-replication 2.12.0 + hostname opensearch-index-management 2.12.0 + hostname opensearch-job-scheduler 2.12.0 + hostname opensearch-knn 2.12.0 + hostname opensearch-ml 2.12.0 + hostname opensearch-notifications 2.12.0 + hostname opensearch-notifications-core 2.12.0 + hostname opensearch-observability 2.12.0 + hostname opensearch-performance-analyzer 2.12.0 + hostname opensearch-reports-scheduler 2.12.0 + hostname opensearch-security 2.12.0 + hostname opensearch-sql 2.12.0 + ``` + +## 步骤 4:在你的环境中设置 OpenSearch + +没有 OpenSearch 使用经验的用户可能需要一份推荐设置清单,以便开始使用该服务。默认情况下,OpenSearch 不绑定到网络接口,外部主机无法访问。此外,安全设置要么未定义(全新安装),要么在你通过调用 `opensearch-tar-install.sh` 运行了安全演示脚本后填充为默认用户名和密码。以下建议将帮助你把 OpenSearch 绑定到网络接口、创建并签发 TLS 证书,以及配置基本身份验证。 + +以下推荐设置可以帮助你: + +- 将 OpenSearch 绑定到主机上的某个 IP 或网络接口。 +- 设置 JVM 堆的初始大小和最大大小。 +- 定义一个指向捆绑 JDK 的环境变量。 +- 配置你自己的 TLS 证书——无需第三方证书颁发机构(CA)。 +- 创建一个使用自定义密码的管理员用户。 + +::: info 注意 +如果你运行过安全演示脚本,则需要手动重新配置被修改过的设置。在继续操作之前,请参阅[安全配置](/install-and-configure/configuring-opensearch/)获取指导。 +::: + +::: tip 提示 +在修改任何配置文件之前,最好先保存一份备份。备份文件可用于撤销错误配置引起的问题。 +::: + +1. 打开 `opensearch.yml`。 + ```bash + vi /path/to/opensearch-2.12.0/config/opensearch.yml + ``` + +1. 添加以下内容。 + ```bash + # 将 OpenSearch 绑定到正确的网络接口。使用 0.0.0.0 + # 表示包含所有可用接口,也可以指定分配给 + # 特定接口的 IP 地址。 + network.host: 0.0.0.0 + + # 除非你已经配置了集群,否则应将 discovery.type + # 设置为 single-node,不然启动服务时 + # 引导检查(bootstrap check)会失败。 + discovery.type: single-node + + # 如果你之前在 opensearch.yml 中禁用了 Security 插件, + # 请务必重新启用它。否则可以跳过此设置。 + plugins.security.disabled: false + ``` + +1. 保存更改并关闭文件。 +1. 指定 JVM 堆的初始大小和最大大小。 + 1. 打开 `jvm.options`。 + ```bash + vi /path/to/opensearch-2.12.0/config/jvm.options + ``` + + 1. 修改堆的初始大小和最大大小。一开始,你应将这两个值设置为可用系统内存的一半。对于专用主机,可以根据工作负载的需求适当调大该值。 + - 例如,如果主机有 8 GB 内存,你可以将堆的初始大小和最大大小设置为 4 GB: + ```bash + -Xms4g + -Xmx4g + ``` + + 1. 保存更改并关闭文件。 +1. 指定内置 JDK 的位置。 + ```bash + export OPENSEARCH_JAVA_HOME=/path/to/opensearch-2.12.0/jdk + ``` + +### 配置 TLS + +TLS 证书允许客户端确认主机的身份,并对客户端与主机之间的流量进行加密,从而为集群(Cluster)提供额外的安全保障。更多信息,请参阅 [Security 插件](/security/)文档中的[配置 TLS 证书](/security/configuration/tls)和[生成证书](/security/configuration/generate-certificates)。对于开发环境中的工作,自签名证书通常就足够了。本节将引导你完成生成自己的 TLS 证书并将其应用到 OpenSearch 主机所需的基本步骤。 + +1. 切换到 OpenSearch 的 `config` 目录,证书将存放在这里。 + ```bash + cd /path/to/opensearch-2.12.0/config/ + ``` + +1. 生成根证书。你将使用它来签发其他证书。 + ```bash + # 为根证书创建私钥 + openssl genrsa -out root-ca-key.pem 2048 + + # 使用私钥创建自签名根证书。请务必 + # 替换传给 -subj 的参数,使其与你的主机相符。 + openssl req -new -x509 -sha256 -key root-ca-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=ROOT" -out root-ca.pem -days 730 + ``` +1. 接下来,创建管理员证书。该证书用于获取提升的权限,以执行与 Security 插件相关的管理任务。 + ```bash + # 为管理员证书创建私钥。 + openssl genrsa -out admin-key-temp.pem 2048 + + # 将私钥转换为 PKCS#8 格式。 + openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem + + # 创建 CSR。通用名称(CN)使用 "A" 即可,因为该证书 + # 用于验证提升的访问权限,并不与某个主机绑定。 + openssl req -new -key admin-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=A" -out admin.csr + + # 使用之前创建的根证书和私钥签发管理员证书。 + openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 730 + ``` +1. 为正在配置的节点创建证书。 + ```bash + # 为节点证书创建私钥。 + openssl genrsa -out node1-key-temp.pem 2048 + + # 将私钥转换为 PKCS#8 格式。 + openssl pkcs8 -inform PEM -outform PEM -in node1-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node1-key.pem + + # 创建 CSR,并替换传给 -subj 的参数,使其与你的主机相符。 + # CN 应与该主机的 DNS A 记录一致——不要使用主机名。 + openssl req -new -key node1-key.pem -subj "/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=node1.dns.a-record" -out node1.csr + + # 创建一个扩展文件,为该主机定义 SAN DNS 名称。 + # 该名称应与主机的 DNS A 记录一致。 + echo 'subjectAltName=DNS:node1.dns.a-record' > node1.ext + + # 使用之前创建的根证书和私钥签发节点证书。 + openssl x509 -req -in node1.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node1.pem -days 730 -extfile node1.ext + ``` +1. 删除不再需要的临时文件。 + ```bash + rm *temp.pem *csr *ext + ``` + +1. 按照[生成证书](/security/configuration/generate-certificates#add-distinguished-names-to-opensearchyml)中的说明,将这些证书添加到 `opensearch.yml`。高级用户也可以选择使用脚本追加这些设置: + ```bash + #! /bin/bash + + # 运行此脚本之前,请务必将 /path/to 替换为你的 OpenSearch 目录, + # 并记得将节点可分辨名称中的 CN 替换为真实的 + # DNS A 记录。 + + echo "plugins.security.ssl.transport.pemcert_filepath: /path/to/opensearch-2.12.0/config/node1.pem" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.ssl.transport.pemkey_filepath: /path/to/opensearch-2.12.0/config/node1-key.pem" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.ssl.transport.pemtrustedcas_filepath: /path/to/opensearch-2.12.0/config/root-ca.pem" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.ssl.http.enabled: true" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.ssl.http.pemcert_filepath: /path/to/opensearch-2.12.0/config/node1.pem" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.ssl.http.pemkey_filepath: /path/to/opensearch-2.12.0/config/node1-key.pem" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.ssl.http.pemtrustedcas_filepath: /path/to/opensearch-2.12.0/config/root-ca.pem" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.allow_default_init_securityindex: true" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.authcz.admin_dn:" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo " - 'CN=A,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.nodes_dn:" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo " - 'CN=node1.dns.a-record,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.audit.type: internal_opensearch" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.enable_snapshot_restore_privilege: true" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.check_snapshot_restore_write_privileges: true" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + echo "plugins.security.restapi.roles_enabled: [\"all_access\", \"security_rest_api_access\"]" | sudo tee -a /path/to/opensearch-2.12.0/config/opensearch.yml + ``` + +1. (可选)为自签名根证书添加信任。 + ```bash + # 将根证书复制到正确的目录 + sudo cp /path/to/opensearch-2.12.0/config/root-ca.pem /etc/pki/ca-trust/source/anchors/ + + # 添加信任 + sudo update-ca-trust + ``` + +### 配置用户 + +OpenSearch 可以通过多种方式定义和验证用户。其中一种无需额外后端基础设施的方法是在 `internal_users.yml` 中手动配置用户。有关配置用户的更多信息,请参阅 [YAML 文件](/security/configuration/yaml)。以下步骤说明了如何删除除 `admin` 用户之外的所有演示用户,以及如何使用脚本替换 `admin` 的默认密码。 + +1. 为 Security 插件的脚本添加可执行权限。 + ```bash + chmod 755 /path/to/opensearch-2.12.0/plugins/opensearch-security/tools/*.sh + ``` + +1. 运行 `hash.sh` 生成新密码。 + - 如果未定义 JDK 的路径,该脚本会运行失败。 + ```bash + # 未找到 JDK 时的输出示例…… + $ ./hash.sh + ************************************************************************** + ** This tool will be deprecated in the next major release of OpenSearch ** + ** https://github.com/opensearch-project/security/issues/1755 ** + ************************************************************************** + which: no java in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/user/.local/bin:/home/user/bin) + WARNING: nor OPENSEARCH_JAVA_HOME nor JAVA_HOME is set, will use + ./hash.sh: line 35: java: command not found + ``` + + - 为避免出现问题,请在调用脚本时声明环境变量: + ```bash + OPENSEARCH_JAVA_HOME=/path/to/opensearch-2.12.0/jdk ./hash.sh + ``` + + - 在提示符处输入所需的密码,并记下输出的哈希值。 +1. 打开 `internal_users.yml`。 + ```bash + vi /path/to/opensearch-2.12.0/config/opensearch-security/internal_users.yml + ``` + +1. 删除除 `admin` 之外的所有演示用户,并将哈希值替换为之前步骤中 `hash.sh` 输出的值。该文件应类似以下示例: + ```bash + --- + # 这是内部用户数据库 + # 哈希值为 bcrypt 哈希,可以使用 plugin/tools/hash.sh 生成 + + _meta: + type: "internalusers" + config_version: 2 + + # 在此处定义你的内部用户 + + admin: + hash: "$2y$1EXAMPLEQqwS8TUcoEXAMPLEeZ3lEHvkEXAMPLERqjyh1icEXAMPLE." + reserved: true + backend_roles: + - "admin" + description: "Admin user" + ``` + +### 应用更改 + +现在 TLS 证书已经安装完毕,演示用户也已删除或分配了新密码,最后一步是应用这些配置更改。这最后一个配置步骤需要在主机上运行 OpenSearch 的同时调用 `securityadmin.sh`。 + +1. 启动 OpenSearch。`securityadmin.sh` 只有在 OpenSearch 运行时才能应用更改。 + ```bash + # 切换目录 + cd /path/to/opensearch-2.12.0/bin + + # 在前台运行服务 + ./opensearch + ``` +1. 在主机上另开一个终端会话,并切换到包含 `securityadmin.sh` 的目录。 + ```bash + # 切换到正确的目录 + cd /path/to/opensearch-2.12.0/plugins/opensearch-security/tools + ``` +1. 调用该脚本。有关必须传入的参数的定义,请参阅[使用 securityadmin.sh 应用更改](/security/configuration/security-admin)。 + ```bash + # 如果已在 $PATH 中声明了该环境变量,则可以省略。 + OPENSEARCH_JAVA_HOME=/path/to/opensearch-2.12.0/jdk ./securityadmin.sh -cd /path/to/opensearch-2.12.0/config/opensearch-security/ -cacert /path/to/opensearch-2.12.0/config/root-ca.pem -cert /path/to/opensearch-2.12.0/config/admin.pem -key /path/to/opensearch-2.12.0/config/admin-key.pem -icl -nhnv + ``` +1. 停止并重启正在运行的 OpenSearch 进程,以应用更改。 + +### 验证服务是否正在运行 + +现在,OpenSearch 已在你的主机上运行,并使用了自定义 TLS 证书和用于基本身份验证的安全用户。你可以从另一台主机向 OpenSearch 节点发送 API 请求,以验证外部连通性。 + +在之前的测试中,你将请求发送到了 `localhost`。现在已应用了 TLS 证书,且新证书引用的是主机的实际 DNS 记录,因此发往 `localhost` 的请求将无法通过 CN 检查,证书会被视为无效。你应该将请求发送到生成证书时指定的地址。 + +::: tip 提示 +在发送请求之前,你应该在客户端上添加对根证书的信任。如果不添加信任,则必须使用 `-k` 选项,让 cURL 忽略 CN 和根证书校验。 +::: + +```bash +$ curl https://your.host.address:9200 -u admin:yournewpassword -k +{ + "name" : "hostname-here", + "cluster_name" : "opensearch", + "cluster_uuid" : "efC0ANNMQlGQ5TbhNflVPg", + "version" : { + "distribution" : "opensearch", + "number" : "2.1.0", + "build_type" : "tar", + "build_hash" : "388c80ad94529b1d9aad0a735c4740dce2932a32", + "build_date" : "2022-06-30T21:31:04.823801692Z", + "build_snapshot" : false, + "lucene_version" : "9.2.0", + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" +} +``` + +### 使用 systemd 将 OpenSearch 作为服务运行 + +本节将引导你为 OpenSearch 创建服务并将其注册到 `systemd`。定义服务之后,你就可以使用 `systemctl` 命令启用、启动和停止 OpenSearch 服务。本节中的命令以 OpenSearch 安装在 `/opt/opensearch` 的环境为例,请根据你的安装路径进行相应修改。 + +::: danger 警告 +以下配置仅适用于在非生产环境中进行测试,我们不建议在生产环境中使用。如果你希望在主机上将 OpenSearch 作为由 systemd 管理的服务运行,应使用 [RPM](/install-and-configure/install-opensearch/rpm) 发行包安装 OpenSearch。tarball 安装方式不会定义特定的安装路径、用户、角色(Role)或权限。如果未能妥善保护主机环境,可能会导致意外行为。 +::: + +1. 为 OpenSearch 服务创建用户。 + ```bash + sudo adduser --system --shell /bin/bash -U --no-create-home opensearch + ``` + +1. 将你的用户添加到 `opensearch` 用户组。 + ```bash + sudo usermod -aG opensearch $USER + ``` + +1. 将文件所有者更改为 `opensearch`。如果你的 OpenSearch 文件位于其他目录,请务必修改路径。 + ```bash + sudo chown -R opensearch /opt/opensearch/ + ``` + +1. 创建服务文件并打开进行编辑。 + ```bash + sudo vi /etc/systemd/system/opensearch.service + ``` + +1. 输入以下示例服务配置。如果你的 OpenSearch 文件位于其他目录,请务必修改其中引用的路径。 + ```bash + [Unit] + Description=OpenSearch + Wants=network-online.target + After=network-online.target + + [Service] + Type=forking + RuntimeDirectory=data + + WorkingDirectory=/opt/opensearch + ExecStart=/opt/opensearch/bin/opensearch -d + + User=opensearch + Group=opensearch + StandardOutput=journal + StandardError=inherit + LimitNOFILE=65535 + LimitNPROC=4096 + LimitAS=infinity + LimitFSIZE=infinity + TimeoutStopSec=0 + KillSignal=SIGTERM + KillMode=process + SendSIGKILL=no + SuccessExitStatus=143 + TimeoutStartSec=75 + + [Install] + WantedBy=multi-user.target + ``` + +1. 重新加载 `systemd` 管理器配置。 + ```bash + sudo systemctl daemon-reload + ``` + +1. 启用 OpenSearch 服务。 + ```bash + sudo systemctl enable opensearch.service + ``` + +1. 启动 OpenSearch 服务。 + ```bash + sudo systemctl start opensearch + ``` + +1. 验证服务是否正在运行。 + ```bash + sudo systemctl status opensearch + ``` + +## 相关链接 + +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [为 Tarball 安装配置 Performance Analyzer](/monitoring-your-cluster/pa/#install-performance-analyzer) +- [安装和配置 OpenSearch Dashboards](/install-and-configure/install-dashboards/) +- [OpenSearch 插件安装](/install-and-configure/plugins) +- [关于 Security 插件](/security/) diff --git a/i18n/zh/install-and-configure/install-opensearch/windows.md b/i18n/zh/install-and-configure/install-opensearch/windows.md new file mode 100644 index 00000000..85f1132c --- /dev/null +++ b/i18n/zh/install-and-configure/install-opensearch/windows.md @@ -0,0 +1,251 @@ +--- +title: Windows +--- + +# Windows + +以下各节介绍如何通过 zip 压缩包在 Windows 上安装 OpenSearch。 + +一般来说,通过 zip 压缩包安装 OpenSearch 可以分为以下几个步骤: + +1. **下载并解压 OpenSearch。** +1. **(可选)测试 OpenSearch。** + - 在应用任何自定义配置之前,确认 OpenSearch 能够运行。 + - 可以在不启用任何安全功能(无密码、无证书)的情况下进行测试,也可以使用随附脚本应用的演示安全配置进行测试。 +1. **针对你的环境配置 OpenSearch。** + - 为 OpenSearch 应用基本设置,并开始在你的环境中使用它。 + +Windows 版 OpenSearch 压缩包是一个自包含的目录,其中包含运行 OpenSearch 所需的一切,包括集成的 Java 开发工具包(JDK)。如果你有自己的 Java 安装并设置了 `JAVA_HOME` 环境变量,那么在未设置 `OPENSEARCH_JAVA_HOME` 环境变量时,OpenSearch 会使用该 Java 安装。要了解如何设置 `OPENSEARCH_JAVA_HOME` 环境变量,请参阅[第 3 步:在你的环境中设置 OpenSearch](#step-3-set-up-opensearch-in-your-environment)。 + +## 前提条件 + +确保已安装 zip 解压工具。 + +## 第 1 步:下载并解压 OpenSearch + +按照以下步骤在 Windows 上安装 OpenSearch。 + +1. 下载 [`opensearch-2.12.0-windows-x64.zip`](https://artifacts.opensearch.org/releases/bundle/opensearch/2.12.0/opensearch-2.12.0-windows-x64.zip) 压缩包。 +1. 要解压压缩包内容,请右键单击并选择 **Extract All**(全部解压缩)。 + +## 第 2 步:(可选)测试 OpenSearch + +在进行任何配置之前,你应该先测试 OpenSearch 的安装。否则,以后出现问题时,很难判断问题是由安装引起的,还是由安装后应用的自定义设置引起的。在这一阶段,有两种快速测试 OpenSearch 的方法: + +1. **(启用安全功能)** 使用 Windows 压缩包中附带的批处理脚本应用通用配置。 +1. **(禁用安全功能)** 手动禁用 Security 插件(plugin),在应用自定义安全设置之前测试实例。 + +批处理脚本会为你的 OpenSearch 实例应用通用配置。该配置定义了一些环境变量,并应用自签名 TLS 证书。你也可以选择自行配置这些内容。 + +如果你只想验证服务是否已正确配置,并打算自行配置安全设置,那么可以禁用 Security 插件,在不加密、不认证的情况下启动服务。 + +::: danger 警告 +默认配置(使用演示证书以及使用默认密码的用户)下的 OpenSearch 节点(Node)不适合用于生产环境。如果你计划在生产环境中使用该节点,至少应将演示 TLS 证书替换为你自己的 TLS 证书,并[更新内部用户和密码列表](/security/configuration/yaml)。有关确保节点按照安全要求进行配置的更多指导,请参阅[安全配置](/security/configuration/)。 +::: + +### 选项 1:在启用安全功能的情况下测试 OpenSearch 设置 + +1. 从命令提示符或 Powershell 运行演示批处理脚本。 + + 1. 在任务栏 **Start**(开始)旁的搜索框中输入 `cmd` 打开命令提示符,或输入 `powershell` 打开 Powershell。 + 1. 切换到 OpenSearch 安装的顶层目录。 + ```bat + cd \path\to\opensearch-2.12.0 + ``` + + 1. 运行批处理脚本。 + 对于 OpenSearch 2.12 或更高版本,使用以下命令指定自定义 admin 密码: + ```bat + > set OPENSEARCH_INITIAL_ADMIN_PASSWORD= + ``` + ```bat + .\opensearch-windows-install.bat + ``` + +1. 打开一个新的命令提示符窗口,向服务器发送请求以验证 OpenSearch 是否正在运行。注意这里使用了 `--insecure` 标志,因为 TLS 证书是自签名的,所以必须使用该标志。 + - 向 9200 端口发送请求: + ```bat + curl.exe -X GET https://localhost:9200 -u "admin:" --insecure + ``` + + 你应该会收到类似如下的响应: + ```bat + { + "name" : "hostname-here", + "cluster_name" : "opensearch", + "cluster_uuid" : "7Nqtr0LrQTOveFcBb7Kufw", + "version" : { + "distribution" : "opensearch", + "number" : , + "build_type" : , + "build_hash" : , + "build_date" : , + "build_snapshot" : false, + "lucene_version" : , + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` + - 查询插件端点: + ```bat + curl.exe -X GET https://localhost:9200/_cat/plugins?v -u "admin:" --insecure + ``` + + 响应应类似如下: + ```bat + hostname opensearch-alerting 2.12.0 + hostname opensearch-anomaly-detection 2.12.0 + hostname opensearch-asynchronous-search 2.12.0 + hostname opensearch-cross-cluster-replication 2.12.0 + hostname opensearch-geospatial 2.12.0 + hostname opensearch-index-management 2.12.0 + hostname opensearch-job-scheduler 2.12.0 + hostname opensearch-knn 2.12.0 + hostname opensearch-ml 2.12.0 + hostname opensearch-neural-search 2.12.0 + hostname opensearch-notifications 2.12.0 + hostname opensearch-notifications-core 2.12.0 + hostname opensearch-observability 2.12.0 + hostname opensearch-reports-scheduler 2.12.0 + hostname opensearch-security 2.12.0 + hostname opensearch-security-analytics 2.12.0 + hostname opensearch-sql 2.12.0 + ``` + +### 选项 2:在禁用安全功能的情况下测试 OpenSearch 设置 + +1. 打开 `opensearch-2.12.0\config` 文件夹。 +1. 使用文本编辑器打开 `opensearch.yml` 文件。 +1. 添加以下行以禁用 Security 插件: + ```yaml + plugins.security.disabled: true + ``` + +1. 保存更改并关闭文件。 +1. 进入 OpenSearch 安装的顶层目录,打开 `opensearch-2.12.0` 文件夹。 +1. 双击 `opensearch-windows-install.bat` 文件以默认方式运行。这会打开一个命令提示符窗口,其中运行着一个 OpenSearch 实例。 +1. 打开一个新的命令提示符窗口,向服务器发送请求以验证 OpenSearch 是否正在运行。由于 Security 插件已被禁用,你将使用 `HTTP` 而不是 `HTTPS` 发送命令。 + - 向 9200 端口发送请求: + ```bat + curl.exe -X GET http://localhost:9200 + ``` + + 你应该会收到类似如下的响应: + ```bat + { + "name" : "hostname-here", + "cluster_name" : "opensearch", + "cluster_uuid" : "7Nqtr0LrQTOveFcBb7Kufw", + "version" : { + "distribution" : "opensearch", + "number" : "2.4.0", + "build_type" : "zip", + "build_hash" : "77ef9e304dd6ee95a600720a387a9735bbcf7bc9", + "build_date" : "2022-11-05T05:50:15.404072800Z", + "build_snapshot" : false, + "lucene_version" : "9.4.1", + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` + - 查询插件端点: + ```bat + curl.exe -X GET http://localhost:9200/_cat/plugins?v + ``` + + 响应应类似如下: + ```bat + hostname opensearch-alerting 2.12.0 + hostname opensearch-anomaly-detection 2.12.0 + hostname opensearch-asynchronous-search 2.12.0 + hostname opensearch-cross-cluster-replication 2.12.0 + hostname opensearch-geospatial 2.12.0 + hostname opensearch-index-management 2.12.0 + hostname opensearch-job-scheduler 2.12.0 + hostname opensearch-knn 2.12.0 + hostname opensearch-ml 2.12.0 + hostname opensearch-neural-search 2.12.0 + hostname opensearch-notifications 2.12.0 + hostname opensearch-notifications-core 2.12.0 + hostname opensearch-observability 2.12.0 + hostname opensearch-reports-scheduler 2.12.0 + hostname opensearch-security 2.12.0 + hostname opensearch-security-analytics 2.12.0 + hostname opensearch-sql 2.12.0 + ``` + +::: tip 提示 +要停止 OpenSearch,请在命令提示符或 Powershell 中按 `Ctrl+C`,或者直接关闭命令提示符或 Powershell 窗口。 +::: + +## 第 3 步:在你的环境中设置 OpenSearch + +没有 OpenSearch 使用经验的用户可能需要一份推荐设置列表来开始使用该服务。默认情况下,OpenSearch 不绑定到任何网络接口,外部主机无法访问。此外,安全设置要么未定义(全新安装),要么在你通过调用 `opensearch-windows-install.bat` 运行了安全演示脚本后,被填充为默认用户名和密码。以下建议可帮助用户将 OpenSearch 绑定到网络接口。 + +以下推荐设置可以让你: + +- 将 OpenSearch 绑定到主机上的某个 IP 或网络接口。 +- 设置 JVM 堆的初始大小和最大大小。 +- 定义一个指向内置 JDK 的环境变量。 + +::: info 注意 +如果你运行过安全演示脚本,则需要手动重新配置被修改过的设置。在继续之前,请参阅[安全配置](/install-and-configure/configuring-opensearch/)获取指导。 +::: + +::: tip 提示 +在修改任何配置文件之前,最好先保存一份备份。备份文件可用于恢复因错误配置导致的问题。 +::: + +1. 打开 `opensearch-2.12.0\config` 文件夹。 +1. 使用文本编辑器打开 `opensearch.yml` 文件。 +1. 添加以下行: + ```bash + # 将 OpenSearch 绑定到正确的网络接口。使用 0.0.0.0 + # 包含所有可用接口,或指定分配给 + # 特定接口的 IP 地址。 + network.host: 0.0.0.0 + + # 除非你已经配置了集群,否则应将 + # discovery.type 设置为 single-node,否则启动服务时 + # 引导检查将会失败。 + discovery.type: single-node + + # 如果你之前在 opensearch.yml 中禁用了 Security 插件, + # 请务必重新启用它。否则可以跳过此设置。 + plugins.security.disabled: false + ``` + +1. 保存更改并关闭文件。 +1. 指定 JVM 堆的初始大小和最大大小。 + 1. 打开 `opensearch-2.12.0\config` 文件夹。 + 1. 使用文本编辑器打开 `jvm.options` 文件。 + 1. 修改堆的初始大小和最大大小的值。作为起点,应将这些值设置为可用系统内存的一半。对于专用主机,可以根据工作负载需求增大该值。
+ 例如,如果宿主机有 8 GB 内存,则可以将堆的初始大小和最大大小设置为 4 GB: + ```bash + -Xms4g + -Xmx4g + ``` + + 1. 保存更改并关闭文件。 +1. 指定内置 JDK 的位置。 + 1. 在任务栏 **Start**(开始)旁的搜索框中输入 `edit environment variables for your account` 或 `edit the system environment variables`。编辑系统环境变量需要管理员权限。用户环境变量优先于系统环境变量。 + 1. 选择 **Edit environment variables for your account**(编辑账户的环境变量)或 **Edit the system environment variables**(编辑系统环境变量)。 + 1. 如果打开了 **System Properties**(系统属性)对话框,请在 **Advanced**(高级)选项卡中选择 **Environment Variables**(环境变量)。 + 1. 在 **User variables**(用户变量)或 **System variables**(系统变量)下,选择 **New**(新建)。 + 1. 在 **Variable name**(变量名)中输入 `OPENSEARCH_JAVA_HOME`。 + 1. 在 **Variable value**(变量值)中输入 `\path\to\opensearch-2.12.0\jdk`。 + 1. 选择 **OK**(确定)关闭所有对话框。 + +## 插件兼容性 + +Performance Analyzer 插件在 Windows 上不可用。所有其他 OpenSearch 插件(包括 k-NN 插件)均可用。有关插件的完整列表,请参阅[可用插件](/install-and-configure/plugins#available-plugins)。 + +## 相关链接 + +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [OpenSearch 插件安装](/install-and-configure/plugins) +- [关于 Security 插件](/security/) diff --git a/i18n/zh/install-and-configure/plugins.md b/i18n/zh/install-and-configure/plugins.md new file mode 100644 index 00000000..6e019566 --- /dev/null +++ b/i18n/zh/install-and-configure/plugins.md @@ -0,0 +1,327 @@ +--- +title: 安装插件 +--- + +# 安装插件 + +你可以根据需要为 OpenSearch 安装单独的插件(plugin)。有关可用插件的信息,请参阅[可用插件](#available-plugins)。 + +::: danger 警告 +为了让插件与 OpenSearch 正常配合工作,所有插件都必须能够访问集群(Cluster)中的数据,包括有关集群操作的元数据。因此,为了保护集群数据并维护其完整性,首先,在 OpenSearch 集群上安装插件之前,务必了解该插件的功能。其次,在选择自定义插件时,务必确保插件来源可靠。 +::: + +## 管理插件 + +OpenSearch 使用名为 `opensearch-plugin` 的命令行工具管理插件。使用该工具,你可以: + +- [列出](#list)已安装的插件。 +- [安装](#install)插件。 +- [删除](#remove)已安装的插件。 + +传入 `-h` 或 `--help` 可打印帮助文本。根据主机配置,你可能还需要以 `sudo` 权限运行该命令。 + +::: info 注意 +如果你在 Docker 容器中运行 OpenSearch,则必须通过修改 Docker 镜像来安装、删除和配置插件。有关信息,请参阅[使用插件](/install-and-configure/install-opensearch/docker#working-with-plugins) +::: + +## 列出插件 + +使用 `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](/api-reference/cat/cat-plugins) 列出已安装的插件。 + +#### 路径和 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` 安装插件有三种方式: + +- [按名称安装插件](#install-a-plugin-by-name)。 +- [从 ZIP 文件安装插件](#install-a-plugin-from-a-zip-file)。 +- [使用 Maven 坐标安装插件](#install-a-plugin-using-maven-coordinates)。 + +### 按名称安装插件: + +有关可按名称安装的插件列表,请参阅[其他插件](#additional-plugins)。 + +#### 用法 {#usage-1} +```bash +bin/opensearch-plugin install +``` + +#### 示例 {#example-1} +```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 文件,请将 `` 替换为托管文件的 URL。该工具仅支持通过 HTTP/HTTPS 协议下载。对于本地 zip 文件,请将 `` 替换为 `file:` 加上插件 zip 文件的绝对路径或相对路径,如下面的第二个示例所示。 + +#### 用法 {#usage-2} +```bash +bin/opensearch-plugin install +``` + +#### 示例 {#example-2} +```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](https://search.maven.org/search?q=org.opensearch.plugin) 上的可用制品和版本。`opensearch-plugin` 会解析你提供的 Maven 坐标并构造 URL。因此,主机必须能够直接连接到 [Maven Central](https://search.maven.org/search?q=org.opensearch.plugin)。如果你将坐标传给代理或本地仓库,插件安装将会失败。 + +#### 用法 {#usage-3} +```bash +bin/opensearch-plugin install :: +``` + +#### 示例 {#example-3} +```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 +``` + +::: info 注意 +安装插件后,请重启 OpenSearch 节点(Node)。 +::: + +### 安装多个插件 + +可以在一次调用中安装多个插件。 + +#### 用法 {#usage-4} +```bash +bin/opensearch-plugin install ... +``` + +#### 示例 {#example-4} +```bash +$ sudo $ ./opensearch-plugin install analysis-nori repository-s3 +``` + +## 删除插件 + +你可以使用 `remove` 选项删除已安装的插件。 + +#### 用法 {#usage-5} +```bash +bin/opensearch-plugin remove +``` + +#### 示例 {#example-5} +```bash +$ sudo $ ./opensearch-plugin remove opensearch-anomaly-detection +-> removing [opensearch-anomaly-detection]... +``` + +::: info 注意 +删除插件后,请重启 OpenSearch 节点。 +::: + +## 批处理模式 + +安装需要默认未包含的额外权限的插件时,插件会提示用户确认所需的权限。要授予所有请求的权限,可以使用批处理模式跳过确认提示。 + +要在安装插件时强制使用批处理模式,请添加 `-b` 或 `--batch` 选项: +```bash +bin/opensearch-plugin install --batch +``` + +## 可用插件 + +::: danger 警告 +插件的主版本号、次版本号和补丁版本号必须与 OpenSearch 的主版本号、次版本号和补丁版本号一致,才能兼容。例如,2.3.0.x 版本的插件只能与 OpenSearch 2.3.0 配合使用。 +::: + +### 内置插件 + +除最小发行包外,所有 OpenSearch 发行版都内置了以下插件。 + +| 插件名称 | 仓库 | 最早可用版本 | +| :--- | :--- | :--- | +| Alerting | [opensearch-alerting](https://github.com/opensearch-project/alerting) | 1.0.0 | +| Anomaly Detection | [opensearch-anomaly-detection](https://github.com/opensearch-project/anomaly-detection) | 1.0.0 | +| Asynchronous Search | [opensearch-asynchronous-search](https://github.com/opensearch-project/asynchronous-search) | 1.0.0 | +| Cross Cluster Replication | [opensearch-cross-cluster-replication](https://github.com/opensearch-project/cross-cluster-replication) | 1.1.0 | +| Custom Codecs | [opensearch-custom-codecs](https://github.com/opensearch-project/custom-codecs) | 2.10.0 | +| Flow Framework | [flow-framework](https://github.com/opensearch-project/flow-framework) | 2.12.0 | +| Notebooks1 | [opensearch-notebooks](https://github.com/opensearch-project/dashboards-notebooks) | 1.0.0 至 1.1.0 | +| Notifications | [notifications](https://github.com/opensearch-project/notifications) | 2.0.0 +| Reports Scheduler | [opensearch-reports-scheduler](https://github.com/opensearch-project/dashboards-reports) | 1.0.0 | +| Geospatial | [opensearch-geospatial](https://github.com/opensearch-project/geospatial) | 2.2.0 | +| Index Management | [opensearch-index-management](https://github.com/opensearch-project/index-management) | 1.0.0 | +| Job Scheduler | [opensearch-job-scheduler](https://github.com/opensearch-project/job-scheduler) | 1.0.0 | +| k-NN | [opensearch-knn](https://github.com/opensearch-project/k-NN) | 1.0.0 | +| ML Commons | [opensearch-ml](https://github.com/opensearch-project/ml-commons) | 1.3.0 | +| Neural Search | [neural-search](https://github.com/opensearch-project/neural-search) | 2.4.0 | +| Observability | [opensearch-observability](https://github.com/opensearch-project/observability) | 1.2.0 | +| Performance Analyzer2 | [opensearch-performance-analyzer](https://github.com/opensearch-project/performance-analyzer) | 1.0.0 | +| Security | [opensearch-security](https://github.com/opensearch-project/security) | 1.0.0 | +| Security Analytics | [opensearch-security-analytics](https://github.com/opensearch-project/security-analytics) | 2.4.0 | +| SQL | [opensearch-sql](https://github.com/opensearch-project/sql) | 1.0.0 | + +*1随着 OpenSearch 1.2.0 的发布,Dashboard Notebooks 已合并到 Observability 插件中。*
+*2Performance Analyzer 在 Windows 上不可用。* + +### 其他插件 + +OpenSearch 社区成员为该服务构建了无数插件。由于许多插件并不在 OpenSearch GitHub 仓库中维护,因此无法列出所有插件的完整列表,但以下插件可以使用 `bin/opensearch-plugin install ` 按名称安装。 + +| 插件名称 | 最早可用版本 | +| :--- | :--- | +| analysis-icu | 1.0.0 | +| analysis-kuromoji | 1.0.0 | +| analysis-nori | 1.0.0 | +| analysis-phonetic | 1.0.0 | +| analysis-smartcn | 1.0.0 | +| analysis-stempel | 1.0.0 | +| analysis-ukrainian | 1.0.0 | +| discovery-azure-classic | 1.0.0 | +| discovery-ec2 | 1.0.0 | +| discovery-gce | 1.0.0 | +| ingest-attachment | 1.0.0 | +| mapper-annotated-text | 1.0.0 | +| mapper-murmur3 | 1.0.0 | +| mapper-size | 1.0.0 | +| query-insights | 2.12.0 | +| repository-azure | 1.0.0 | +| repository-gcs | 1.0.0 | +| repository-hdfs | 1.0.0 | +| repository-s3 | 1.0.0 | +| store-smb | 1.0.0 | +| transport-nio | 1.0.0 | + +## 相关链接 + +- [关于可观测性(Observability)](/observing-your-data/) +- [关于安全分析](/security-analytics/) +- [关于 Security 插件](/security/) +- [告警(Alerting)](/observing-your-data/alerting/) +- [异常检测](/observing-your-data/ad/) +- [异步搜索](/search-plugins/async/) +- [跨集群复制(Cross-cluster Replication)](/tuning-your-cluster/replication-plugin/) +- [索引状态管理(Index State Management,ISM)](/im-plugin/ism/) +- [k-NN](/search-plugins/knn/) +- [ML Commons 插件](/ml-commons-plugin/) +- [神经搜索(Neural Search)](/search-plugins/neural-search) +- [通知](/observing-your-data/notifications/) +- [OpenSearch Dashboards](/dashboards/) +- [Performance Analyzer](/monitoring-your-cluster/pa/) +- [SQL](/search-plugins/sql/) diff --git a/i18n/zh/install-and-configure/upgrade-opensearch/appendix/index.md b/i18n/zh/install-and-configure/upgrade-opensearch/appendix/index.md new file mode 100644 index 00000000..de443c35 --- /dev/null +++ b/i18n/zh/install-and-configure/upgrade-opensearch/appendix/index.md @@ -0,0 +1,16 @@ +--- +title: 升级附录 +--- + +# 升级附录 + +升级附录提供更多辅助文档,例如包含示例 API 请求和配置文件的实验,用于补充相关的流程文档。附录中列出的具体步骤可以有多种用法: + +- OpenSearch 新用户可以借助我们提供的步骤和示例资源,学习如何配置和使用 OpenSearch 及 OpenSearch Dashboards。 +- 管理 OpenSearch 集群的系统管理员可以使用我们提供的示例,先在测试环境中模拟集群维护,再将变更应用到生产工作负载。 + +如果你希望我们补充某个特定主题,请在 GitHub 上 [OpenSearch Project](https://github.com/opensearch-project) 的 issue [#2830](https://github.com/opensearch-project/documentation-website/issues/2830) 下留言。 + +::: info 注意 +本附录中的具体命令只是与 OpenSearch API 及底层主机交互的示例,用于演示相关升级流程文档中描述的步骤。其目的并非给出严格的规定,而是为刚接触 OpenSearch、希望看到实际示例的用户提供更多背景信息。 +::: diff --git a/i18n/zh/install-and-configure/upgrade-opensearch/appendix/rolling-upgrade-lab.md b/i18n/zh/install-and-configure/upgrade-opensearch/appendix/rolling-upgrade-lab.md new file mode 100644 index 00000000..55d777eb --- /dev/null +++ b/i18n/zh/install-and-configure/upgrade-opensearch/appendix/rolling-upgrade-lab.md @@ -0,0 +1,867 @@ +--- +title: 滚动升级实验 +--- + + + + + +# 滚动升级实验 + +你可以在自己的兼容主机上按照以下步骤 操作,重建 OpenSearch Project 在测试[滚动升级](/install-and-configure/upgrade-opensearch/rolling-upgrade)时所用的集群状态。如果你想在开发环境中测试升级流程,这个练习会很有帮助。 + +本实验中的步骤在一台任意选择的 [Amazon Elastic Compute Cloud (Amazon EC2)](https://aws.amazon.com/ec2/) `t2.large` 实例上验证过,该实例使用 [Amazon Linux 2](https://aws.amazon.com/amazon-linux-2/) 内核版本 `Linux 5.10.162-141.675.amzn2.x86_64` 和 [Docker](https://www.docker.com/) 版本 `20.10.17, build 100c701`。该实例挂载了一个 20 GiB 的 gp2 [Amazon EBS](https://aws.amazon.com/ebs/) 根卷。这些规格仅供参考,并不代表 OpenSearch 或 OpenSearch Dashboards 的硬件要求。 + +为了让说明更具可移植性,本流程中对主机上 `$HOME` 路径的引用均以波浪号("~")表示。如果你更想指定绝对路径,请修改 `upgrade-demo-cluster.sh` 中定义的卷路径以及本文档相关命令中使用的卷路径,使其符合你的环境。 + +## 设置环境 + +按照本文档的步骤操作时,你将使用我们提供的脚本定义多个 Docker 资源,包括容器、卷和一个专用的 Docker 网络。如果想重新开始,可以使用以下命令清理环境: + +```bash +docker container stop $(docker container ls -aqf name=os-); \ + docker container rm $(docker container ls -aqf name=os-); \ + docker volume rm -f $(docker volume ls -q | egrep 'data-0|repo-0'); \ + docker network rm opensearch-dev-net +``` + +::: danger 警告 +该命令会删除名称匹配正则表达式 `os-*` 的容器、匹配 `data-0*` 和 `repo-0*` 的数据卷,以及名为 `opensearch-dev-net` 的 Docker 网络。如果你的主机上还运行着其他 Docker 资源,请检查并修改该命令,以免意外删除其他资源。该命令不会撤销主机配置的更改,例如内存交换行为。 +::: + +选好主机后,就可以开始实验了: + +1. 根据你的 Linux 发行版和系统架构,安装相应版本的 [Docker Engine](https://docs.docker.com/engine/install/)。 +1. 在主机上配置[重要的系统设置](/install-and-configure/install-opensearch/#important-settings): + 1. 在主机上禁用内存分页和交换以提升性能: + ```bash + sudo swapoff -a + ``` + 1. 增加 OpenSearch 可用的内存映射数量。打开 `sysctl` 配置文件进行编辑。此示例命令使用 [vim](https://www.vim.org/) 文本编辑器,你也可以使用任何可用的文本编辑器: + ```bash + sudo vim /etc/sysctl.conf + ``` + 1. 在 `/etc/sysctl.conf` 中添加以下行: + ```bash + vm.max_map_count=262144 + ``` + 1. 保存并退出。如果使用 `vi` 或 `vim` 文本编辑器,可以切换到命令模式,输入 `:wq!` 或 `ZZ` 保存并退出。 + 1. 应用配置更改: + ```bash + sudo sysctl -p + ``` +1. 在主目录中创建一个名为 `deploy` 的新目录,然后进入该目录。部署脚本、配置文件和 TLS 证书的路径都将使用 `~/deploy`: + ```bash + mkdir ~/deploy && cd ~/deploy + ``` +1. 从 OpenSearch Project 的 [documentation-website](https://github.com/opensearch-project/documentation-website) 仓库下载 `upgrade-demo-cluster.sh`: + ```bash + wget https://raw.githubusercontent.com/opensearch-project/documentation-website/main/assets/examples/upgrade-demo-cluster.sh + ``` +1. 不做任何修改直接运行该脚本,以部署四个运行 OpenSearch 的容器和一个运行 OpenSearch Dashboards 的容器,并使用自定义的自签名 TLS 证书和一组预定义的内部用户: + ```bash + sh upgrade-demo-cluster.sh + ``` +1. 确认容器已成功启动: + ```bash + docker container ls + ``` +

示例响应

+ + ```bash + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + 6e5218c8397d opensearchproject/opensearch-dashboards:1.3.7 "./opensearch-dashbo…" 24 seconds ago Up 22 seconds 0.0.0.0:5601->5601/tcp, :::5601->5601/tcp os-dashboards-01 + cb5188308b21 opensearchproject/opensearch:1.3.7 "./opensearch-docker…" 25 seconds ago Up 24 seconds 9300/tcp, 9650/tcp, 0.0.0.0:9204->9200/tcp, :::9204->9200/tcp, 0.0.0.0:9604->9600/tcp, :::9604->9600/tcp os-node-04 + 71b682aa6671 opensearchproject/opensearch:1.3.7 "./opensearch-docker…" 26 seconds ago Up 25 seconds 9300/tcp, 9650/tcp, 0.0.0.0:9203->9200/tcp, :::9203->9200/tcp, 0.0.0.0:9603->9600/tcp, :::9603->9600/tcp os-node-03 + f894054a9378 opensearchproject/opensearch:1.3.7 "./opensearch-docker…" 27 seconds ago Up 26 seconds 9300/tcp, 9650/tcp, 0.0.0.0:9202->9200/tcp, :::9202->9200/tcp, 0.0.0.0:9602->9600/tcp, :::9602->9600/tcp os-node-02 + 2e9c91c959cd opensearchproject/opensearch:1.3.7 "./opensearch-docker…" 28 seconds ago Up 27 seconds 9300/tcp, 9650/tcp, 0.0.0.0:9201->9200/tcp, :::9201->9200/tcp, 0.0.0.0:9601->9600/tcp, :::9601->9600/tcp os-node-01 + ``` +1. OpenSearch 初始化集群所需的时间取决于底层主机的性能。你可以跟踪容器日志,查看 OpenSearch 在引导过程中的操作: + 1. 输入以下命令,在终端窗口中显示容器 `os-node-01` 的日志: + ```bash + docker logs -f os-node-01 + ``` + 1. 节点就绪时,你会看到类似以下示例的日志条目: +

示例

+ + ``` + [INFO ][o.o.s.c.ConfigurationRepository] [os-node-01] Node 'os-node-01' initialized + ``` + 1. 按 `Ctrl+C` 停止跟踪容器日志,返回命令提示符。 +1. 使用 cURL 查询 OpenSearch REST API。在以下命令中,请求被发送到主机端口 `9201` 以查询 `os-node-01`,该端口映射到容器的 `9200` 端口: + ```bash + curl -s "https://localhost:9201" -ku admin: + ``` +

示例响应

+ + ```json + { + "name" : "os-node-01", + "cluster_name" : "opensearch-dev-cluster", + "cluster_uuid" : "g1MMknuDRuuD9IaaNt56KA", + "version" : { + "distribution" : "opensearch", + "number" : "1.3.7", + "build_type" : "tar", + "build_hash" : "db18a0d5a08b669fb900c00d81462e221f4438ee", + "build_date" : "2022-12-07T22:59:20.186520Z", + "build_snapshot" : false, + "lucene_version" : "8.10.1", + "minimum_wire_compatibility_version" : "6.8.0", + "minimum_index_compatibility_version" : "6.0.0-beta1" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` + +::: tip 提示 +**提示**:在 `curl` 中使用 `-s` 选项可以隐藏进度条和错误消息。 +::: + +## 添加数据并配置 OpenSearch Security + +OpenSearch 集群现已运行,接下来添加数据并配置一些 OpenSearch Security 设置。版本升级完成后,会再次验证你添加的数据和配置的设置。 + +本节分为两部分: +- [使用 REST API 索引数据](#indexing-data-with-the-rest-api) +- [使用 OpenSearch Dashboards 添加数据](#adding-data-using-opensearch-dashboards) + +### 使用 REST API 索引数据 + +1. 下载示例字段映射文件: + ```bash + wget https://raw.githubusercontent.com/opensearch-project/documentation-website/main/assets/examples/ecommerce-field_mappings.json + ``` +1. 接下来,下载要摄取到该索引中的批量数据: + ```bash + wget https://raw.githubusercontent.com/opensearch-project/documentation-website/main/assets/examples/ecommerce.json + ``` +1. 使用 [Create index](/api-reference/index-apis/create-index) API,按照 `ecommerce-field_mappings.json` 中定义的映射创建索引: + ```bash + curl -H "Content-Type: application/x-ndjson" \ + -X PUT "https://localhost:9201/ecommerce?pretty" \ + --data-binary "@ecommerce-field_mappings.json" \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "acknowledged" : true, + "shards_acknowledged" : true, + "index" : "ecommerce" + } + ``` +1. 使用 [Bulk](/api-reference/document-apis/bulk) API 将 `ecommerce.json` 中的数据添加到新的 ecommerce 索引: + ```bash + curl -H "Content-Type: application/x-ndjson" \ + -X PUT "https://localhost:9201/ecommerce/_bulk?pretty" \ + --data-binary "@ecommerce.json" \ + -ku admin: + ``` +

示例响应(已截断)

+ + ```json + { + "took" : 3323, + "errors" : false, + "items" : [ + ... + "index" : { + "_index" : "ecommerce", + "_type" : "_doc", + "_id" : "4674", + "_version" : 1, + "result" : "created", + "_shards" : { + "total" : 2, + "successful" : 2, + "failed" : 0 + }, + "_seq_no" : 4674, + "_primary_term" : 1, + "status" : 201 + } + ] + } + ``` +1.

也可以通过搜索查询确认数据已成功索引。以下查询返回关键字 `customer_first_name` 等于 `Sonya` 的文档数量:

+ + ```bash + curl -H 'Content-Type: application/json' \ + -X GET "https://localhost:9201/ecommerce/_search?pretty=true&filter_path=hits.total" \ + -d'{"query":{"match":{"customer_first_name":"Sonya"}}}' \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "hits" : { + "total" : { + "value" : 106, + "relation" : "eq" + } + } + } + ``` + +### 使用 OpenSearch Dashboards 添加数据 + +1. 打开 Web 浏览器,访问 Docker 主机的 `5601` 端口(例如 https://HOST_ADDRESS:5601)。如果 OpenSearch Dashboards 正在运行,且你的浏览器客户端能够通过网络访问该主机,就会被重定向到登录页面。 + 1. 如果 Web 浏览器因 TLS 证书为自签名证书而报错,你可能需要在浏览器中绕过证书检查。有关如何绕过证书检查,请参阅浏览器的文档。每个证书的通用名称(Common Name,CN)都是根据用于集群内部通信的容器名和节点名生成的,因此从浏览器连接主机时仍会出现「invalid CN」警告。 +1. 输入默认用户名(`admin`)和密码(`admin`)。 +1. 在 OpenSearch Dashboards 的 **Home** 页面上,选择 **Add sample data**。 +1. 在 **Sample web logs** 下,选择 **Add data**。 + 1. **可选**:选择 **View data** 查看 **[Logs] Web Traffic** 仪表板。 +1. 选择 **Menu button** 打开 **Navigation pane**,然后转到 **Security > Internal users**。 +1. 选择 **Create internal user**。 +1. 填写 **Username** 和 **Password**。 +1. 在 **Backend role** 字段中输入 `admin`。 +1. 选择 **Create**。 + +## 备份重要文件 + +在对集群进行更改之前,务必先创建备份,尤其是当集群运行在生产环境中时。 + +在本节中,你将: +- [注册快照仓库](#registering-a-snapshot-repository)。 +- [创建快照](#creating-a-snapshot)。 +- [备份安全设置](#backing-up-security-settings)。 + +### 注册快照仓库 + +1. 使用 `upgrade-demo-cluster.sh` 映射的卷注册一个仓库: + ```bash + curl -H 'Content-Type: application/json' \ + -X PUT "https://localhost:9201/_snapshot/snapshot-repo?pretty" \ + -d '{"type":"fs","settings":{"location":"/usr/share/opensearch/snapshots"}}' \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "acknowledged" : true + } + ``` +1. **可选**:执行额外检查,验证仓库是否创建成功: + ```bash + curl -H 'Content-Type: application/json' \ + -X POST "https://localhost:9201/_snapshot/snapshot-repo/_verify?timeout=0s&master_timeout=50s&pretty" \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "nodes" : { + "UODBXfAlRnueJ67grDxqgw" : { + "name" : "os-node-03" + }, + "14I_OyBQQXio8nmk0xsVcQ" : { + "name" : "os-node-04" + }, + "tQp3knPRRUqHvFNKpuD2vQ" : { + "name" : "os-node-02" + }, + "rPe8D6ssRgO5twIP00wbCQ" : { + "name" : "os-node-01" + } + } + } + ``` + +### 创建快照 + +快照(Snapshot)是集群索引和状态的备份。有关更多信息,请参阅[快照](/tuning-your-cluster/availability-and-recovery/snapshots/)。 + +1. 创建一个包含所有索引和集群状态的快照: + ```bash + curl -H 'Content-Type: application/json' \ + -X PUT "https://localhost:9201/_snapshot/snapshot-repo/cluster-snapshot-v137?wait_for_completion=true&pretty" \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "snapshot" : { + "snapshot" : "cluster-snapshot-v137", + "uuid" : "-IYB8QNPShGOTnTtMjBjNg", + "version_id" : 135248527, + "version" : "1.3.7", + "indices" : [ + "opensearch_dashboards_sample_data_logs", + ".opendistro_security", + "security-auditlog-2023.02.27", + ".kibana_1", + ".kibana_92668751_admin_1", + "ecommerce", + "security-auditlog-2023.03.06", + "security-auditlog-2023.02.28", + "security-auditlog-2023.03.07" + ], + "data_streams" : [ ], + "include_global_state" : true, + "state" : "SUCCESS", + "start_time" : "2023-03-07T18:33:00.656Z", + "start_time_in_millis" : 1678213980656, + "end_time" : "2023-03-07T18:33:01.471Z", + "end_time_in_millis" : 1678213981471, + "duration_in_millis" : 815, + "failures" : [ ], + "shards" : { + "total" : 9, + "failed" : 0, + "successful" : 9 + } + } + } + ``` + +### 备份安全设置 + +集群管理员可以通过以下任一方式修改 OpenSearch Security 设置: + +- 修改 YAML 文件并运行 `securityadmin.sh` +- 使用 admin 证书发送 REST API 请求 +- 通过 OpenSearch Dashboards 进行更改 + +无论选择哪种方式,OpenSearch Security 都会将配置写入一个名为 `.opendistro_security` 的特殊系统索引。该系统索引在升级过程中会被保留,同时也保存在你创建的快照中。不过,恢复系统索引需要 `admin` 证书授予的高级访问权限。有关更多信息,请参阅[系统索引](/security/configuration/system-indices)和[配置 TLS 证书](/security/configuration/tls)。 + +你还可以在任意 OpenSearch 节点上运行带有 `-backup` 选项的 `securityadmin.sh`,将 OpenSearch Security 设置导出为 YAML 文件。这些 YAML 文件可用于使用现有配置重新初始化 `.opendistro_security` 索引。以下步骤将指导你生成这些备份文件,并将其复制到主机上存储: + +1. 与 `os-node-01` 打开一个交互式伪终端(pseudo-TTY)会话: + ```bash + docker exec -it os-node-01 bash + ``` +1. 创建一个名为 `backups` 的目录并进入该目录: + ```bash + mkdir /usr/share/opensearch/backups && cd /usr/share/opensearch/backups + ``` +1. 使用 `securityadmin.sh` 在 `/usr/share/opensearch/backups/` 中创建 OpenSearch Security 设置的备份: + ```bash + /usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh \ + -backup /usr/share/opensearch/backups \ + -icl \ + -nhnv \ + -cacert /usr/share/opensearch/config/root-ca.pem \ + -cert /usr/share/opensearch/config/admin.pem \ + -key /usr/share/opensearch/config/admin-key.pem + ``` +

示例响应

+ + ```bash + Security Admin v7 + Will connect to localhost:9300 ... done + Connected as CN=A,OU=DOCS,O=OPENSEARCH,L=PORTLAND,ST=OREGON,C=US + OpenSearch Version: 1.3.7 + OpenSearch Security Version: 1.3.7.0 + Contacting opensearch cluster 'opensearch' and wait for YELLOW clusterstate ... + Clustername: opensearch-dev-cluster + Clusterstate: GREEN + Number of nodes: 4 + Number of data nodes: 4 + .opendistro_security index already exists, so we do not need to create one. + Will retrieve '/config' into /usr/share/opensearch/backups/config.yml + SUCC: Configuration for 'config' stored in /usr/share/opensearch/backups/config.yml + Will retrieve '/roles' into /usr/share/opensearch/backups/roles.yml + SUCC: Configuration for 'roles' stored in /usr/share/opensearch/backups/roles.yml + Will retrieve '/rolesmapping' into /usr/share/opensearch/backups/roles_mapping.yml + SUCC: Configuration for 'rolesmapping' stored in /usr/share/opensearch/backups/roles_mapping.yml + Will retrieve '/internalusers' into /usr/share/opensearch/backups/internal_users.yml + SUCC: Configuration for 'internalusers' stored in /usr/share/opensearch/backups/internal_users.yml + Will retrieve '/actiongroups' into /usr/share/opensearch/backups/action_groups.yml + SUCC: Configuration for 'actiongroups' stored in /usr/share/opensearch/backups/action_groups.yml + Will retrieve '/tenants' into /usr/share/opensearch/backups/tenants.yml + SUCC: Configuration for 'tenants' stored in /usr/share/opensearch/backups/tenants.yml + Will retrieve '/nodesdn' into /usr/share/opensearch/backups/nodes_dn.yml + SUCC: Configuration for 'nodesdn' stored in /usr/share/opensearch/backups/nodes_dn.yml + Will retrieve '/whitelist' into /usr/share/opensearch/backups/whitelist.yml + SUCC: Configuration for 'whitelist' stored in /usr/share/opensearch/backups/whitelist.yml + Will retrieve '/audit' into /usr/share/opensearch/backups/audit.yml + SUCC: Configuration for 'audit' stored in /usr/share/opensearch/backups/audit.yml + ``` +1. **可选**:为 TLS 证书创建一个备份目录,并保存证书副本。如果每个节点使用不同的 TLS 证书,请对每个节点重复此操作: + ```bash + mkdir /usr/share/opensearch/backups/certs && cp /usr/share/opensearch/config/*pem /usr/share/opensearch/backups/certs/ + ``` +1. 结束伪终端会话: + ```bash + exit + ``` +1. 将文件复制到主机: + ```bash + docker cp os-node-01:/usr/share/opensearch/backups ~/deploy/ + ``` + +## 执行升级 + +集群已配置完毕,重要的文件和设置也已备份,现在可以开始版本升级了。 + +::: info 注意 +本节中的部分步骤(例如禁用分片复制和刷新事务日志)不会影响集群的性能。将这些步骤列入其中是作为最佳实践:如果客户端在整个升级过程中持续与 OpenSearch 集群交互(例如查询现有数据或索引文档),这些步骤可以显著提升集群性能。 +::: + +1. 禁用分片复制,以停止 Lucene 索引段在集群内的移动: + ```bash + curl -H 'Content-type: application/json' \ + -X PUT "https://localhost:9201/_cluster/settings?pretty" \ + -d'{"persistent":{"cluster.routing.allocation.enable":"primaries"}}' \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "acknowledged" : true, + "persistent" : { + "cluster" : { + "routing" : { + "allocation" : { + "enable" : "primaries" + } + } + } + }, + "transient" : { } + } + ``` +1. 对集群执行 flush 操作,将事务日志条目提交到 Lucene 索引: + ```bash + curl -X POST "https://localhost:9201/_flush?pretty" -ku admin: + ``` +

示例响应

+ + ```json + { + "_shards" : { + "total" : 20, + "successful" : 20, + "failed" : 0 + } + } + ``` +1. 选择一个要升级的节点。由于该演示集群中的所有节点都符合集群管理器条件,因此可以按任意顺序升级节点。以下命令会停止并删除容器 `os-node-01`,但不会删除挂载的数据卷: + ```bash + docker stop os-node-01 && docker container rm os-node-01 + ``` +1. 使用 `opensearchproject/opensearch:2.5.0` 镜像启动一个名为 `os-node-01` 的新容器,并使用与原容器相同的映射卷: + ```bash + docker run -d \ + -p 9201:9200 -p 9601:9600 \ + -e "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" \ + --ulimit nofile=65536:65536 --ulimit memlock=-1:-1 \ + -v data-01:/usr/share/opensearch/data \ + -v repo-01:/usr/share/opensearch/snapshots \ + -v ~/deploy/opensearch-01.yml:/usr/share/opensearch/config/opensearch.yml \ + -v ~/deploy/root-ca.pem:/usr/share/opensearch/config/root-ca.pem \ + -v ~/deploy/admin.pem:/usr/share/opensearch/config/admin.pem \ + -v ~/deploy/admin-key.pem:/usr/share/opensearch/config/admin-key.pem \ + -v ~/deploy/os-node-01.pem:/usr/share/opensearch/config/os-node-01.pem \ + -v ~/deploy/os-node-01-key.pem:/usr/share/opensearch/config/os-node-01-key.pem \ + --network opensearch-dev-net \ + --ip 172.20.0.11 \ + --name os-node-01 \ + opensearchproject/opensearch:2.5.0 + ``` +

示例响应

+ + ```bash + d26d0cb2e1e93e9c01bb00f19307525ef89c3c3e306d75913860e6542f729ea4 + ``` +1. **可选**:查询集群,确定哪个节点正在担任集群管理器。在整个过程中,你可以随时运行此命令,查看何时选举出了新的集群管理器: + ```bash + curl -s "https://localhost:9201/_cat/nodes?v&h=name,version,node.role,master" \ + -ku admin: | column -t + ``` +

示例响应

+ + ```bash + name version node.role master + os-node-01 2.5.0 dimr - + os-node-04 1.3.7 dimr * + os-node-02 1.3.7 dimr - + os-node-03 1.3.7 dimr - + ``` +1. **可选**:查询集群,查看在移除和替换节点时分片分配如何变化。在整个过程中,你可以随时运行此命令,查看分片状态的变化: + ```bash + curl -s "https://localhost:9201/_cat/shards" \ + -ku admin: + ``` +

示例响应

+ + ```bash + security-auditlog-2023.03.06 0 p STARTED 53 214.5kb 172.20.0.13 os-node-03 + security-auditlog-2023.03.06 0 r UNASSIGNED + .kibana_1 0 p STARTED 3 14.5kb 172.20.0.12 os-node-02 + .kibana_1 0 r STARTED 3 14.5kb 172.20.0.13 os-node-03 + ecommerce 0 p STARTED 4675 3.9mb 172.20.0.12 os-node-02 + ecommerce 0 r STARTED 4675 3.9mb 172.20.0.14 os-node-04 + security-auditlog-2023.03.07 0 p STARTED 37 175.7kb 172.20.0.14 os-node-04 + security-auditlog-2023.03.07 0 r UNASSIGNED + .opendistro_security 0 p STARTED 10 67.9kb 172.20.0.12 os-node-02 + .opendistro_security 0 r STARTED 10 67.9kb 172.20.0.13 os-node-03 + .opendistro_security 0 r STARTED 10 64.5kb 172.20.0.14 os-node-04 + .opendistro_security 0 r UNASSIGNED + security-auditlog-2023.02.27 0 p STARTED 4 80.5kb 172.20.0.12 os-node-02 + security-auditlog-2023.02.27 0 r UNASSIGNED + security-auditlog-2023.02.28 0 p STARTED 6 104.1kb 172.20.0.14 os-node-04 + security-auditlog-2023.02.28 0 r UNASSIGNED + opensearch_dashboards_sample_data_logs 0 p STARTED 14074 9.1mb 172.20.0.12 os-node-02 + opensearch_dashboards_sample_data_logs 0 r STARTED 14074 8.9mb 172.20.0.13 os-node-03 + .kibana_92668751_admin_1 0 r STARTED 33 37.3kb 172.20.0.13 os-node-03 + .kibana_92668751_admin_1 0 p STARTED 33 37.3kb 172.20.0.14 os-node-04 + ``` +1. 停止 `os-node-02`: + ```bash + docker stop os-node-02 && docker container rm os-node-02 + ``` +1. 使用 `opensearchproject/opensearch:2.5.0` 镜像启动一个名为 `os-node-02` 的新容器,并使用与原容器相同的映射卷: + ```bash + docker run -d \ + -p 9202:9200 -p 9602:9600 \ + -e "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" \ + --ulimit nofile=65536:65536 --ulimit memlock=-1:-1 \ + -v data-02:/usr/share/opensearch/data \ + -v repo-01:/usr/share/opensearch/snapshots \ + -v ~/deploy/opensearch-02.yml:/usr/share/opensearch/config/opensearch.yml \ + -v ~/deploy/root-ca.pem:/usr/share/opensearch/config/root-ca.pem \ + -v ~/deploy/admin.pem:/usr/share/opensearch/config/admin.pem \ + -v ~/deploy/admin-key.pem:/usr/share/opensearch/config/admin-key.pem \ + -v ~/deploy/os-node-02.pem:/usr/share/opensearch/config/os-node-02.pem \ + -v ~/deploy/os-node-02-key.pem:/usr/share/opensearch/config/os-node-02-key.pem \ + --network opensearch-dev-net \ + --ip 172.20.0.12 \ + --name os-node-02 \ + opensearchproject/opensearch:2.5.0 + ``` +

示例响应

+ + ```bash + 7b802865bd6eb420a106406a54fc388ed8e5e04f6cbd908c2a214ea5ce72ac00 + ``` +1. 停止 `os-node-03`: + ```bash + docker stop os-node-03 && docker container rm os-node-03 + ``` +1. 使用 `opensearchproject/opensearch:2.5.0` 镜像启动一个名为 `os-node-03` 的新容器,并使用与原容器相同的映射卷: + ```bash + docker run -d \ + -p 9203:9200 -p 9603:9600 \ + -e "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" \ + --ulimit nofile=65536:65536 --ulimit memlock=-1:-1 \ + -v data-03:/usr/share/opensearch/data \ + -v repo-01:/usr/share/opensearch/snapshots \ + -v ~/deploy/opensearch-03.yml:/usr/share/opensearch/config/opensearch.yml \ + -v ~/deploy/root-ca.pem:/usr/share/opensearch/config/root-ca.pem \ + -v ~/deploy/admin.pem:/usr/share/opensearch/config/admin.pem \ + -v ~/deploy/admin-key.pem:/usr/share/opensearch/config/admin-key.pem \ + -v ~/deploy/os-node-03.pem:/usr/share/opensearch/config/os-node-03.pem \ + -v ~/deploy/os-node-03-key.pem:/usr/share/opensearch/config/os-node-03-key.pem \ + --network opensearch-dev-net \ + --ip 172.20.0.13 \ + --name os-node-03 \ + opensearchproject/opensearch:2.5.0 + ``` +

示例响应

+ + ```bash + d7f11726841a89eb88ff57a8cbecab392399f661a5205f0c81b60a995fc6c99d + ``` +1. 停止 `os-node-04`: + ```bash + docker stop os-node-04 && docker container rm os-node-04 + ``` +1. 使用 `opensearchproject/opensearch:2.5.0` 镜像启动一个名为 `os-node-04` 的新容器,并使用与原容器相同的映射卷: + ```bash + docker run -d \ + -p 9204:9200 -p 9604:9600 \ + -e "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" \ + --ulimit nofile=65536:65536 --ulimit memlock=-1:-1 \ + -v data-04:/usr/share/opensearch/data \ + -v repo-01:/usr/share/opensearch/snapshots \ + -v ~/deploy/opensearch-04.yml:/usr/share/opensearch/config/opensearch.yml \ + -v ~/deploy/root-ca.pem:/usr/share/opensearch/config/root-ca.pem \ + -v ~/deploy/admin.pem:/usr/share/opensearch/config/admin.pem \ + -v ~/deploy/admin-key.pem:/usr/share/opensearch/config/admin-key.pem \ + -v ~/deploy/os-node-04.pem:/usr/share/opensearch/config/os-node-04.pem \ + -v ~/deploy/os-node-04-key.pem:/usr/share/opensearch/config/os-node-04-key.pem \ + --network opensearch-dev-net \ + --ip 172.20.0.14 \ + --name os-node-04 \ + opensearchproject/opensearch:2.5.0 + ``` +

示例响应

+ + ```bash + 26f8286ab11e6f8dcdf6a83c95f265172f9557578a1b292af84c6f5ef8738e1d + ``` +1. 确认集群正在运行新版本: + ```bash + curl -s "https://localhost:9201/_cat/nodes?v&h=name,version,node.role,master" \ + -ku admin: | column -t + ``` +

示例响应

+ + ```bash + name version node.role master + os-node-01 2.5.0 dimr * + os-node-02 2.5.0 dimr - + os-node-04 2.5.0 dimr - + os-node-03 2.5.0 dimr - + ``` +1. 最后需要升级的组件是 OpenSearch Dashboards 节点。首先,停止并删除旧容器: + ```bash + docker stop os-dashboards-01 && docker rm os-dashboards-01 + ``` +1. 创建一个运行目标版本 OpenSearch Dashboards 的新容器: + ```bash + docker run -d \ + -p 5601:5601 --expose 5601 \ + -v ~/deploy/opensearch_dashboards.yml:/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml \ + -v ~/deploy/root-ca.pem:/usr/share/opensearch-dashboards/config/root-ca.pem \ + -v ~/deploy/os-dashboards-01.pem:/usr/share/opensearch-dashboards/config/os-dashboards-01.pem \ + -v ~/deploy/os-dashboards-01-key.pem:/usr/share/opensearch-dashboards/config/os-dashboards-01-key.pem \ + --network opensearch-dev-net \ + --ip 172.20.0.10 \ + --name os-dashboards-01 \ + opensearchproject/opensearch-dashboards:2.5.0 + ``` +

示例响应

+ + ```bash + 310de7a24cf599ca0b39b241db07fa8865592ebe15b6f5fda26ad19d8e1c1e09 + ``` +1. 确保 OpenSearch Dashboards 容器已正常启动。可以使用类似以下的命令,确认对 https://HOST_ADDRESS:5601 的请求被重定向(HTTP 状态码 302)到 `/app/login?`: + ```bash + curl https://localhost:5601 -kI + ``` +

示例响应

+ + ```bash + HTTP/1.1 302 Found + location: /app/login? + osd-name: opensearch-dashboards-dev + cache-control: private, no-cache, no-store, must-revalidate + set-cookie: security_authentication=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; HttpOnly; Path=/ + content-length: 0 + Date: Wed, 08 Mar 2023 15:36:53 GMT + Connection: keep-alive + Keep-Alive: timeout=120 + ``` +1. 重新启用副本分片的分配: + ```bash + curl -H 'Content-type: application/json' \ + -X PUT "https://localhost:9201/_cluster/settings?pretty" \ + -d'{"persistent":{"cluster.routing.allocation.enable":"all"}}' \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "acknowledged" : true, + "persistent" : { + "cluster" : { + "routing" : { + "allocation" : { + "enable" : "all" + } + } + } + }, + "transient" : { } + } + ``` + +## 验证升级 + +你已经成功部署了一个安全的 OpenSearch 集群,索引了数据,创建了一个填充示例数据的仪表板,创建了一个新的内部用户,备份了重要文件,并将集群从 1.3.7 版本升级到 2.5.0。在继续探索和试用 OpenSearch 及 OpenSearch Dashboards 之前,你应该先验证升级结果。 + +对于此集群,升级后的验证步骤可以包括验证以下内容: + +- [运行版本](#verifying-the-new-running-version) +- [健康状况和分片分配](#verifying-cluster-health-and-shard-allocation) +- [数据一致性](#verifying-data-consistency) + +### 验证新的运行版本 + +1. 验证 OpenSearch 节点当前的运行版本: + ```bash + curl -s "https://localhost:9201/_cat/nodes?v&h=name,version,node.role,master" \ + -ku admin: | column -t + ``` +

示例响应

+ + ```bash + name version node.role master + os-node-01 2.5.0 dimr * + os-node-02 2.5.0 dimr - + os-node-04 2.5.0 dimr - + os-node-03 2.5.0 dimr - + ``` +1. 验证 OpenSearch Dashboards 当前的运行版本: + 1. **方式 1**:通过 Web 界面验证 OpenSearch Dashboards 版本。 + 1. 打开 Web 浏览器,访问 Docker 主机的 `5601` 端口(例如 https://HOST_ADDRESS:5601)。 + 1. 使用默认用户名(`admin`)和默认密码(`admin`)登录。 + 1. 选择右上角的 **Help button**。版本会显示在弹出窗口中。 + 1. 再次选择 **Help button** 关闭弹出窗口。 + 1. **方式 2**:通过检查 `manifest.yml` 验证 OpenSearch Dashboards 版本。 + 1. 在命令行中,与 OpenSearch Dashboards 容器打开一个交互式伪终端会话: + ```bash + docker exec -it os-dashboards-01 bash + ``` + 1. 检查 `manifest.yml` 中的版本: + ```bash + head -n 5 manifest.yml + ``` +

示例响应

+ + ```bash + --- + schema-version: '1.1' + build: + name: OpenSearch Dashboards + version: 2.5.0 + ``` + 1. 结束伪终端会话: + ```bash + exit + ``` + +### 验证集群健康状况和分片分配 + +1. 查询[集群健康](/api-reference/cluster-api/cluster-health) API 端点,查看集群的健康状况信息。你应该会看到 `green` 状态,表示所有主分片和副本分片均已分配: + ```bash + curl -s "https://localhost:9201/_cluster/health?pretty" -ku admin: + ``` +

示例响应

+ + ```json + { + "cluster_name" : "opensearch-dev-cluster", + "status" : "green", + "timed_out" : false, + "number_of_nodes" : 4, + "number_of_data_nodes" : 4, + "discovered_master" : true, + "discovered_cluster_manager" : true, + "active_primary_shards" : 16, + "active_shards" : 36, + "relocating_shards" : 0, + "initializing_shards" : 0, + "unassigned_shards" : 0, + "delayed_unassigned_shards" : 0, + "number_of_pending_tasks" : 0, + "number_of_in_flight_fetch" : 0, + "task_max_waiting_in_queue_millis" : 0, + "active_shards_percent_as_number" : 100.0 + } + ``` +1. 查询 [CAT shards](/api-reference/cat/cat-shards) API 端点,查看集群升级后分片的分配情况: + ```bash + curl -s "https://localhost:9201/_cat/shards" -ku admin: + ``` +

示例响应

+ + ```bash + security-auditlog-2023.02.27 0 r STARTED 4 80.5kb 172.20.0.13 os-node-03 + security-auditlog-2023.02.27 0 p STARTED 4 80.5kb 172.20.0.11 os-node-01 + security-auditlog-2023.03.08 0 p STARTED 30 95.2kb 172.20.0.13 os-node-03 + security-auditlog-2023.03.08 0 r STARTED 30 123.8kb 172.20.0.11 os-node-01 + ecommerce 0 p STARTED 4675 3.9mb 172.20.0.12 os-node-02 + ecommerce 0 r STARTED 4675 3.9mb 172.20.0.13 os-node-03 + .kibana_1 0 p STARTED 3 5.9kb 172.20.0.12 os-node-02 + .kibana_1 0 r STARTED 3 5.9kb 172.20.0.11 os-node-01 + .kibana_92668751_admin_1 0 p STARTED 33 37.3kb 172.20.0.13 os-node-03 + .kibana_92668751_admin_1 0 r STARTED 33 37.3kb 172.20.0.11 os-node-01 + opensearch_dashboards_sample_data_logs 0 p STARTED 14074 9.1mb 172.20.0.12 os-node-02 + opensearch_dashboards_sample_data_logs 0 r STARTED 14074 9.1mb 172.20.0.14 os-node-04 + security-auditlog-2023.02.28 0 p STARTED 6 26.2kb 172.20.0.11 os-node-01 + security-auditlog-2023.02.28 0 r STARTED 6 26.2kb 172.20.0.14 os-node-04 + .opendistro-reports-definitions 0 p STARTED 0 208b 172.20.0.12 os-node-02 + .opendistro-reports-definitions 0 r STARTED 0 208b 172.20.0.13 os-node-03 + .opendistro-reports-definitions 0 r STARTED 0 208b 172.20.0.14 os-node-04 + security-auditlog-2023.03.06 0 r STARTED 53 174.6kb 172.20.0.12 os-node-02 + security-auditlog-2023.03.06 0 p STARTED 53 174.6kb 172.20.0.14 os-node-04 + .kibana_101107607_newuser_1 0 r STARTED 1 5.1kb 172.20.0.13 os-node-03 + .kibana_101107607_newuser_1 0 p STARTED 1 5.1kb 172.20.0.11 os-node-01 + .opendistro_security 0 r STARTED 10 64.5kb 172.20.0.12 os-node-02 + .opendistro_security 0 r STARTED 10 64.5kb 172.20.0.13 os-node-03 + .opendistro_security 0 r STARTED 10 64.5kb 172.20.0.11 os-node-01 + .opendistro_security 0 p STARTED 10 64.5kb 172.20.0.14 os-node-04 + .kibana_-152937574_admintenant_1 0 r STARTED 1 5.1kb 172.20.0.12 os-node-02 + .kibana_-152937574_admintenant_1 0 p STARTED 1 5.1kb 172.20.0.14 os-node-04 + security-auditlog-2023.03.07 0 r STARTED 37 175.7kb 172.20.0.12 os-node-02 + security-auditlog-2023.03.07 0 p STARTED 37 175.7kb 172.20.0.14 os-node-04 + .kibana_92668751_admin_2 0 p STARTED 34 38.6kb 172.20.0.13 os-node-03 + .kibana_92668751_admin_2 0 r STARTED 34 38.6kb 172.20.0.11 os-node-01 + .kibana_2 0 p STARTED 3 6kb 172.20.0.13 os-node-03 + .kibana_2 0 r STARTED 3 6kb 172.20.0.14 os-node-04 + .opendistro-reports-instances 0 r STARTED 0 208b 172.20.0.12 os-node-02 + .opendistro-reports-instances 0 r STARTED 0 208b 172.20.0.11 os-node-01 + .opendistro-reports-instances 0 p STARTED 0 208b 172.20.0.14 os-node-04 + ``` + +### 验证数据一致性 + +你需要再次查询 ecommerce 索引,以确认示例数据仍然存在: + +1. 将此查询的响应与你在[使用 REST API 索引数据](#indexing-data-with-the-rest-api)的[最后一步](#validation)中收到的响应进行比较: + ```bash + curl -H 'Content-Type: application/json' \ + -X GET "https://localhost:9201/ecommerce/_search?pretty=true&filter_path=hits.total" \ + -d'{"query":{"match":{"customer_first_name":"Sonya"}}}' \ + -ku admin: + ``` +

示例响应

+ + ```json + { + "hits" : { + "total" : { + "value" : 106, + "relation" : "eq" + } + } + } + ``` +1. 打开 Web 浏览器,访问 Docker 主机的 `5601` 端口(例如 https://HOST_ADDRESS:5601)。 +1. 输入默认用户名(`admin`)和密码(`admin`)。 +1. 在 OpenSearch Dashboards 的 **Home** 页面上,选择 Web 界面左上角的 **Menu button**,打开 **Navigation pane**。 +1. 选择 **Dashboard**。 +1. 选择 **[Logs] Web Traffic**,打开在前面添加示例数据时创建的仪表板。 +1. 查看完仪表板后,选择 **Profile** 按钮。选择 **Log out**,以便以其他用户身份登录。 +1. 输入升级前创建的用户名和密码,然后选择 **Log in**。 + +## 后续步骤 + +查看以下资源,进一步了解 OpenSearch 的工作原理: + +- [REST API 参考](/api-reference/) +- [OpenSearch Dashboards 快速入门指南](/dashboards/quickstart) +- [关于 OpenSearch 中的安全功能](/security/) diff --git a/i18n/zh/install-and-configure/upgrade-opensearch/index.md b/i18n/zh/install-and-configure/upgrade-opensearch/index.md new file mode 100644 index 00000000..fa0d2283 --- /dev/null +++ b/i18n/zh/install-and-configure/upgrade-opensearch/index.md @@ -0,0 +1,244 @@ +--- +title: 升级 OpenSearch +--- + +# 升级 OpenSearch + +OpenSearch Project 会定期发布更新,其中包含新功能、改进和缺陷修复。OpenSearch 使用[语义化版本(Semantic Versioning)](https://semver.org/),这意味着破坏性变更只会在主版本之间引入。要了解即将推出的功能和修复,请查看 GitHub 上的 [OpenSearch Project Roadmap](https://github.com/orgs/opensearch-project/projects/1)。要查看以往的版本列表,或进一步了解 OpenSearch 如何使用版本号,请参阅[发布计划与维护策略](https://opensearch.isharkfly.com/releases.html)。 + +我们知道用户都希望尽快升级 OpenSearch 以使用最新功能。我们会继续扩充这些升级与迁移文档,覆盖更多主题,例如升级 OpenSearch Dashboards 以及保留自定义配置(例如插件的配置)。如果想了解接下来的计划或希望补充某些内容,请在 GitHub 上 [OpenSearch Project](https://github.com/opensearch-project) 的[升级与迁移文档 meta issue](https://github.com/opensearch-project/documentation-website/issues/2830) 下留言。 + +::: tip 提示 +如果你希望增加某个特定流程,或者想参与贡献,请在 GitHub 上[创建 issue](https://github.com/opensearch-project/documentation-website/issues)。请参阅[贡献者指南](https://github.com/opensearch-project/documentation-website/blob/main/CONTRIBUTING.md)了解如何提供帮助。 +::: + +## 工作流注意事项 + +在对集群做任何变更之前,请花时间规划整个流程。例如,考虑以下问题: + +- 升级过程需要多长时间? +- 如果集群用于生产环境,停机会造成多大影响? +- 你是否具备相应的基础设施,可以先在测试或开发环境中搭建新集群,再将其投入生产?还是需要直接升级生产主机? + +这些问题的答案可以帮助你确定哪种升级路径最适合你的环境。 + +至少,你应该完成以下工作: + +- [查看破坏性变更](#reviewing-breaking-changes)。 +- [查看 OpenSearch 工具兼容性矩阵](#reviewing-the-opensearch-tools-compatibility-matrices)。 +- [查看插件兼容性](#reviewing-plugin-compatibility)。 +- [备份配置文件](#backing-up-configuration-files)。 +- [创建快照](#creating-a-snapshot)。 + +::: tip 提示 +在开始升级之前,停止所有非必要的索引操作,以免在升级期间给集群带来不必要的资源压力。 +::: + +### 查看破坏性变更 + +确定新版本 OpenSearch 如何与你的环境集成非常重要。在开始任何升级步骤之前,请先查看[破坏性变更](/breaking-changes),以确定是否需要调整你的工作流。例如,上游或下游组件可能需要修改,才能与某项 API 变更兼容(参见 meta issue [#2589](https://github.com/opensearch-project/OpenSearch/issues/2589))。 + +### 查看 OpenSearch 工具兼容性矩阵 + +如果你的 OpenSearch 集群与环境中的其他服务(例如 Logstash 或 Beats)交互,请查看 [OpenSearch 工具兼容性矩阵](/tools/#compatibility-matrices),以确定其他组件是否也需要升级。 + +### 查看插件兼容性 + +检查你使用的插件,确认它们与目标版本的 OpenSearch 是否兼容。OpenSearch Project 官方插件可以在 GitHub 上的 [OpenSearch Project](https://github.com/opensearch-project) 仓库中找到。如果你使用了第三方插件,请查阅这些插件的文档,确认它们是否兼容。 + +前往[可用插件](/install-and-configure/plugins#available-plugins)查看参考表,其中列出了 OpenSearch 捆绑插件的版本兼容性。 + +::: warning 重要 +插件的主版本、次版本和补丁版本必须与 OpenSearch 的主版本、次版本和补丁版本一致才能兼容。例如,2.3.0.x 版本的插件只能与 OpenSearch 2.3.0 配合使用。 +::: + +### 备份配置文件 + +在开始升级之前备份所有重要文件,以降低数据丢失的风险。这些文件通常位于以下两个目录之一: + +- `opensearch/config` +- `opensearch-dashboards/config` + +例如 `opensearch.yml`、`opensearch_dashboards.yml`、插件配置文件和 TLS 证书。确定需要备份的文件后,为安全起见,请将它们复制到远程存储中。 + +如果你使用了安全功能,请务必阅读[注意事项](/security/configuration/security-admin#a-word-of-caution),了解如何备份和恢复安全设置。 + +### 创建快照 + +我们建议使用[快照(Snapshot)](/tuning-your-cluster/availability-and-recovery/snapshots/)备份集群状态和索引。如果需要将集群回滚到原始版本,升级前创建的快照可以用作还原点。 + +将快照存储在外部存储上可以进一步降低数据丢失的风险,例如挂载的网络文件系统(Network File System,NFS),或下表中列出的云存储方案。 + +| 快照仓库位置 | 所需的 OpenSearch 插件 | +| :--- | :--- | +| [Amazon Simple Storage Service (Amazon S3)](https://aws.amazon.com/s3/) | [repository-s3](https://github.com/opensearch-project/OpenSearch/tree/2.12.0/plugins/repository-s3) | +| [Google Cloud Storage (GCS)](https://cloud.google.com/storage) | [repository-gcs](https://github.com/opensearch-project/OpenSearch/tree/2.12.0/plugins/repository-gcs) | +| [Apache Hadoop Distributed File System (HDFS)](https://hadoop.apache.org/) | [repository-hdfs](https://github.com/opensearch-project/OpenSearch/tree/2.12.0/plugins/repository-hdfs) | +| [Microsoft Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) | [repository-azure](https://github.com/opensearch-project/OpenSearch/tree/2.12.0/plugins/repository-azure) | + +## 升级方式 + +根据你的需求,选择合适的方式将集群升级到新版本的 OpenSearch: + +- [滚动升级](#rolling-upgrade)在不停止集群的情况下逐个升级节点。 +- [集群重启升级](#cluster-restart-upgrade)在集群停止期间升级服务。 + +跨越多个 OpenSearch 主版本的升级需要重建索引,因此需要额外的工作。有关详细信息,请参阅 [Reindex](/api-reference/document-apis/reindex) API。规划数据迁移时,可参考本指南后面的[索引兼容性参考](#index-compatibility-reference)表。 + +### 滚动升级 + +如果希望集群在整个升级过程中保持可用,滚动升级是很好的选择。在逐个停止、升级和重启节点的同时,数据可以继续被摄取、分析和查询。滚动升级的一种变体称为「节点替换」,其流程与滚动升级完全相同,只是新节点不复用原来的主机和容器。如果你同时要升级底层主机,可以采用节点替换的方式。 + +如果集群管理器运行的 OpenSearch 版本比申请加入集群的节点更新,该节点就无法加入集群。为避免此问题,请最后升级符合集群管理器条件的节点。 + +有关该流程的更多信息,请参阅[滚动升级](/install-and-configure/upgrade-opensearch/rolling-upgrade)。 + +### 集群重启升级 + +OpenSearch 管理员可能出于多种原因选择集群重启升级,例如管理员不希望在运行中的集群上执行维护,或者集群正在迁移到其他环境。 + +滚动升级每次只有一个节点离线,而集群重启升级则要求先停止集群中所有节点上的 OpenSearch 和 OpenSearch Dashboards,然后才能继续。节点停止后,安装新版本的 OpenSearch。然后启动 OpenSearch,集群以新版本完成引导。 + +## 兼容性 + +OpenSearch 节点与同一*主*版本内运行任意其他*次*版本的 OpenSearch 节点兼容。例如,1.1.0 与 1.3.7 兼容,因为它们属于同一个*主*版本(1.x)。此外,OpenSearch 节点和索引向后兼容上一个主版本。例如,这意味着由运行任意 1.x 版本的 OpenSearch 节点创建的索引,可以从快照恢复到运行任意 2.x 版本的 OpenSearch 集群中。 + +::: tip 提示 +OpenSearch 1.x 节点与运行 Elasticsearch 7.x 的节点兼容,但混合版本环境的持续时间不应超出集群升级活动的时间范围。 +::: + +索引的兼容性由创建该索引的 [Apache Lucene](https://lucene.apache.org/) 版本决定。如果索引由运行 1.0.0 版本的 OpenSearch 集群创建,那么任何运行最高至最新 1.x 或 2.x 版本的 OpenSearch 集群都可以使用该索引。有关 OpenSearch 1.0.0 及更高版本以及 [Elasticsearch](https://www.elastic.co/) 6.8 及更高版本所使用的 Lucene 版本,请参阅[索引兼容性参考](#index-compatibility-reference)表。 + +如果你的升级路径跨越多个主版本,并且希望保留现有索引,可以在升级前使用 [Reindex](/api-reference/document-apis/reindex) API 让索引与目标版本的 OpenSearch 兼容。例如,如果集群当前运行的是 Elasticsearch 6.8,而你想升级到 OpenSearch 2.x,则必须先升级到 OpenSearch 1.x,使用 [Reindex](/api-reference/document-apis/reindex) API 重新创建索引,最后再升级到 2.x。除重建索引外,另一种方法是从数据源重新摄取数据,例如重放数据流或从数据库摄取数据。 + +### 索引兼容性参考 + +如果计划在 OpenSearch 版本升级后保留旧索引,你可能需要重建索引或重新摄取数据。下表列出了近期 OpenSearch 和 Elasticsearch 版本所使用的 Lucene 版本。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Lucene 版本OpenSearch 版本Elasticsearch 版本
9.4.22.5.0
2.4.1
8.6
9.4.12.4.0—
9.4.0—8.5
9.3.02.3.0
2.2.x
8.4
9.2.02.1.08.3
9.1.02.0.x8.2
9.0.0—8.1
8.0
8.11.1—7.17
8.10.11.3.x
1.2.x
7.16
8.9.01.1.07.15
7.14
8.8.21.0.07.13
8.8.0—7.12
8.7.0—7.11
7.10
8.6.2—7.9
8.5.1—7.8
7.7
8.4.0—7.6
8.3.0—7.5
8.2.0—7.4
8.1.0—7.3
8.0.0—7.2
7.1
7.7.3—6.8
+

短横线(—)表示没有包含对应 Apache Lucene 版本的产品版本。

diff --git a/i18n/zh/install-and-configure/upgrade-opensearch/rolling-upgrade.md b/i18n/zh/install-and-configure/upgrade-opensearch/rolling-upgrade.md new file mode 100644 index 00000000..d2cf93d5 --- /dev/null +++ b/i18n/zh/install-and-configure/upgrade-opensearch/rolling-upgrade.md @@ -0,0 +1,201 @@ +--- +title: 滚动升级 +--- + +# 滚动升级 + +滚动升级(Rolling Upgrade)有时也称为「节点替换升级」,可以在运行中的集群上执行,几乎不会造成停机。节点会被逐个停止并原地升级。或者,也可以逐个停止节点,并用运行新版本的主机替换它们。在此过程中,你可以继续在集群中索引和查询数据。 + +本文档从较高层面、以与平台无关的方式概述滚动升级流程。有关命令、脚本和配置文件的具体示例,请参阅[附录](/install-and-configure/upgrade-opensearch/appendix/)。 + +## 升级前的准备 + +在对 OpenSearch 集群做任何变更之前,请参阅[升级 OpenSearch](/install-and-configure/upgrade-opensearch/),了解有关备份配置文件以及为集群状态和索引创建快照的建议。 + +::: warning 重要 +**重要:** OpenSearch 节点无法降级。如果需要撤销升级,则必须全新安装 OpenSearch,并从快照恢复集群。请在开始升级之前创建快照,并将其存储在远程仓库中。 +::: + +## 执行升级 + +1. 开始之前,请先检查 OpenSearch 集群的健康状况。升级前应解决所有索引或分片分配问题,以确保数据得到保留。状态为 **green** 表示所有主分片和副本分片均已分配。有关更多信息,请参阅[集群健康](/api-reference/cluster-api/cluster-health)。以下命令查询 `_cluster/health` API 端点: + ```json + GET "/_cluster/health?pretty" + ``` + 响应应类似于以下示例: + ```json + { + "cluster_name":"opensearch-dev-cluster", + "status":"green", + "timed_out":false, + "number_of_nodes":4, + "number_of_data_nodes":4, + "active_primary_shards":1, + "active_shards":4, + "relocating_shards":0, + "initializing_shards":0, + "unassigned_shards":0, + "delayed_unassigned_shards":0, + "number_of_pending_tasks":0, + "number_of_in_flight_fetch":0, + "task_max_waiting_in_queue_millis":0, + "active_shards_percent_as_number":100.0 + } + ``` +1. 禁用分片复制,以免在节点下线时创建分片副本。这会停止 Lucene 索引段在集群节点之间的移动。你可以通过调用 `_cluster/settings` API 端点来禁用分片复制: + ```json + PUT "/_cluster/settings?pretty" + { + "persistent": { + "cluster.routing.allocation.enable": "primaries" + } + } + ``` + 响应应类似于以下示例: + ```json + { + "acknowledged" : true, + "persistent" : { + "cluster" : { + "routing" : { + "allocation" : { + "enable" : "primaries" + } + } + } + }, + "transient" : { } + } + ``` + +1. 对集群执行 flush 操作,将事务日志条目提交到 Lucene 索引: + ```json + POST "/_flush?pretty" + ``` + 响应应类似于以下示例: + ```json + { + "_shards" : { + "total" : 4, + "successful" : 4, + "failed" : 0 + } + } + ``` +1. 检查集群并确定第一个要升级的节点。符合集群管理器条件的节点应最后升级,因为 OpenSearch 节点可以加入管理器节点运行旧版本的集群,但无法加入所有管理器节点都运行新版本的集群。 +1. 查询 `_cat/nodes` 端点,确定哪个节点被选为集群管理器。以下命令包含额外的查询参数,只请求 name、version、node.role 和 master 列。请注意,OpenSearch 1.x 版本使用术语「master」,该术语在 OpenSearch 2.x 及更高版本中已被弃用,并由「cluster_manager」取代。 + ```bash + GET "/_cat/nodes?v&h=name,version,node.role,master" | column -t + ``` + 响应应类似于以下示例: + ```bash + name version node.role master + os-node-01 7.10.2 dimr - + os-node-04 7.10.2 dimr - + os-node-03 7.10.2 dimr - + os-node-02 7.10.2 dimr * + ``` +1. 停止要升级的节点。删除容器时,不要删除与该容器关联的卷。新的 OpenSearch 容器将使用现有的卷。**删除卷会导致数据丢失**。 +1. 查询 `_cat/nodes` API 端点,确认对应节点已从集群中移除: + ```bash + GET "/_cat/nodes?v&h=name,version,node.role,master" | column -t + ``` + 响应应类似于以下示例: + ```bash + name version node.role master + os-node-02 7.10.2 dimr * + os-node-04 7.10.2 dimr - + os-node-03 7.10.2 dimr - + ``` + `os-node-01` 不再列出,因为该容器已被停止并删除。 +1. 部署一个运行目标版本 OpenSearch 的新容器,并将其映射到与已删除容器相同的卷。 +1. 新节点上的 OpenSearch 运行后,查询 `_cat/nodes` 端点,确认它已加入集群: + ```bash + GET "/_cat/nodes?v&h=name,version,node.role,master" | column -t + ``` + 响应应类似于以下示例: + ```bash + name version node.role master + os-node-02 7.10.2 dimr * + os-node-04 7.10.2 dimr - + os-node-01 7.10.2 dimr - + os-node-03 7.10.2 dimr - + ``` + 在示例输出中,新的 OpenSearch 节点向集群报告的运行版本为 `7.10.2`。这是 `compatibility.override_main_response_version` 的作用,该设置用于让会检查版本的旧版客户端连接集群。你可以调用 `/_nodes` API 端点手动确认节点版本,如以下命令所示。将 `` 替换为你的节点名称。有关更多信息,请参阅 [Nodes API](/api-reference/nodes-apis/)。 + ```bash + GET "/_nodes/?pretty=true" | jq -r '.nodes | .[] | "\(.name) v\(.version)"' + ``` + 响应应类似于以下示例: + ```bash + os-node-01 v1.3.7 + ``` +1. 对集群中的每个节点重复第 5 步到第 9 步。请记住最后升级符合集群管理器条件的节点。替换最后一个节点后,查询 `_cat/nodes` 端点,确认所有节点都已加入集群。此时集群已引导到新版本的 OpenSearch。你可以查询 `_cat/nodes` API 端点来验证集群版本: + ```bash + GET "/_cat/nodes?v&h=name,version,node.role,master" | column -t + ``` + 响应应类似于以下示例: + ```bash + name version node.role master + os-node-04 1.3.7 dimr - + os-node-02 1.3.7 dimr * + os-node-01 1.3.7 dimr - + os-node-03 1.3.7 dimr - + ``` +1. 重新启用分片复制: + ```json + PUT "/_cluster/settings?pretty" + { + "persistent": { + "cluster.routing.allocation.enable": "all" + } + } + ``` + 响应应类似于以下示例: + ```json + { + "acknowledged" : true, + "persistent" : { + "cluster" : { + "routing" : { + "allocation" : { + "enable" : "all" + } + } + } + }, + "transient" : { } + } + ``` +1. 确认集群处于健康状态: + ```bash + GET "/_cluster/health?pretty" + ``` + 响应应类似于以下示例: + ```json + { + "cluster_name" : "opensearch-dev-cluster", + "status" : "green", + "timed_out" : false, + "number_of_nodes" : 4, + "number_of_data_nodes" : 4, + "discovered_master" : true, + "active_primary_shards" : 1, + "active_shards" : 4, + "relocating_shards" : 0, + "initializing_shards" : 0, + "unassigned_shards" : 0, + "delayed_unassigned_shards" : 0, + "number_of_pending_tasks" : 0, + "number_of_in_flight_fetch" : 0, + "task_max_waiting_in_queue_millis" : 0, + "active_shards_percent_as_number" : 100.0 + } + ``` +1. 升级现已完成,你可以开始体验最新的功能和修复了! + +### 相关文章 + +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [性能分析器](/monitoring-your-cluster/pa/) +- [安装和配置 OpenSearch Dashboards](/install-and-configure/install-dashboards/) +- [关于 OpenSearch 中的安全功能](/security/) diff --git a/i18n/zh/intro.md b/i18n/zh/intro.md new file mode 100644 index 00000000..db1699c7 --- /dev/null +++ b/i18n/zh/intro.md @@ -0,0 +1,106 @@ +--- +title: OpenSearch 简介 +--- + +# OpenSearch 简介 + +OpenSearch 是一个基于 [Apache Lucene](https://lucene.apache.org/) 的分布式搜索和分析引擎。将数据添加到 OpenSearch 后,你就可以对其执行全文搜索,并使用你所期望的各种功能:按字段搜索、搜索多个索引、提升字段权重、按评分对结果排序、按字段对结果排序以及对结果进行聚合。 + +不出所料,人们经常将 OpenSearch 这样的搜索引擎用作搜索应用程序的后端——想想 [Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:FAQ/Technical#What_software_is_used_to_run_Wikipedia?) 或者在线商店。OpenSearch 性能出色,并且可以随着应用程序需求的增减而扩展或缩减。 + +另一个同样流行但不那么显而易见的用例是日志分析:收集应用程序的日志,将其导入 OpenSearch,然后利用丰富的搜索和可视化功能来发现问题。例如,一台出现故障的 Web 服务器可能有 0.5% 的请求返回 500 错误,除非你有一张实时展示该服务器在过去四小时内返回的所有 HTTP 状态码的图表,否则很难注意到这个问题。你可以使用 [OpenSearch Dashboards](/dashboards/) 基于 OpenSearch 中的数据构建此类可视化。 + +## 集群和节点 + +OpenSearch 采用分布式设计,这意味着你与之交互的是 OpenSearch *集群*(Cluster)。每个集群由一个或多个*节点*(Node)组成,节点是存储数据并处理搜索请求的服务器。 + +你可以在笔记本电脑上本地运行 OpenSearch——它的系统要求非常低——但你也可以将单个集群扩展到数据中心中数百台性能强大的机器。 + +在单节点集群(例如笔记本电脑)中,一台机器必须承担所有工作:管理集群状态、索引和搜索数据,以及在索引之前对数据进行预处理。不过,随着集群规模的扩大,你可以对职责进行划分。拥有高速磁盘和充足内存的节点可能非常适合索引和搜索数据,而拥有强大 CPU 但磁盘很小的节点则可以负责管理集群状态。有关设置节点类型的更多信息,请参阅[集群组建](/tuning-your-cluster/)。 + +## 索引和文档 + +OpenSearch 将数据组织为*索引*(Index)。每个索引是 JSON *文档*(Document)的集合。如果你有一组原始的百科全书文章或日志行想要添加到 OpenSearch,必须先将它们转换为 [JSON](https://www.json.org/)。一部电影的简单 JSON 文档可能如下所示: + +```json +{ + "title": "The Wind Rises", + "release_date": "2013-07-20" +} +``` + +当你将文档添加到索引时,OpenSearch 会添加一些元数据,例如唯一的文档 *ID*: + +```json +{ + "_index": "", + "_type": "_doc", + "_id": "", + "_version": 1, + "_source": { + "title": "The Wind Rises", + "release_date": "2013-07-20" + } +} +``` + +索引还包含映射和设置: + +- *映射*(Mapping)是索引中文档所具有的*字段*(Field)的集合。在本例中,这些字段是 `title` 和 `release_date`。 +- 设置包括索引名称、创建日期和分片数量等数据。 + +## 主分片和副本分片 + +OpenSearch 将索引拆分为*分片*(Shard),以便在集群的各个节点之间均匀分布。例如,一个 400 GB 的索引可能太大,集群中的任何单个节点都无法处理;但如果将其拆分为十个分片,每个分片 40 GB,OpenSearch 就可以将这些分片分布到十个节点上,并单独处理每个分片。 + +默认情况下,OpenSearch 会为每个*主分片*(Primary Shard)创建一个*副本分片*(Replica Shard)。例如,如果你将索引拆分为十个分片,OpenSearch 也会创建十个副本分片。这些副本分片在节点发生故障时充当备份——OpenSearch 会将副本分片分配到与其对应主分片不同的节点上——同时它们还能提高集群处理搜索请求的速度和吞吐率。对于搜索密集型的工作负载,你可以为每个索引指定多个副本。 + +尽管分片只是 OpenSearch 索引的一部分,但每个分片实际上都是一个完整的 Lucene 索引——我们知道这有点令人困惑。不过这个细节很重要,因为每个 Lucene 实例都是一个消耗 CPU 和内存的运行进程。分片并不是越多越好。例如,将一个 400 GB 的索引拆分为 1,000 个分片会给集群带来不必要的压力。一个好的经验法则是将分片大小保持在 10--50 GB 之间。 + +## REST API + +你可以使用 REST API 与 OpenSearch 集群交互,它提供了很大的灵活性。你可以使用 [curl](https://curl.se/) 之类的客户端,或任何能够发送 HTTP 请求的编程语言。要将 JSON 文档添加到 OpenSearch 索引(即索引一个文档),你需要发送一个 HTTP 请求: + +```json +PUT https://://_doc/ +{ + "title": "The Wind Rises", + "release_date": "2013-07-20" +} +``` + +搜索该文档: + +```json +GET https://://_search?q=wind +``` + +删除该文档: + +```json +DELETE https://://_doc/ +``` + +你可以使用 REST API 更改大多数 OpenSearch 设置、修改索引、检查集群健康状况、获取统计信息——几乎可以完成所有操作。 + +## 高级概念 + +以下部分介绍 OpenSearch 中一些更高级的概念。 + +### Translog + +任何索引变更(例如文档的索引或删除)都会在 Lucene 提交(commit)期间写入磁盘。然而,Lucene 提交是开销很大的操作,因此无法在每次索引变更后都执行。取而代之的是,每个分片都会将每个索引操作记录在一个称为 _translog_ 的事务日志中。当文档被索引时,它会被添加到内存缓冲区并记录到 translog 中。进程或主机重启后,内存缓冲区中的所有数据都会丢失。由于 translog 会写入磁盘,将文档记录到 translog 中可以确保持久性。 + +频繁的刷新操作会将内存缓冲区中的文档写入一个段(Segment),然后清空内存缓冲区。[flush](#flush) 会定期执行 Lucene 提交,包括使用 `fsync` 将段写入磁盘、清除旧的 translog 并启动一个新的 translog。因此,translog 包含所有尚未 flush 的操作。 + +### Refresh + +OpenSearch 会定期执行 _refresh_(刷新)操作,将内存中 Lucene 索引的文档写入文件。由于没有执行 `fsync`,这些文件并不能保证持久性。refresh 使文档可以被搜索到。 + +### Flush + +_flush_ 操作使用 `fsync` 将文件持久化到磁盘,从而确保持久性。flush 确保仅存储在 translog 中的数据被记录到 Lucene 索引中。OpenSearch 会根据需要执行 flush,以确保 translog 不会变得过大。 + +### Merge + +在 OpenSearch 中,一个分片就是一个 Lucene 索引,它由_段_(或段文件)组成。段存储已索引的数据,并且是不可变的。较小的段会定期合并为较大的段。合并可以减少每个分片上的段总数、释放磁盘空间并提高搜索性能。最终,段会达到合并策略中指定的最大大小,之后便不再被合并为更大的段。合并策略还指定了合并的执行频率。 diff --git a/i18n/zh/quickstart.md b/i18n/zh/quickstart.md new file mode 100644 index 00000000..cd7a6cc9 --- /dev/null +++ b/i18n/zh/quickstart.md @@ -0,0 +1,161 @@ +--- +title: 快速入门 +--- + +# 快速入门 + +通过 [Docker](https://www.docker.com/) 部署容器,开始使用 OpenSearch 和 OpenSearch Dashboards。在继续之前,你需要在本地机器上[安装 Docker](https://docs.docker.com/get-docker/) 和 [Docker Compose](https://github.com/docker/compose)。 + +::: info 注意 +本指南中使用的 Docker Compose 命令都带有连字符(例如 `docker-compose`)。如果你在机器上安装的是 Docker Desktop(它会自动安装捆绑版本的 Docker Compose),则应去掉连字符。例如,将 `docker-compose` 改为 `docker compose`。 +::: + +## 启动集群 + +你需要一个称为 Compose 文件的特殊文件,Docker Compose 使用它来定义和创建集群中的容器。OpenSearch 项目提供了一个示例 Compose 文件,你可以用它来快速上手。要进一步了解如何使用 Compose 文件,请查阅官方的 [Compose 规范](https://docs.docker.com/compose/compose-file/)。 + +1. 在机器上运行 OpenSearch 之前,你应该在主机上禁用内存分页和交换,以提升性能,并增加 OpenSearch 可用的内存映射数量。有关更多信息,请参阅[重要系统设置](/install-and-configure/install-opensearch/)。 + ```bash + # 禁用内存分页和交换。 + sudo swapoff -a + + # 编辑定义主机最大内存映射数量的 sysctl 配置文件。 + sudo vi /etc/sysctl.conf + + # 将最大内存映射数量设置为推荐值 262144。 + vm.max_map_count=262144 + + # 重新加载内核参数。 + sudo sysctl -p + ``` +1. 将示例 Compose 文件下载到主机。你可以使用 `curl` 和 `wget` 等命令行工具下载该文件,也可以使用 Web 浏览器从 OpenSearch 项目的 documentation-website 仓库中手动复制 [docker-compose.yml](https://github.com/opensearch-project/documentation-website/blob/2.12/assets/examples/docker-compose.yml)。 + ```bash + # 使用 cURL: + curl -O https://raw.githubusercontent.com/opensearch-project/documentation-website/2.12/assets/examples/docker-compose.yml + + # 使用 wget: + wget https://raw.githubusercontent.com/opensearch-project/documentation-website/2.12/assets/examples/docker-compose.yml + ``` +1. 在终端应用程序中,进入刚刚下载的 `docker-compose.yml` 文件所在的目录,然后运行以下命令,以后台进程的方式创建并启动集群。 + ```bash + docker-compose up -d + ``` +1. 使用 `docker-compose ps` 命令确认容器正在运行。你应该会看到类似以下的输出: + ```bash + $ docker-compose ps + NAME COMMAND SERVICE STATUS PORTS + opensearch-dashboards "./opensearch-dashbo…" opensearch-dashboards running 0.0.0.0:5601->5601/tcp + opensearch-node1 "./opensearch-docker…" opensearch-node1 running 0.0.0.0:9200->9200/tcp, 9300/tcp, 0.0.0.0:9600->9600/tcp, 9650/tcp + opensearch-node2 "./opensearch-docker…" opensearch-node2 running 9200/tcp, 9300/tcp, 9600/tcp, 9650/tcp + ``` +1. 查询 OpenSearch REST API,验证服务是否正在运行。由于默认安全配置使用的是演示证书,你应该使用 `-k`(也写作 `--insecure`)来禁用主机名检查。使用 `-u` 传入默认用户名和密码(`admin:`)。 + ```bash + curl https://localhost:9200 -ku admin: + ``` + 示例响应: + ```json + { + "name" : "opensearch-node1", + "cluster_name" : "opensearch-cluster", + "cluster_uuid" : "W0B8gPotTAajhMPbC9D4ww", + "version" : { + "distribution" : "opensearch", + "number" : "2.6.0", + "build_type" : "tar", + "build_hash" : "7203a5af21a8a009aece1474446b437a3c674db6", + "build_date" : "2023-02-24T18:58:37.352296474Z", + "build_snapshot" : false, + "lucene_version" : "9.5.0", + "minimum_wire_compatibility_version" : "7.10.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "The OpenSearch Project: https://opensearch.org/" + } + ``` +1. 在运行 OpenSearch 集群的同一台主机上,使用 Web 浏览器打开 `http://localhost:5601/`,探索 OpenSearch Dashboards。默认用户名是 `admin`,默认密码由 `docker-compose.yml` 文件中的 `OPENSEARCH_INITIAL_ADMIN_PASSWORD=` 设置指定。 + +## 使用示例数据创建索引和字段映射 + +使用 OpenSearch 项目提供的数据集创建索引(Index)并定义字段映射(Mapping)。OpenSearch Dashboards 中的示例可视化也使用了同样的虚构电子商务数据。要了解更多信息,请参阅 [OpenSearch Dashboards 入门](/dashboards/)。 + +1. 下载 [ecommerce-field_mappings.json](https://github.com/opensearch-project/documentation-website/blob/2.12/assets/examples/ecommerce-field_mappings.json)。该文件为你将要使用的示例数据定义了[映射](/field-types/)。 + ```bash + # 使用 cURL: + curl -O https://raw.githubusercontent.com/opensearch-project/documentation-website/2.12/assets/examples/ecommerce-field_mappings.json + + # 使用 wget: + wget https://raw.githubusercontent.com/opensearch-project/documentation-website/2.12/assets/examples/ecommerce-field_mappings.json + ``` +1. 下载 [ecommerce.json](https://github.com/opensearch-project/documentation-website/blob/2.12/assets/examples/ecommerce.json)。该文件包含格式化后的索引数据,可以通过 bulk API 摄取。要了解更多信息,请参阅[索引数据](/im-plugin/)和 [Bulk](/api-reference/document-apis/bulk)。 + ```bash + # 使用 cURL: + curl -O https://raw.githubusercontent.com/opensearch-project/documentation-website/2.12/assets/examples/ecommerce.json + + # 使用 wget: + wget https://raw.githubusercontent.com/opensearch-project/documentation-website/2.12/assets/examples/ecommerce.json + ``` +1. 使用映射文件定义字段映射。 + ```bash + curl -H "Content-Type: application/x-ndjson" -X PUT "https://localhost:9200/ecommerce" -ku admin: --data-binary "@ecommerce-field_mappings.json" + ``` +1. 通过 bulk API 上传索引。 + ```bash + curl -H "Content-Type: application/x-ndjson" -X PUT "https://localhost:9200/ecommerce/_bulk" -ku admin: --data-binary "@ecommerce.json" + ``` +1. 使用搜索 API 查询数据。以下命令提交的查询将返回 `customer_first_name` 为 `Sonya` 的文档。 + ```bash + curl -H 'Content-Type: application/json' -X GET "https://localhost:9200/ecommerce/_search?pretty=true" -ku admin: -d' {"query":{"match":{"customer_first_name":"Sonya"}}}' + ``` + 默认情况下,提交到 OpenSearch REST API 的查询通常会返回未格式化的 JSON。要获得便于阅读的响应体,请使用查询参数 `pretty=true`。有关 `pretty` 和其他实用查询参数的更多信息,请参阅[通用 REST 参数](/api-reference/common-parameters)。 +1. 在运行 OpenSearch 集群的同一台主机上,使用 Web 浏览器打开 `http://localhost:5601/`,访问 OpenSearch Dashboards。默认用户名是 `admin`,密码由 `docker-compose.yml` 文件中的 `OPENSEARCH_INITIAL_ADMIN_PASSWORD=` 设置指定。 +1. 在顶部菜单栏中,转到 **Management > Dev Tools**。 +1. 在控制台的左侧窗格中输入以下内容: + ```json + GET ecommerce/_search + { + "query": { + "match": { + "customer_first_name": "Sonya" + } + } + } + ``` +1. 选择请求右上角的三角形图标提交查询。你也可以按 `Ctrl+Enter`(Mac 用户按 `Cmd+Enter`)提交请求。要进一步了解如何使用 OpenSearch Dashboards 控制台提交查询,请参阅[在控制台中运行查询](/dashboards/dev-tools/run-queries)。 + +## 后续步骤 + +你已经成功部署了自己的 OpenSearch 集群和 OpenSearch Dashboards,并添加了一些示例数据。现在你可以更深入地了解配置和功能了。以下是一些入门建议: +- [关于 Security 插件](/security/) +- [OpenSearch 配置](/install-and-configure/configuring-opensearch/) +- [OpenSearch 插件安装](/install-and-configure/plugins) +- [OpenSearch Dashboards 入门](/dashboards/) +- [OpenSearch 工具](/tools/) +- [索引 API](/api-reference/index-apis/) + +## 常见问题 + +如果你的容器无法启动或意外退出,请查看以下常见问题及建议的解决方案。 + +### Docker 命令需要提升权限 + +将你的用户添加到 `docker` 用户组,即可无需使用 `sudo` 运行 Docker 命令。有关更多信息,请参阅 Docker 的 [Linux 安装后步骤](https://docs.docker.com/engine/install/linux-postinstall/)。 +```bash +sudo usermod -aG docker $USER +``` + +### 错误消息:"-bash: docker-compose: command not found" {#error-message--bash-docker-compose-command-not-found} + +如果你安装的是 Docker Desktop,那么你的机器上已经安装了 Docker Compose。请尝试使用 `docker compose`(不带连字符)代替 `docker-compose`。请参阅[使用 Docker Compose](https://docs.docker.com/get-started/08_using_compose/)。 + +### 错误消息:"docker: 'compose' is not a docker command." + +如果你安装的是 Docker Engine,则必须单独安装 Docker Compose,并且需要使用 `docker-compose` 命令(带连字符)。请参阅 [Docker Compose](https://github.com/docker/compose)。 + +### 错误消息:"max virtual memory areas vm.max_map_count [65530] is too low" {#error-message-max-virtual-memory-areas-vmmaxmapcount-65530-is-too-low} + +如果主机的 `vm.max_map_count` 过低,OpenSearch 将无法启动。如果你在服务日志中看到以下错误,请查阅[重要系统设置](/install-and-configure/install-opensearch/),并适当设置 `vm.max_map_count`。 +```bash +opensearch-node1 | ERROR: [1] bootstrap checks failed +opensearch-node1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] +opensearch-node1 | ERROR: OpenSearch did not exit normally - check the logs at /usr/share/opensearch/logs/opensearch-cluster.log +``` diff --git a/i18n/zh/version-history.md b/i18n/zh/version-history.md new file mode 100644 index 00000000..89437020 --- /dev/null +++ b/i18n/zh/version-history.md @@ -0,0 +1,50 @@ +--- +title: 版本历史 +--- + +# 版本历史 + +OpenSearch 版本 | 版本亮点 | 发布日期 +:--- | :--- | :--- +[2.12.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.12.0.md) | 并发段搜索和对话式搜索正式发布(GA)。提供实验性的 OpenSearch Assistant Toolkit,包括智能体和工具、工作流自动化,以及适用于 OpenSearch Dashboards UI 的 OpenSearch Assistant。新增 match-only text 字段、用于监控前 N 个查询的查询洞察(query insights),以及嵌套字段上的 k-NN 搜索。完整的版本亮点列表,请参阅发行说明。 | 2024 年 2 月 20 日 +[2.11.1](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.11.1.md) | 包括跨集群复制、告警、可观测性、OpenSearch Dashboards、索引管理、机器学习、安全和安全分析的维护变更及缺陷修复。完整的版本亮点列表,请参阅发行说明。 | 2023 年 11 月 30 日 +[2.11.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.11.0.md) | 新增多模态和稀疏神经搜索功能,以及创建引用远程存储中数据的浅快照的能力。搜索比较工具正式发布。包括在 Security Analytics 中创建威胁检测器的简化工作流,以及 OpenSearch Dashboards 的安全性改进。实验性功能包括用于分布式追踪的新框架和工具集,以及对话式搜索的更新。完整的版本亮点列表,请参阅发行说明。 | 2023 年 10 月 16 日 +[2.10.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.10.0.md) | 远程存储正式发布。新增混合搜索功能、Security Analytics 自定义日志类型、IP2Geo 摄取处理器以及 delimited term frequency 词元过滤器。为 OpenSearch Dashboards 带来全新的外观,并更新了 Discover 工具。通知新增 Microsoft Teams webhook 支持。实验性功能包括并发段搜索和对话式搜索。完整的版本亮点列表,请参阅发行说明。 | 2023 年 9 月 25 日 +[2.9.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.9.0.md) | 搜索管道和 Neural Search 插件正式发布。新增机器学习模型访问控制以及与外部机器学习工具的集成。实现了 k-NN 字节向量以及 Faiss 引擎的高效过滤。将告警和异常检测与 OpenSearch Dashboards 集成,并新增复合监控器。新增两个索引编解码算法选项。包括 Security Analytics 的新摄取模式、geoshape 聚合以及扩展(extensions)——一种扩展 OpenSearch 功能的新机制。完整的版本亮点列表,请参阅发行说明。 | 2023 年 7 月 24 日 +[2.8.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.8.0.md) | 新增使用 PPL 的跨集群查询、搜索管道、将段复制设为默认复制类型的选项、可搜索快照性能改进,以及在多数据源中通过 SigV4 身份验证支持 Amazon OpenSearch Serverless。包括 OpenSearch Dashboards 中用于 flush、refresh 和清除缓存操作的 UI。完整的版本亮点列表,请参阅发行说明。 | 2023 年 6 月 6 日 +[2.7.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.7.0.md) | 可搜索快照和段复制现已正式发布。在 OpenSearch Dashboards 中新增多数据源、可观测性功能、动态租户管理、组件模板以及基于形状的地图过滤器。包括 flat object 字段类型、热点分片识别以及机器学习模型的新自动重新加载机制。完整的版本亮点列表,请参阅发行说明。 | 2023 年 5 月 2 日 +[2.6.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.6.0.md) | 包括可观测性的简单模式、索引管理 UI 增强、Security Analytics 增强、协调节点级别的搜索背压,以及向仪表板添加地图的功能。实验性功能包括新的机器学习模型健康仪表板、机器学习中新的文本嵌入模型以及 Dashboards 中的 SigV4 身份验证。完整的版本亮点列表,请参阅发行说明。 | 2023 年 2 月 28 日 +[2.5.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.5.0.md) | 包括索引管理 UI 增强、多图层地图、可观测性的 Jaeger 支持、Debian 发行版、按感知属性返回集群健康状况、集群管理器任务限流、加权分区搜索请求路由策略,以及索引汇总(rollup)中的查询字符串支持。实验性功能包括远程存储中的请求级持久性以及机器学习节点的 GPU 加速。完整的版本亮点列表,请参阅发行说明。 | 2023 年 1 月 24 日 +[2.4.1](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.4.1.md) | 包括 gradle check 和索引压力测试的维护变更及缺陷修复。新增对跳过变更日志的支持。 | 2022 年 12 月 13 日 +[2.4.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.4.0.md) | 包括 Windows 支持、时间点(Point-in-time)搜索、自定义 k-NN 过滤、用于笛卡尔坐标的 xy_point 和 xy_shape 字段类型、GeoHex 网格聚合,以及包括搜索背压在内的弹性增强。在 OpenSearch Dashboards 中,此版本新增快照恢复功能、多重身份验证以及已保存对象的聚合视图。此版本包括以下实验性功能:可搜索快照、Compare Search Results、OpenSearch Dashboards 中的多数据源、ML Commons 中新的模型服务框架(Model Serving Framework)、支持语义搜索的新 Neural Search 插件,以及用于分析安全日志的新 Security Analytics 插件。完整的版本亮点列表,请参阅发行说明。 | 2022 年 11 月 15 日 +[2.3.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.3.0.md) | 此版本包括以下实验性功能:段复制、远程存储以及 OpenSearch Dashboards 的拖放功能。实验性功能让你可以在 OpenSearch 中测试新功能。由于这些功能仍在开发中,你的测试和反馈可以帮助在功能正式发布之前塑造其开发方向。我们不建议在生产环境中使用实验性功能。此外,此版本还为 SQL 插件新增了 maketime 和 makedate 日期时间函数。为 OpenSearch Dashboards 创建了新的 [OpenSearch Playground](https://playground.opensearch.org) 演示站点。完整的版本亮点列表,请参阅发行说明。 | 2022 年 9 月 14 日 +[2.2.1](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.2.1.md) | 包括 gradle 更新以及 gradle check 的缺陷修复。 | 2022 年 9 月 1 日 +[2.2.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.2.0.md) | 包括 ML Commons 中对逻辑回归(Logistic Regression)和 RCF Summarize 机器学习算法的支持、用于近似 k-NN 搜索的 Lucene 或基于 C 的 Nmslib 和 Faiss 库、使用 SQL 和 PPL 查询按相关性搜索、可视化的自定义区域地图以及汇总(rollup)增强。完整的版本亮点列表,请参阅发行说明。 | 2022 年 8 月 11 日 +[2.1.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.1.0.md) | 包括 ML Commons 插件中对专用机器学习节点的支持、SQL 中的相关性搜索及其他功能、多词项聚合以及快照管理(Snapshot Management)。完整的版本亮点列表,请参阅发行说明。 | 2022 年 7 月 7 日 +[2.0.1](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.0.1.md) | 包括 Alerting 和 Anomaly Detection 的缺陷修复及维护更新。 | 2022 年 6 月 16 日 +[2.0.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.0.0.md) | 包括告警的文档级监控器、OpenSearch Notifications 插件以及 OpenSearch Dashboards 中的 Geo Map Tiles。还新增了对 Lucene 9 的支持以及所有 OpenSearch 插件的缺陷修复。完整的版本亮点列表,请参阅发行说明。 | 2022 年 5 月 26 日 +[2.0.0-rc1](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-2.0.0-rc1.md) | 2.0.0 的候选发布版本。此版本让你可以在正式发布之前预览即将推出的 2.0.0 版本。该预览版本新增了文档级告警、对 Lucene 9 的支持,以及在文档级安全中使用 term lookup 查询的能力。 | 2022 年 5 月 3 日 +[1.3.15](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.15.md) | 包括跨集群复制、SQL、OpenSearch Dashboards 报告和告警的缺陷修复及维护更新。 | 2024 年 3 月 5 日 +[1.3.14](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.14.md) | 包括 OpenSearch 安全和 OpenSearch Dashboards 安全的缺陷修复及维护更新。 | 2023 年 12 月 12 日 +[1.3.13](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.13.md) | 包括 Anomaly Detection 的缺陷修复,新增维护更新和基础设施增强。 | 2023 年 9 月 21 日 +[1.3.12](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.12.md) | 新增 OpenSearch 安全和 OpenSearch Dashboards 可观测性的维护更新。包括可观测性、OpenSearch Dashboards 可视化和 OpenSearch 安全的缺陷修复。 | 2023 年 8 月 10 日 +[1.3.11](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.11.md) | 新增 OpenSearch 安全、OpenSearch Dashboards 安全和 ML Commons 的维护更新。 | 2023 年 6 月 29 日 +[1.3.10](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.10.md) | 新增异常检测、可观测性和安全的基础设施增强及维护更新。包括索引管理和 OpenSearch 安全的缺陷修复。 | 2023 年 5 月 18 日 +[1.3.9](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.9.md) | 新增 Debian 支持。包括 OpenSearch 核心、k-NN 和 OpenSearch 安全的升级、增强及维护更新。 | 2023 年 3 月 16 日 +[1.3.8](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.8.md) | 新增 OpenSearch 安全增强。更新工具脚本以便在 Windows 上运行。包括 Anomaly Detection 和 OpenSearch 安全的维护更新及缺陷修复。 | 2023 年 2 月 2 日 +[1.3.7](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.7.md) | 新增 Windows 支持。包括错误处理的维护更新及缺陷修复。 | 2022 年 12 月 13 日 +[1.3.6](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.6.md) | 包括 OpenSearch Security Dashboards 插件中租户功能的维护更新及缺陷修复。 | 2022 年 10 月 6 日 +[1.3.5](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.5.md) | 包括 gradle check 和 OpenSearch 安全的维护更新及缺陷修复。 | 2022 年 9 月 1 日 +[1.3.4](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.4.md) | 包括 OpenSearch 和 OpenSearch Dashboards 的维护更新及缺陷修复。 | 2022 年 7 月 14 日 +[1.3.3](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.3.md) | 新增 Anomaly Detection 和 ML Commons 的增强。修复 Anomaly Detection、Observability 和 k-NN 的缺陷。 | 2022 年 6 月 9 日 +[1.3.2](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.2.md) | 修复 Anomaly Detection 和 Security Dashboards 插件的缺陷,新增使用 RPM 安装 OpenSearch 的选项,增强 ML Commons 执行任务,并移除 Anomaly Detection 中的 job-scheduler zip。 | 2022 年 5 月 5 日 +[1.3.1](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.1.md) | 修复使用文档级安全时的缺陷,并调整 ML Commons 以使用最新的 RCF jar 和 protostuff 进行 RCF 模型序列化。 | 2022 年 3 月 30 日 +[1.3.0](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.3.0.md) | 为 Validate Detector API 新增模型类型验证;为索引管理新增持续转换、自定义操作、Explain API 的 applied policy 参数、默认操作重试以及新的滚动更新和转换条件;新增 ML Commons 插件;为 SQL 新增 parse 命令;为可观测性新增 Application Analytics、Live Tail、Correlation 和 Events Flyout;为 Performance Analyzer 新增自动向后移植以及对 OPENSEARCH_JAVA_HOME 的支持。缺陷修复。 | 2022 年 3 月 17 日 +[1.2.4](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.2.4.md) | 将 Performance Analyzer、SQL 和 Security 插件更新到 Log4j 2.17.1,将 Alerting 和 Job Scheduler 更新到 cron-utils 9.1.6,并更新 Anomaly Detection 和 SQL 中的 gson。 | 2022 年 1 月 18 日 +[1.2.3](https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.2.3.md) | 根据 [CVE-2021-45105](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45105) 公告的建议,将 OpenSearch 中使用的 Log4j 版本更新为 Log4j 2.17.0。 | 2021 年 12 月 22 日 +[1.2.0](https://github.com/opensearch-project/OpenSearch/blob/main/release-notes/opensearch.release-notes-1.2.0.md) | 新增可观测性、Anomaly Detection 的新验证 API、分片级索引背压、SQL 和 PPL 的新 "match" 查询类型、k-NN 中对 Faiss 库的支持,以及自定义 Dashboards 品牌。 | 2021 年 11 月 23 日 +[1.1.0](https://github.com/opensearch-project/opensearch-build/tree/main/release-notes/opensearch-release-notes-1.1.0.md) | 新增跨集群复制、索引管理的安全功能、桶级告警、帮助从 Elasticsearch OSS 升级到 OpenSearch 的 CLI,以及异常检测插件中针对高基数数据的增强。 | 2021 年 10 月 5 日 +[1.0.1](https://github.com/opensearch-project/opensearch-build/tree/main/release-notes/opensearch-release-notes-1.0.1.md) | 缺陷修复。 | 2021 年 9 月 1 日 +[1.0.0](https://github.com/opensearch-project/opensearch-build/tree/main/release-notes/opensearch-release-notes-1.0.0.md) | 正式发布版本。为需要在连接前进行版本检查的客户端新增兼容性设置。 | 2021 年 7 月 12 日 +[1.0.0-rc1](https://github.com/opensearch-project/opensearch-build/tree/main/release-notes/opensearch-release-notes-1.0.0-rc1.md) | 第一个候选发布版本。 | 2021 年 6 月 7 日 +[1.0.0-beta1](https://github.com/opensearch-project/opensearch-build/tree/main/release-notes/opensearch-release-notes-1.0.0-beta1.md) | 首个 beta 版本。重构插件以适配 OpenSearch。 | 2021 年 5 月 13 日 -- 2.54.0 From f1789a890178b234f1de72e57a64210a47107832 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 26 Nov 2026 11:32:42 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=E6=94=B9=E5=8F=91=E5=B8=83=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=BA=20main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 031ba6cf..596419c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline { DOCS_TOOLS = '.vitepress/node_modules' WRANGLER = '.vitepress/node_modules/.bin/wrangler' // 发布到线上的分支 - RELEASE_BRANCH = 'docs_cn' + RELEASE_BRANCH = 'main' // Cloudflare API Token(Jenkins Secret text 凭据,需要 Workers Scripts:Edit 权限) CLOUDFLARE_API_TOKEN = credentials('sharkdat-cloudflare-api-token') // Cloudflare Account ID(Secret text 凭据)。设置后 wrangler 不再调用 /memberships 查询账号, -- 2.54.0