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

ELK-01-elasticsearch-8.15.1安装

文章目录

  • 前言
  • 一、下载elasticsearch
  • 二、将tar包放到服务器
  • 三、解压tar包
  • 四、更改配置文件
  • 五、添加启动用户
  • 六、用elasticserch用户启动
    • 6.1 报错
    • 6.2 解决问题1
    • 6.3 解决问题2
    • 6.4 再次用elasticserch用户启动
    • 6.5 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: 9200
cluster.initial_master_nodes: ["bztc-es-node-1"]

五、添加启动用户

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

#添加用户
sudo passwd elasticserch
#设置密码
sudo passwd 你的密码
#将文件夹赋权给elasticsearch
sudo chown -R elasticsearch /opt/elasticsearch

六、用elasticserch用户启动

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

6.1 报错

[2024-09-23T17:15:13,906][ERROR][o.e.b.Elasticsearch      ] [bztc-es-node-1] node validation exception
[2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch. For more information 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]; for more information 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 enabled if security is enabled. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.15/bootstrap-checks-xpack.html#bootstrap-checks-tls]

6.2 解决问题1

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

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

6.3 解决问题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.4 再次用elasticserch用户启动

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

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

curl localhost: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.5 windows浏览器打开

浏览器地址栏输入:http://10.211.55.120:9200
会出现:
在这里插入图片描述

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

七、设置开机自动启动

7.1 创建启动脚本

创建一个脚本文件。

sudo vim /opt/elasticsearch/start.sh

7.2 在脚本中添加以下内容

#!/bin/bash
cd /opt/elasticsearch/elasticsearch-8.15.1/bin && ./elasticsearch

7.3 赋予脚本执行权限

sudo chmod +x /opt/elasticsearch/start.sh

7.4 创建 Systemd 服务单元文件

sudo nano /etc/systemd/system/bztcES.service

在bztcES.service添加以下内容

[Unit]
Description=Elasticsearch Service
After=network.target[Service]
Type=simple
User=elasticsearch
ExecStart=/opt/elasticsearch/start.sh
Restart=on-failure
RestartSec=60[Install]
WantedBy=multi-user.target

7.5 重新加载 Systemd 配置

sudo systemctl daemon-reload

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

sudo systemctl start bztcES.service
sudo systemctl enable bztcES.service

7.7 检查服务状态

sudo systemctl status bztcES.service

总结

在Linux系统中安装elasticsearch。


http://www.mrgr.cn/news/34365.html

相关文章:

  • 【python】标识符
  • 大数据毕业设计选题推荐-安顺旅游景点数据分析系统-Hive-Hadoop-Spark
  • R18 5G网络中 AI/ML技术特性及其在5GS和NG-RAN中的应用
  • 软件设计师:01计算机组成与结构
  • Java后端面试题(微服务相关2)(day13)
  • 机器人顶刊IEEE T-RO发布无人机动态环境高效表征成果:基于粒子的动态环境连续占有地图
  • Python 图算法系列29-大规模图关系建立-step1导入数据
  • 预计2030年全球半导体用超高纯氢气市场规模将达到2.5亿美元
  • HTML5 Video标签的属性、方法和事件汇总,以及常用视频插件推荐
  • windows自定义路径docker安装
  • 镭射限高防外破预警装置-线路防外破可视化监控,安全尽在掌握中
  • 跨境专线的网速收到什么影响
  • SpringBoot+Thymeleaf租房管理系统
  • python 斑马打印模板
  • TAPD 提效技巧 - 需求基本信息
  • leetcode 236.二叉树的最近公共祖先
  • Sentence Transformers 教程!
  • 【解密 Kotlin 扩展函数】扩展函数的底层原理(十八)
  • 云原生周刊:Artifact Hub 成为 CNCF 孵化项目|2024.9.23
  • 项目实现:云备份服务端③(热点模块、服务端业务处理模块实现)