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

Linux上安装Elasticsearch

Linux上安装Elasticsearch

文章目录

  • Linux上安装Elasticsearch
    • 1. 下载安装包
    • 2. 上传到linux服务器
    • 3. 解压
    • 4. 修改配置文件
    • 5. 扩大内存权限
    • 6. 启动ES(注意:root用户无法启动)
      • 创建用户
      • 创建所属组,赋予es文件操作权限:
      • 切换到yizhi用户
      • 进入bin目录
      • 启动elasticsearch,注意:第一次启动一定要前台启动
        • 前台运行, Ctrl + C 终止
        • 后台运行
          • 启动成功后会返回一段信息,其中包含了初始用户名、密码等信息
      • 开放防火墙,没修改是9200 , 照上面修改后的是19200
      • 访问:https://00.00.00.00:19200,注意:一定是https,http访问不到
        • 原因:是因为ES8默认开启了 SSL 认证。
        • 解决方式:
          • a. 使用https访问
          • b. 重新打开elasticsearch.yml
          • 位置:相对位置/elasticsearch-8.7.1/config/elasticsearch.yml
        • 重新启动,如果访问成功,之后都可以在后台启动了,但是第一次一定要在前台启动

1. 下载安装包

官网下载地址: https://www.elastic.co/cn/downloads/elasticsearch

2. 上传到linux服务器

3. 解压

tar -zxvf elasticsearch-8.7.1-linux-x86_64.tar.gz -C /www/wwwroot

4. 修改配置文件

位置:相对位置/elasticsearch-8.7.1/config/elasticsearch.yml,添加如下

# 数据目录位置
path.data: /www/wwwroot/es/dataES
# 日志目录位置
path.logs: /www/wwwroot/es/logsES
# 默认只允许本机访问,修改为0.0.0.0后则可以远程访问
# 绑定到0.0.0.0,允许任何ip来访问
network.host: 0.0.0.0
# 在添加下面参数让elasticsearch-head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"
# 修改端口号(非必须)
http.port: 19200

cluster.initial_master_nodes: ["VM-4-7-centos"]

5. 扩大内存权限

位置:绝对位置:/etc/sysctl.conf,添加一行

vm.max_map_count=262144

然后控制台运行:sysctl -p

6. 启动ES(注意:root用户无法启动)

创建用户

useradd yizhi

创建所属组,赋予es文件操作权限:

chown yizhi:yizhi -R 相对位置/elasticsearch-8.7.1

切换到yizhi用户

su yizhi

进入bin目录

cd 相对位置/elasticsearch-8.7.1/bin

启动elasticsearch,注意:第一次启动一定要前台启动

前台运行, Ctrl + C 终止

./elasticsearch

后台运行

elasticsearch -d

启动成功后会返回一段信息,其中包含了初始用户名、密码等信息
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.

ℹ️  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
  XXXXXXXXXXXX

ℹ️  HTTP CA certificate SHA-256 fingerprint:
  XXXXXXXXXXXXXXXXX

ℹ️  Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=

ℹ️ Configure other nodes to join this cluster:
• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=

  If you're running in Docker, copy the enrollment token and run:
  `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.7.1`

用户名为elastic,密码为XXXXXXXXXXXX

开放防火墙,没修改是9200 , 照上面修改后的是19200

访问:https://00.00.00.00:19200,注意:一定是https,http访问不到

原因:是因为ES8默认开启了 SSL 认证。

解决方式:

a. 使用https访问
b. 重新打开elasticsearch.yml
位置:相对位置/elasticsearch-8.7.1/config/elasticsearch.yml

可以看到这两行

xpack.security.enabled: true
xpack.security.enrollment.enabled: true

xpack.security.enabled设置为 false

重新启动,如果访问成功,之后都可以在后台启动了,但是第一次一定要在前台启动


http://www.kler.cn/news/18287.html

相关文章:

  • 4。计算机组成原理(2)存储系统
  • 理解FPGA的基础知识——逻辑电路
  • 一次业务系统无法使用对应的oracle数据库性能分析过程
  • React条件渲染、列表渲染和组件传值
  • 增强型语言模型——走向通用智能的道路?!?
  • 11 KVM虚拟机配置-配置虚拟设备(存储)
  • PostgreSQL数据库自带的命令行工具--psql
  • Lumerical------S 参数文件格式
  • Qt 制作小程序登录系统(超详细)
  • 浅谈 LRU
  • Web2与Web3开发的不同之处
  • python正则表达式
  • 第二章 Vim编辑器与Shell命令脚本
  • 双线性插值(Bilinear interpolation)原理推导
  • PyQGIS中一次性加载多个shp文件
  • 探索语音识别技术:从自动翻译到智能客服
  • electron打包运行白屏、Can not find modules ‘xxx‘,Dynamic Linking Error
  • JavaWeb ( 六 ) JSP
  • C# 判断文件/目录是否存在
  • AWS VPC 配置指南:快速创建和设置你的虚拟私有云
  • 【C++】map和set的介绍+使用
  • EC6110-Hi3798MV310-当贝纯净桌面-卡刷强刷固件包
  • 在 node.js 里面写 MySQL 增删改查语句
  • helm部署nacos
  • 线性结构-数组
  • nestjs笔记
  • 打动人心的故事 | 如何利用文案在Facebook上塑造品牌形象
  • 面试整理 - 二叉排序树 c语言 及java 例子
  • 【在homeassistant的ONVIF中配置TP-Link】
  • SpringBoot启用web模拟测试(一)