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

监控-01-elasticsearch-8.15.1安装

文章目录

  • 前言
  • 一、下载elasticsearch
  • 二、将tar包放到服务器
  • 三、解压tar包
  • 四、更改配置文件
  • 五、添加启动用户
  • 六、用elasticserch用户启动
    • 6.1 报错
    • 6.2 报错
    • 6.3 解决问题1
    • 6.4 解决问题2
    • 6.5 再次用elasticserch用户启动
    • 6.6 windows浏览器打开
  • 七、设置开机自动启动
    • 7.1 创建启动脚本
    • 7.2 在脚本中添加以下内容
    • 7.3 赋予脚本执行权限
    • 7.4 创建 Systemd 服务单元文件
    • 7.5 重新加载 Systemd 配置
    • 7.6 启动服务并使其在开机时自启
    • 7.7 检查服务状态
  • 总结

前言

在Linux系统中安装elasticsearch。


一、下载elasticsearch

下载地址:
https://www.elastic.co/cn/downloads/past-releases#elasticsearch

二、将tar包放到服务器

三、解压tar包

四、更改配置文件

vim/opt/elasticsearch/elasticsearch-8.15.1/config/elasticsearch.yml

更改为:

cluster.name: bztc-elasticsearch node.name: bztc-es-node-1 path.data: /opt/elasticsearch/data path.logs: /opt/elasticsearch/logs network.host:0.0.0.0 http.port:9200cluster.initial_master_nodes:["bztc-es-node-1"]

五、添加启动用户

此时启动es会报错,因为不能用root用户启动。
添加一个elasticserch用户:

#添加用户sudouseraddelasticsearch#设置用户elasticsearch的密码sudopasswdelasticsearch#将文件夹赋权给elasticsearchsudochown-Relasticsearch /opt/elasticsearch

六、用elasticserch用户启动

cd/opt/elasticsearch/elasticsearch-8.15.1/bin ./elasticsearch

6.1 报错

[elasticsearch@es9 bin]$ ./elasticsearch warning: ignoringJAVA_HOME=/opt/jdk-21.0.9;using bundled JDK ERROR: Elasticsearch diedwhilestarting up, withexitcode137

调整 JVM 堆内存大小
Elasticsearch 默认堆内存为 1GB,但可能会根据系统内存自动调整。建议手动设置:

# 编辑 JVM 配置文件vi/opt/elasticsearch/config/jvm.options# 添加或修改以下参数(根据实际内存调整)# 设置初始堆内存-Xms512m# 设置最大堆内存-Xmx512m

内存配置建议:

系统总内存 2GB:设置 -Xms512m -Xmx512m

系统总内存 4GB:设置 -Xms1g -Xmx1g

系统总内存 8GB:设置 -Xms2g -Xmx2g

注意:堆内存不要超过系统内存的 50%,留一半给操作系统和文件系统缓存

6.2 报错

[2024-09-23T17:15:13,906][ERROR][o.e.b.Elasticsearch][bztc-es-node-1]nodevalidation exception[2]bootstrap checks failed. You must address the points describedinthe following[2]lines before starting Elasticsearch. Formoreinformation see[https://www.elastic.co/guide/en/elasticsearch/reference/8.15/bootstrap-checks.html]bootstrap check failure[1]of[2]: max virtual memory areas vm.max_map_count[65530]is too low, increase to at least[262144];formoreinformation see[https://www.elastic.co/guide/en/elasticsearch/reference/8.15/_maximum_map_count_check.html]bootstrap check failure[2]of[2]: Transport SSL must be enabledifsecurity is enabled. Pleaseset[xpack.security.transport.ssl.enabled]to[true]or disable security by setting[xpack.security.enabled]to[false];formoreinformation see[https://www.elastic.co/guide/en/elasticsearch/reference/8.15/bootstrap-checks-xpack.html#bootstrap-checks-tls]

6.3 解决问题1

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

sudovim/etc/sysctl.conf#在sysctl.conf末尾添加:vm.max_map_count=262144#保存并退出文件,然后运行以下命令使更改生效sudosysctl-p

6.4 解决问题2

Transport SSL must be enabled if security is enabled. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]

vim/opt/elasticsearch/elasticsearch-8.15.1/config/elasticsearch.yml#在末尾添加:xpack.security.enabled: false#保存文件

6.5 再次用elasticserch用户启动

cd/opt/elasticsearch/elasticsearch-8.15.1/bin ./elasticsearch

启动成功,没有报错后打开新的命令窗口执行:

curllocalhost:9200

执行完出现以下内容:

{"name":"bztc-es-node-1","cluster_name":"bztc-elasticsearch","cluster_uuid":"wecEbx33T5Sdv-UzTIpcNg","version":{"number":"8.15.1","build_flavor":"default","build_type":"tar","build_hash":"253e8544a65ad44581194068936f2a5d57c2c051","build_date":"2024-09-02T22:04:47.310170297Z","build_snapshot":false,"lucene_version":"9.11.1","minimum_wire_compatibility_version":"7.17.0","minimum_index_compatibility_version":"7.0.0"},"tagline":"You Know, for Search"}

6.6 windows浏览器打开

浏览器地址栏输入:http://10.211.55.120:9200
会出现:

如果服务器里curl localhost:9200能打印内容,而浏览器不行,则检查服务器防火墙是否关闭,或者配置文件里的network.host是否配置的0.0.0.0

七、设置开机自动启动

7.1 创建启动脚本

创建一个脚本文件。

sudovim/opt/elasticsearch/start.sh

7.2 在脚本中添加以下内容

#!/bin/bashcd/opt/elasticsearch/elasticsearch-8.15.1/bin&&./elasticsearch

7.3 赋予脚本执行权限

sudochmod+x /opt/elasticsearch/start.sh

7.4 创建 Systemd 服务单元文件

sudonano/etc/systemd/system/bztcES.service

在bztcES.service添加以下内容

[Unit]Description=Elasticsearch ServiceAfter=network.target[Service]Type=simpleUser=elasticsearchExecStart=/opt/elasticsearch/start.shRestart=on-failureRestartSec=60[Install]WantedBy=multi-user.target

7.5 重新加载 Systemd 配置

sudosystemctl daemon-reload

7.6 启动服务并使其在开机时自启

sudosystemctl start bztcES.servicesudosystemctlenablebztcES.service

7.7 检查服务状态

sudosystemctl status bztcES.service

总结

在Linux系统中安装elasticsearch。

http://www.jsqmd.com/news/677112/

相关文章:

  • 2026年甘肃兰州租车公司优选 涵盖高端定制与大众出行 兼顾节能与智能出行 - 深度智识库
  • 浏览器卡顿、隐私泄露?Thorium为你带来极致性能与隐私保护解决方案
  • 求推荐厂房暖通中央空调工程方?设计施工一体化承包的看这儿 - 品牌2026
  • Splatoon:解决FFXIV高难副本机制可视化的智能导航方案
  • 【Matlab】MATLAB教程:线性判别分析LDA及分类特征提取实战(基于lda(data,label))
  • Qt右键菜单死活弹不出来?别急,先检查这行代码(customContextMenuRequested信号实战)
  • 从零到一:C语言PAT基础算法通关实战
  • Xshell高效连接实战:SSH、Telnet与串口配置全解析
  • 揭秘天猫超市购物卡回收大法,轻松变现不浪费 - 团团收购物卡回收
  • 如何在3分钟内用Applite告别Mac软件安装烦恼:终极图形化Homebrew解决方案
  • 给I.MX6ULL开发板插上翅膀:保姆级教程搞定RTL8188EUS USB无线网卡驱动
  • **发散创新:基于Python的稀疏模型在NLP任务中的高效实现与部署**在自
  • 2026年广州热门饰品公司 海富饰品款式新颖吗 - 工业品网
  • 告别电脑调试:用iOS快捷指令打造你的移动端‘轻量级开发者工具’
  • 2026汽车软件发展现状报告
  • Spring Boot项目实战:集成Zip4j实现带密码的批量分卷压缩上传功能
  • VoiceFixer终极指南:3分钟掌握免费AI语音修复工具
  • 2026年GEO服务商深度解析:十家头部企业如何重塑B2B获客逻辑 - 品牌2025
  • 告别黑窗口:给CentOS 7/8服务器装上KDE桌面,像用Windows一样管理Linux
  • 联邦学习实战:从FedAvg算法原理到PaddlePaddle实现
  • 广东雨宏家顺建筑防水工程:东莞防水补漏哪个公司好 - LYL仔仔
  • NextLevel多相机支持:同时使用广角、长焦和超广角镜头
  • 深度解析:2026年值得信赖的AI推广公司权威榜单(含医疗器械) - 品牌2025
  • 目前见过最适合教师的12款AI工具,简直不要太方便! - AI论文先行者
  • 从医疗级CPC到手机加速度计:拆解智能手环睡眠监测的‘技术代差’与选购指南
  • Android Manifest里tools:replace用不对?详解合并冲突的‘替换’规则与避坑指南
  • 济南聚鑫打胶服务:济南门窗打胶哪家好 - LYL仔仔
  • 数字信号处理基础:从模拟到离散的转换与应用
  • nli-MiniLM2-L6-H768镜像免配置教程:开箱即用的交叉编码器推理方案
  • 手机检测模型应用实战:基于DAMOYOLO的智能识别方案