当前位置: 首页 > news >正文

openEuler 下部署 Elasticsearch

Elasticsearch(简称 ES)是分布式搜索与分析引擎,广泛用于日志分析、全文检索等场景。本文基于 openEuler 22.03 LTS 系统,从环境准备、单节点部署、集群搭建、功能验证到运维优化,提供可落地的部署指南。
一、环境准备

  1. 系统基础配置
    openEuler 默认配置需调整以适配 ES 的资源要求:
    bash
    运行

切换root用户

su root

1. 关闭防火墙(测试环境,生产环境需开放9200/9300端口)

systemctl stop firewalld
systemctl disable firewalld

2. 临时关闭SELinux(永久关闭需修改/etc/selinux/config)

setenforce 0

3. 调整虚拟内存(ES要求vm.max_map_count≥262144)

sysctl -w vm.max_map_count=262144
echo “vm.max_map_count=262144” >> /etc/sysctl.conf
sysctl -p

4. 安装依赖包

dnf install -y java-11-openjdk-devel wget
2. 下载 Elasticsearch 安装包
选择与 openEuler 架构匹配的 ES 版本(以 7.17.10 为例,适配 openEuler 22.03):
bash
运行

下载安装包(x86_64架构)

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.10-linux-x86_64.tar.gz

若为ARM64架构,替换为对应包:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.10-linux-aarch64.tar.gz

解压包

tar -zxvf elasticsearch-7.17.10-linux-x86_64.tar.gz
mv elasticsearch-7.17.10 /usr/local/elasticsearch
二、单节点部署

  1. 创建 ES 专属用户
    ES 不允许 root 用户启动,需创建系统用户:
    bash
    运行

创建用户组与用户

groupadd elasticsearch
useradd -g elasticsearch elasticsearch

授权目录权限

chown -R elasticsearch:elasticsearch /usr/local/elasticsearch
2. 配置 ES 核心参数
编辑 ES 配置文件/usr/local/elasticsearch/config/elasticsearch.yml:
yaml

集群名称(自定义)

cluster.name: es-cluster

节点名称(自定义)

node.name: es-node-1

数据存储路径

path.data: /usr/local/elasticsearch/data

日志存储路径

path.logs: /usr/local/elasticsearch/logs

绑定IP(0.0.0.0允许所有IP访问)

network.host: 0.0.0.0

HTTP端口(默认9200)

http.port: 9200

集群初始化主节点(单节点为自身)

cluster.initial_master_nodes: [“es-node-1”]
3. 启动 ES 服务
bash
运行

切换到elasticsearch用户

su elasticsearch

后台启动ES

cd /usr/local/elasticsearch
./bin/elasticsearch -d

验证启动状态(返回JSON信息则成功)

curl http://localhost:9200
三、集群部署(3 节点示例)
以节点1(192.168.1.10)、节点2(192.168.1.11)、节点3(192.168.1.12)为例,在单节点基础上调整配置:

  1. 所有节点统一配置elasticsearch.yml
    yaml
    cluster.name: es-cluster

各节点名称需唯一(如es-node-1、es-node-2、es-node-3)

node.name: es-node-1
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200

集群节点发现列表(所有节点IP)

discovery.seed_hosts: [“192.168.1.10”, “192.168.1.11”, “192.168.1.12”]

初始化主节点(所有节点名称)

cluster.initial_master_nodes: [“es-node-1”, “es-node-2”, “es-node-3”]
2. 依次启动所有节点
bash
运行
su elasticsearch
cd /usr/local/elasticsearch
./bin/elasticsearch -d
3. 验证集群状态
bash
运行

查看集群健康状态(返回"status":"green"则正常)

curl http://192.168.1.10:9200/_cat/health?v
四、功能验证

  1. 创建测试索引
    bash
    运行

创建名为test_index的索引

curl -X PUT “http://localhost:9200/test_index”

插入测试数据

curl -X POST “http://localhost:9200/test_index/_doc/1” -H “Content-Type: application/json” -d ‘{“name”:“openEuler”,“version”:“22.03”}’

查询数据

curl -X GET “http://localhost:9200/test_index/_search”
2. 查看节点信息
bash
运行

查看集群节点列表

curl http://localhost:9200/_cat/nodes?v
五、运维优化(openEuler 适配)

  1. 内存优化
    编辑/usr/local/elasticsearch/config/jvm.options,调整 JVM 堆内存(建议为物理内存的 50%,不超过 32GB):
    ini
    -Xms4g
    -Xmx4g
  2. 开机自启配置
    创建 systemd 服务文件/etc/systemd/system/elasticsearch.service:
    ini
    [Unit]
    Description=Elasticsearch
    After=network.target

[Service]
User=elasticsearch
Group=elasticsearch
WorkingDirectory=/usr/local/elasticsearch
ExecStart=/usr/local/elasticsearch/bin/elasticsearch
Restart=always

[Install]
WantedBy=multi-user.target
启用自启:
bash
运行
systemctl daemon-reload
systemctl enable elasticsearch
systemctl start elasticsearch
3. 常见问题解决
启动失败提示内存不足:检查vm.max_map_count是否配置,或调整 JVM 堆内存;
集群节点无法发现:确认防火墙开放 9300 端口(ES 节点通信端口),执行firewall-cmd --add-port=9300/tcp --permanent;
权限错误:重新执行chown -R elasticsearch:elasticsearch /usr/local/elasticsearch。
总结
openEuler 下部署 ES 的核心是系统参数适配(虚拟内存、用户权限)+ ES 配置优化(集群发现、资源限制)。单节点适合测试场景,生产环境建议 3 节点以上集群保证高可用。后续可结合 Kibana 实现数据可视化,或接入 Filebeat 完成日志采集。

http://www.cnnetsun.cn/news/127563.html

相关文章:

  • 集成电路核心领域人才需求
  • 63、活动目录安全、认证、日志记录、监控与配额管理指南
  • 企业级html 图书管理系统管理系统源码|SpringBoot+Vue+MyBatis架构+MySQL数据库【完整版】
  • 7、伪微分算子相关理论及狄拉克哈密顿量的解耦
  • 基于微信小程序的在线家庭清洁系统毕设源码
  • 20、微软 Windows Vista 使用指南:账户管理与数据保护
  • 15、活动目录用户与组管理操作指南
  • 17、活动目录计算机对象与组织单位管理指南
  • 12、Ourmon:网络监控与异常检测工具全解析
  • 22、恶意软件分析与检测全解析
  • 产品解读 | Ftrans SFT:信创浪潮下的FTP替代革命者
  • 继何恺明DyT后,LayerNorm再遭暴击!简单erf函数竟成Transformer新宠
  • C语言链表2
  • 蜣螂优化(DBO)算法在工程实际中求目标函数最小值的例子:压力容器设计成本最小化的4变量4约束...
  • 12、游戏内存中常见数据结构解析
  • 21、游戏响应式黑客技术全解析
  • 26、游戏隐藏与反检测技术全解析
  • Kotaemon网络安全问答:CVE漏洞快速查询
  • Kotaemon能否自动识别问题紧急程度?
  • 复杂时序场景的突围:金仓数据库是凭借什么超越InfluxDB?
  • 特价股票投资中的跨境投资策略与风险管理
  • 为分析经理制定全面的仪表板策略
  • MATLAB实现神经网络的模式识别
  • 17、在 Linux 系统中运行 Windows 程序及优化工作流
  • Kotaemon索引构建优化:FAISS vs HNSW性能对比
  • Kotaemon在低资源环境下的轻量化改造方案
  • 16、企业 Linux 桌面迁移与后台基础设施搭建指南
  • 19、数据迁移与备份:从 Windows 到 Linux 的全面指南
  • Kotaemon销售谈判策略建议:促成交易技巧
  • 特征工程中的特征构造技巧:大数据分析的创新实践