🌟 一文掌握 《Elasticsearch:8.0 》

一、搭建《Elasticsearch:8.0 》集群 (Linux版)

1.1 准备三台centos、IP分别为129、131、132

1.2 安装 JDK 17

centos7:安装jdk详细步骤

es要求进程最大打开文件数数量为最低65536,每台都执行:

vi /etc/security/limits.conf

linux 复制代码
* soft nofile 65536 
* hard nofile 65536

修改/etc/sysctl.conf文件

vi /etc/sysctl.conf

linux 复制代码
vm.max_map_count = 262144

刷新配置

sysctl -p

1.3 下载elasticsearch-8.9.0

下载安装包

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

解压

tar -zxvf elasticsearch-8.9.0-linux-x86_64.tar.gz

1.4 创建as用户(es默认情况下不允许拥root用户运行)

useradd as

passwd as

①新建数据文件夹

mkdir /java/elasticsearch/elasticsearch-8.9.0/data

②新建证书文件夹

mkdir /java/elasticsearch/elasticsearch-8.9.0/config/certs

③更改文件拥有者

chown -R as:as /java/elasticsearch/elasticsearch-8.9.0

④切换到es用户

su as

cd /java/elasticsearch/elasticsearch-8.9.0/bin/

⑤签发 ca 证书

./elasticsearch-certutil ca

⑥用 ca 证书签发节点证书

./elasticsearch-certutil cert --ca elastic-stack-ca.p12

⑦将生成的证书移动到证书文件夹中

mv /java/elasticsearch/elasticsearch-8.9.0/elastic-stack-ca.p12 /java/elasticsearch/elasticsearch-8.9.0/config/certs/

1.5 在centos:129 签发htttp证书

cd /java/elasticsearch/elasticsearch-8.9.0/bin/

./elasticsearch-certutil http

查看证书的位置,解压并移动到证书的文件夹中

cd ..

unzip elasticsearch-ssl-http.zip

mv /java/elasticsearch/elasticsearch-8.9.0/elasticsearch/http.p12 /java/elasticsearch/elasticsearch-8.9.0/config/certs/

修改config/elasticsearch.yml文件:在文末加入如下配置

linux 复制代码
# 设置 ES 集群名称
cluster.name: es-study
# 设置集群中当前节点名称
node.name: node1
# 节点属性
node.roles: [master,data]
# 设置数据,日志文件路径
path.data: /java/elasticsearch/elasticsearch-8.9.0/data
path.logs: /java/elasticsearch/elasticsearch-8.9.0/logs
# 设置网络访问节点
# network和端口号一定要配置,如果怕安全问题,把host设置成访问此elasticsearch服务器的ip地址,就是设置成唯一访问。 可以配置成 network.host: 0.0.0.0
network.host: 192.168.118.129
# 设置网络访问端口
http.port: 9200
discovery.seed_hosts:
  - 192.168.118.129
  - 192.168.118.131
  - 192.168.118.132
cluster.initial_master_nodes:
  - node1
  - node2
  - node3
# 安全认证
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
 enabled: true # 注意第一个空格
 keystore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/http.p12
 truststore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/http.p12
xpack.security.transport.ssl:
 enabled: true
 verification_mode: certificate
 keystore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/elastic-stack-ca.p12
 truststore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/elastic-stack-ca.p12
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none

1.6 启动centos:129 es

cd bin/

./elasticsearch

1.7 在浏览器输入地址:

https://192.168.118.129:9200/

1.7 启动centos:131 es

需要创建用户、修改内存配置、新建data、certs文件夹,更上面的操作一样,再执行一次即可

将centos:129的证书下载,然后传到centos:131对应的文件夹下

修改elasticsearch.yml配置类

linux 复制代码
cluster.name: es-study
# 设置集群中当前节点名称
node.name: node2
# 节点属性
node.roles: [master,data]
# 设置数据,日志文件路径
path.data: /java/elasticsearch/elasticsearch-8.9.0/data
path.logs: /java/elasticsearch/elasticsearch-8.9.0/logs
# 设置网络访问节点
# network和端口号一定要配置,如果怕安全问题,把host设置成访问此elasticsearch服务器的ip地址,就是设置成唯一访问。 可以配置成 network.host: 0.0.0.0
network.host: 192.168.118.131
# 设置网络访问端口
http.port: 9200
discovery.seed_hosts:
  - 192.168.118.129
  - 192.168.118.131
  - 192.168.118.132
cluster.initial_master_nodes:
  - node1
  - node2
  - node3
# 安全认证
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
 enabled: true # 注意第一个空格
 keystore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/http.p12
 truststore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/http.p12
xpack.security.transport.ssl:
 enabled: true
 verification_mode: certificate
 keystore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/elastic-stack-ca.p12
 truststore.path: /java/elasticsearch/elasticsearch-8.9.0/config/certs/elastic-stack-ca.p12
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none

启动es

./elasticsearch

相关推荐
zzzll11113 小时前
Spring Boot 实现数据脱敏:自定义注解 + Jackson 序列化器
java·spring boot·后端
vx-Biye_Design8 小时前
SSM伴侣动物伴护星小程序06330-计算机课程设计、毕业设计
spring boot·后端·elasticsearch·小程序·架构·课程设计·idea
2分钟速写快排10 小时前
什么是 RAG?如何用 RAG 实现一个用户记忆?
前端·后端·ai编程
面向Google编程10 小时前
Apache Iceberg Variant 类型:v3 半结构化数据不再「二选一」
大数据·后端
X54先生(人文科技)10 小时前
ELR-SELLM Edge 神经元网络架构评估报告
人工智能·深度学习·架构·开源
jason成都11 小时前
Spring WebFlux 适配达梦新方案|dm‑r2dbc:Netty 异步传输的实验性 R2DBC 驱动
java·后端·spring
云泽80811 小时前
Git 版本控制系统(下):从 .git 目录结构到冲突解决机制详解
大数据·git·elasticsearch
Elastic 中国社区官方博客11 小时前
教程:使用 ES|QL 进行威胁狩猎
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索·安全威胁分析
小陈不好吃12 小时前
从单体到微服务:Spring Cloud Gateway 动态路由实战与踩坑记录
微服务·云原生·架构
北岛贰12 小时前
迷茫焦虑期,我做了一个带支付带官网的 AI 聊天虚拟恋人 App
前端·人工智能·后端