redhat 9.2 安装 elasticsearch-7.17.3 过程记录

  1. 确认 redhat 版本号:
bash 复制代码
 > cat /etc/redhat-release:
 > Red Hat Enterprise Linux release 9.2 (Plow)
  1. 新建 elasticsearch 目录:
bash 复制代码
 > cd /data/software && mkdir  elasticsearch && cd elasticsearch
  1. 下载 elasticsearch-7.17.3-linux-x86_64.tar.gz:
bash 复制代码
> wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.3-linux-x86_64.tar.gz

下载失败也可以去其他地方下载( 比如迅雷 ),然后上传到该目录。

  1. 解压 elasticsearch-7.17.3-linux-x86_64.tar.gz:
bash 复制代码
> tar -xzf elasticsearch-7.17.3-linux-x86_64.tar.gz
bash 复制代码
> cd elasticsearch-7.17.3 && mkdir data && mkdir tmpdir
  1. cd config && vim elasticsearch.yml,添加如下内容:
bash 复制代码
 cluster.initial_master_nodes: ["es-node-1"]  	// 不加启动 es 会报错 the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
 path.data: /data/software/elasticsearch/elasticsearch-7.17.3/data
 path.logs: /data/software/elasticsearch/elasticsearch-7.17.3/logs
 network.host: 0.0.0.0 							// 不加只能使用 http://127.0.0.1:9200 访问,不能用 具体 ip 访问
 ingest.geoip.downloader.enabled: false   		// 不加可能如果网络不好,java 调用 es api 会超时,然后 es 日志会发现类似 "error downloading geoip database [GeoLite2-Country.mmdb]" 的错误
  1. 修改 es 的默认 /tmp 目录:

有时候启动 es 会报类似 "Exception in thread "main" java.nio.file.AccessDeniedException: /tmp/elasticsearch-8523317643108022907..." 的错误,因为 No space left 或者 no permission 等,可以手动修改 es 默认使用的 /tmp 目录:

bash 复制代码
    1. vim  /data/software/elasticsearch/elasticsearch-7.17.3/bin/elasticsearch,在 "if [ -z "$ES_TMPDIR" ]; then" 上一行新增 ES_TMPDIR="/data/software/elasticsearch/elasticsearch-7.17.3/tmpdir"
    2. vim /data/software/elasticsearch/elasticsearch-7.17.3/bin/elasticsearch-env,在 "if [ ! -z "$ES_JAVA_HOME" ]; then" 上一行新增 ES_JAVA_HOME="/data/software/elasticsearch/elasticsearch-7.17.3/jdk"
	
  1. 启动 es:
bash 复制代码
    1. cd /data/software/elasticsearch/elasticsearch-7.17.3/bin && ./elasticsearch        // 前台启动 
	2. cd /data/software/elasticsearch/elasticsearch-7.17.3/bin && ./elasticsearch -d     // 后台启动 
  1. 安装 ik分词器:

  2. 下载 elasticsearch-analysis-ik-7.17.3.zip( 下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.3/elasticsearch-analysis-ik-7.17.3.zip )

  3. cd /data/software/elasticsearch/elasticsearch-7.17.3/plugins && mkdir analysis-ik

  4. 将下载好的 elasticsearch-analysis-ik-7.17.3.zip 上传到 analysis-ik 目录

  5. unzip elasticsearch-analysis-ik-7.17.3.zip

  6. 重启 elasticSearch

  7. elasticSearch 常见 API:

  8. http://127.0.0.1:9200/_cat/nodes?v # 查看所有节点

  9. http://127.0.0.1:9200/_cat/health?v # 查看 elasticSearch 健康状况

  10. http://127.0.0.1:9200/_cat/indices?v # 查看所有索引信息

  11. http://127.0.0.1:9200/index_article # 查看索引 index_article 的信息

  12. http://127.0.0.1:9200/index_article DELETE # 删除索引 index_article

  13. http://127.0.0.1:9200/index_article/_mapping DELETE # 删除索引 index_article

  14. http://127.0.0.1:9200/index_article/_search # 查询索引 index_article 中的全部数据

  15. http://127.0.0.1:9200/_analyze # 测试分词器分词效果

POST

{

"text":"I prefer having your accompanying for life-long time to the short-time tenderness",

"analyzer":"standard"

}

  1. 设置用户名、密码:

  2. 修改 /data/software/elasticsearch/elasticsearch-7.17.3/config/elasticsearch.yml,添加 "xpack.security.enabled: true"

  3. cd /data/software/elasticsearch/elasticsearch-7.17.3/bin 执行 ./elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass "",发现证书 elastic-certificates.p12 生成到了 /data/software/elasticsearch/elasticsearch-7.17.3/config 中

  4. 修改 /data/software/elasticsearch/elasticsearch-7.17.3/config/elasticsearch.yml,添加以下4行:

bash 复制代码
    xpack.security.transport.ssl.enabled: true
    xpack.security.transport.ssl.verification_mode: certificate
    xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
    xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
  1. 重启 es,浏览器请求 http://127.0.0.1:9200/ 提示让输入用户名和密码了

  2. 设置密码:

cd /data/software/elasticsearch/elasticsearch-7.17.3/bin 执行 ./elasticsearch-setup-passwords interactive,选择 y,根据提示为分别为用户 elastic、apm_system、kibana_system、logstash_system、beats_system、remote_monitoring_user 设置密码

相关推荐
深入云栈18 小时前
Netty 4.2.x 源码深度解析 (二十四):池化内存分配 —— PoolArena、PoolChunk 与 PoolSubpage
java·后端·架构
惜.己19 小时前
Java结合idea简单使用Playwright
java·开发语言·自动化
Vex2une20 小时前
JDK 8 下载安装与环境变量配置完整指南(Windows新手图文教程)
java·windows·环境配置·环境变量·jdk8·jdk下载安装·java入门教程
文丑颜不良啊21 小时前
LeetCode3281~3300题目解析
java·leetcode
nice_lcj5201 天前
【从零理解计算机网络 · 02】分层模型:别背 OSI 七层,看数据怎么被“打包“和“拆包“
java·后端·tcp/ip·计算机网络·面试·osi·分层模型
SimonKing1 天前
给Deepseek Harness装上插件市场,从此插件无忧
java·后端·程序员
艾莉丝努力练剑1 天前
【AI大模型接入SDK】C++的SessionManager 线程安全
java·开发语言·前端·c++·人工智能·学习·安全
aiotto资源分享1 天前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
RuoyiOffice1 天前
SpringBoot3+Vue3 采购到付款:ERP、WMS与财务如何按同一来源协同
java·spring boot·架构·vue
Elasticsearch1 天前
Java4Shell 远程代码执行漏洞 - CVE-2026-114938
elasticsearch