雷达智富

首页 > 内容 > 程序笔记 > 正文

程序笔记

如何在 Debian 12/11/10 上安装 OpenSearch

2024-07-15 48

OpenSearch 是一个高度可扩展的开源搜索引擎,由 AWS 团队作为 Elasticsearch 和 Kibana 的分支创建。 OpenSearch 使开发人员能够使用由 Apache Lucene 提供支持的强大文本搜索功能来存储、管理和分析大量数据。 OpenSearch 适用于全文搜索、实时监控和日志分析等各种应用,同时具有控制性、灵活性和可扩展性,可释放您为您的业务创建不同的定制搜索解决方案的限制。

OpenSearch 是在免费使用许可下发布的,吸引了大量社区通过贡献代码改进特性和功能以及文档来引导其开发、采用和成功。据了解,AWS 作为一家公司,使用 OpenSearch 作为其“Amazon OpenSearch Service”服务产品(托管服务)的后端。

在本文中,我们将了解在 Debian 12/11/10 Linux 操作系统上安装 OpenSearch 的步骤。在未运行 ElasticSearch 或类似解决方案的系统上执行此安装可能会导致端口冲突。安装过程与我们最近在 Ubuntu Linux 上安装 OpenSearch 的过程类似。

在 Debian 12/11/10 上安装 OpenSearch

在这里,我们为您提供在 Debian 上正常安装 OpenSearch 所需的步骤。

1.系统更新

确保您在全新安装的 Debian Linux 系统上执行安装。但系统必须在其他步骤之前更新。

sudo apt update && sudo apt upgrade -y

检查升级后是否需要重启。有时就是这种情况。

[ -e /var/run/reboot-required ] && sudo reboot

2.启用OpenSearch APT存储库

OpenSearch 的所有最新 Debian 软件包均可在 OpenSearch APT 存储库中找到,可使用高级软件包工具 (APT) 安装。默认情况下该存储库不可用,需要手动添加。它包含所有必需的依赖项和 OpenSearch 包。

让我们安装提供启用存储库所需依赖项的软件包。

sudo apt update && sudo apt -y install gnupg2 lsb-release ca-certificates curl

导入用于签署 OpenSearch 包以确保真实性的 OpenSearch GPG 密钥。

curl -fsSL https://artifacts.opensearch.org/publickeys/opensearch.pgp|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/opensearch.gpg

将 OpenSearch 存储库添加到 Debian 的 APT 源列表中。

echo "deb https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-2.x.list

现在刷新我们添加的 OpenSearch 存储库中可用的包列表。

sudo apt update

使用 APT 包管理器在 Debian 上安装 OpenSearch 包。

sudo apt install vim opensearch

您还可以安装 APT 存储库中提供的特定版本的 OpenSearch。

sudo apt list -a opensearch
sudo apt install opensearch=<version>

使用 systemd 配置 opensearch 服务自动启动

 sudo systemctl daemon-reload
 sudo systemctl enable opensearch.service

3. 在 Debian 上配置 OpenSearch

编辑 opensearch.yml 文件以调整 OpenSearch 的启动配置。

sudo vim /etc/opensearch/opensearch.yml

添加以下行:

# Bind OpenSearch to the correct network interface. Use 0.0.0.0
# to include all available interfaces or specify an IP address
# assigned to a specific interface.
network.host: 0.0.0.0

# Unless you have already configured a cluster, you should set
# discovery.type to single-node, or the bootstrap checks will
# fail when you try to start the service.
discovery.type: single-node

# If you previously disabled the Security plugin in opensearch.yml,
# be sure to re-enable it. Otherwise you can skip this setting.
plugins.security.disabled: true

您还可以设置节点名称以使用系统中配置的主机名。

node.name: ${HOSTNAME}

可以指定索引簇的默认名称。

cluster.name: mycluster

要指定初始和最大 JVM 堆大小,请编辑以下文件。

sudo vim /etc/opensearch/jvm.options

默认设置。

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1g
-Xmx1g

可以调整这些值以匹配系统上的 RAM。

完成更改后,您需要重新启动 OpenSearch 服务。

sudo systemctl restart opensearch

检查服务状态。

$ systemctl status opensearch
● opensearch.service - OpenSearch
     Loaded: loaded (/lib/systemd/system/opensearch.service; enabled; preset: enabled)
     Active: active (running) since Wed 2023-11-29 09:52:26 UTC; 21s ago
       Docs: https://opensearch.org/
   Main PID: 3551 (java)
      Tasks: 69 (limit: 4531)
     Memory: 1.2G
        CPU: 41.549s
     CGroup: /system.slice/opensearch.service
             └─3551 /usr/share/opensearch/jdk/bin/java -Xshare:auto -Dopensearch.networkaddress.cache.ttl=60 -Dopensearch.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.>
Nov 29 09:52:26 deb12 systemd[1]: Started opensearch.service - OpenSearch.

测试 OpenSearch 的功能。

 curl -X GET http://localhost:9200

plugins.security.disabled: 设置为 false

$ curl -X GET https://localhost:9200 -u 'admin:admin' --insecure
{
  "name" : "deb12",
  "cluster_name" : "opensearch",
  "cluster_uuid" : "1C2PKCFKTRyeduMDE8UjjA",
  "version" : {
    "distribution" : "opensearch",
    "number" : "2.11.0",
    "build_type" : "deb",
    "build_hash" : "4dcad6dd1fd45b6bd91f041a041829c8687278fa",
    "build_date" : "2023-10-13T02:57:02.526977318Z",
    "build_snapshot" : false,
    "lucene_version" : "9.7.0",
    "minimum_wire_compatibility_version" : "7.10.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "The OpenSearch Project: https://opensearch.org/";
}

4. 安装 OpenSearch 插件

OpenSearch 插件用于通过额外的特性和功能来扩展 OpenSearch 搜索引擎的功能。插件可用于增强监控、安全性、数据可视化等。

要列出已安装的插件,请运行:

# /usr/share/opensearch/bin/opensearch-plugin list
opensearch-alerting
opensearch-anomaly-detection
opensearch-asynchronous-search
opensearch-cross-cluster-replication
opensearch-custom-codecsIf that awesome I didn't
opensearch-geospatial
opensearch-index-management
opensearch-job-scheduler
opensearch-knn
opensearch-ml
opensearch-neural-search
opensearch-notifications
opensearch-notifications-core
opensearch-observability
opensearch-performance-analyzer
opensearch-reports-scheduler
opensearch-security
opensearch-security-analytics
opensearch-sql

或者使用不带 SSL 的curl 进行查询:

curl -X GET http://localhost:9200/_cat/plugins?v

plugins.security.disabled: 设置为 false

$ curl -X GET https://localhost:9200/_cat/plugins?v -u 'admin:admin' --insecure
name  component                            version
deb12 opensearch-alerting                  2.11.0.0
deb12 opensearch-anomaly-detection         2.11.0.0
deb12 opensearch-asynchronous-search       2.11.0.0
deb12 opensearch-cross-cluster-replication 2.11.0.0
deb12 opensearch-custom-codecs             2.11.0.0
deb12 opensearch-geospatial                2.11.0.0
deb12 opensearch-index-management          2.11.0.0
deb12 opensearch-job-scheduler             2.11.0.0
deb12 opensearch-knn                       2.11.0.0
deb12 opensearch-ml                        2.11.0.0
deb12 opensearch-neural-search             2.11.0.0
deb12 opensearch-notifications             2.11.0.0
deb12 opensearch-notifications-core        2.11.0.0
deb12 opensearch-observability             2.11.0.0
deb12 opensearch-performance-analyzer      2.11.0.0
deb12 opensearch-reports-scheduler         2.11.0.0
deb12 opensearch-security                  2.11.0.0
deb12 opensearch-security-analytics        2.11.0.0
deb12 opensearch-sql                       2.11.0.0

可以根据需要安装单独的 OpenSearch 插件。有关可用插件的详细信息,请参阅可用插件。

opensearch-plugin install <plugin-name>

安装 OpenSearch 仪表板

如果您需要 OpenSearch Dashboards(用于可视化 OpenSearch 数据的用户界面),请参阅 OpenSearch Dashboards 官方文档页面。

echo "deb 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
sudo apt update
sudo apt install opensearch-dashboards
sudo systemctl enable opensearch-dashboards
sudo systemctl start opensearch-dashboards
sudo systemctl status opensearch-dashboards

从 Web 浏览器导航到 OpenSearch 仪表板。默认端口是5601,服务器主IP地址或本地主机取决于监听地址。

默认登录名是:

  • 用户名admin
  • 密码管理员

结论

在这篇博文中,我们已经在 Debian Linux 系统上成功安装和配置了 OpenSearch。 OpenSearch 的深度定制超出了本文的范围。通读 OpenSearch 文档页面以了解更多信息,并能够调整 OpenSearch 安装以满足不同的业务需求。


更新于:2个月前
赞一波!1

文章评论

全部评论