ELK的搭建—Elasticsearch-8.11.3的安装及集群的搭建

es的安装及其集群的搭建

  • 一、Elasticsearch服务的安装部署
      • [1. Elasticsearch的rpm包下载](#1. Elasticsearch的rpm包下载)
      • [2. 安装Elasticsearch服务](#2. 安装Elasticsearch服务)
      • [3. 设置系统资源及内存大小分配](#3. 设置系统资源及内存大小分配)
      • [4. Elasticsearch的配置修改](#4. Elasticsearch的配置修改)
  • 二、建立Elasticsearch集群
      • [1. 安装Elasticsearch主节点server1](#1. 安装Elasticsearch主节点server1)
      • [2. 配置server1,及配置文件的详解](#2. 配置server1,及配置文件的详解)
      • [3. 重启elasticsearch的server1节点](#3. 重启elasticsearch的server1节点)
      • [1. 安装Elasticsearch主节点server2](#1. 安装Elasticsearch主节点server2)
      • [2. 配置server2,及配置文件的详解](#2. 配置server2,及配置文件的详解)
      • [3. 重启elasticsearch的server2节点](#3. 重启elasticsearch的server2节点)
      • [1. 安装Elasticsearch主节点server3步骤与server2相同](#1. 安装Elasticsearch主节点server3步骤与server2相同)
  • [三、 elasticsearch插件的安装](#三、 elasticsearch插件的安装)

应用场景:信息检索,旅游网站,滴滴车离我多远

一、Elasticsearch服务的安装部署

1. Elasticsearch的rpm包下载

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

2. 安装Elasticsearch服务

bash 复制代码
#安装Elasticsearch(一般说成es)的rpm包
[root@erds-node ~]# rpm -ivh elasticsearch-8.11.3-x86_64.rpm
warning: elasticsearch-8.11.3-x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Updating / installing...
   1:elasticsearch-0:8.11.3-1         ################################# [100%]

--------------------------- Security autoconfiguration information ------------------------------

Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.

#!!!!!!!!注意: 此处的Jg+*c_O-bhFlK3jZvm54为Elasticsearch服务的用户elastic的密钥
The generated password for the elastic built-in superuser is : Jg+*c_O-bhFlK3jZvm54    

If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>'
after creating an enrollment token on your existing cluster.

You can complete the following actions at any time:

Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.

Generate an enrollment token for Kibana instances with
 '/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.

Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.

-------------------------------------------------------------------------------------------------
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service

#重载system配置
[root@erds-node ~]# systemctl daemon-reload
#设置开机自启,并启动服务
[root@erds-node ~]# systemctl enable --now  elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

3. 设置系统资源及内存大小分配

复制代码
es节点非常消耗资源需调整内核参数如下:
[root@localhost ~]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
* soft  memlock  unlimited
* hard memlock  unlimited
elasticsearch -  nofile  65535     #添加此行,设置最大文件数
elasticsearc   -  nproc  4096      #添加此行,设置最大线程数

[root@erds-node ~]# echo "vm.max_map_count=262144" >> /etc/sysctl.conf
[root@erds-node ~]# sysctl -p
vm.max_map_count = 262144

锁定elasticsearch使用内存的大小(可不调整,使用默认值)
[root@localhost elasticsearch]# vi jvm.options

	  ##可在此处修改elasticsearch默认占用的内存大小,根据自己系统内存大小进行设定,默认为4G
	  ## -Xms4g
	  ## -Xmx4g

[root@localhost ~]# vi /usr/lib/systemd/system/elasticsearch.service

      # Specifies the maximum size of virtual memory
      LimitAS=infinity
      LimitMEMLOCK=infinity         ####添加此行 :限制内存锁定
      
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# cd /etc/elasticsearch/
[root@localhost elasticsearch]# vi elasticsearch.yml

      # Lock the memory on startup:
      bootstrap.memory_lock: true   #取消此行注释,内存锁定,索斯设置的1G内存

4. Elasticsearch的配置修改

bash 复制代码
[root@localhost elasticsearch]# cat elasticsearch.yml
#数据存储目录
path.data: /var/lib/elasticsearch
#日志存储目录
path.logs: /var/log/elasticsearch
#默认情况下,Elasticsearch只能在本地主机上访问,设置为0.0.0.0可在任意主机上使用https://IP:9200进行访问
network.host: 0.0.0.0
#设置Elasticsearch监听端口,默认为9200
http.port: 9200
#集群的主机列表,主机IP之间以","隔开
discovery.seed_hosts: ["localhost.localdomain"]
#允许从任意主机进行HTTPS访问,不过需要用户登录认证(用户:elastic;安装时提示的密码:Jg+*c_O-bhFlK3jZvm54)
http.host: 0.0.0.0

二、建立Elasticsearch集群

1. 安装Elasticsearch主节点server1

注意:此处步骤看目录的第一大点所有步骤进行操作: "一、Elasticsearch服务的安装部署";server1的安装,只有其配置文件不同

2. 配置server1,及配置文件的详解

bash 复制代码
[root@localhost elasticsearch]# cat elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
#集群名称
cluster.name: my-es
# ------------------------------------ Node ------------------------------------
#节点名称
node.name: server1
# ----------------------------------- Paths ------------------------------------
#数据存储目录
path.data: /var/lib/elasticsearch

#日志存储目录
path.logs: /var/log/elasticsearch
# ----------------------------------- Memory -----------------------------------
#启动时是否锁定内存资源的占用
bootstrap.memory_lock: true
# ---------------------------------- Network -----------------------------------
#设置为0.0.0.0监听本机所有的接口地址,可在任意主机上使用https://IP:9200进行访问
network.host: 0.0.0.0

#设置Elasticsearch监听端口,默认为9200
http.port: 9200
# --------------------------------- Discovery ----------------------------------
#集群的主机列表,主机IP之间以","隔开
discovery.seed_hosts: ["10.8.109.166","10.8.109.170","10.8.109.171"]

#使用符合主条件的初始节点集引导群集
#cluster.initial_master_nodes: ["node-1", "node-2"]
# ---------------------------------- Various -----------------------------------
# 是否允许通配符删除索引,默认是拒绝
#action.destructive_requires_name: false
# --------------------------------------------------------------------------------
#是否启用安全功能,默认启用
xpack.security.enabled: true
xpack.security.enrollment.enabled: true

#为HTTP API客户端连接(如Kibana、Logstash和Agent)启用加密
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

#启用群集节点之间的加密和相互身份验证
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
  
#指定master节点范围(此处可用主机名,使用主机名时必须能进行DNS解析)
cluster.initial_master_nodes: ["10.8.109.166","10.8.109.170","10.8.109.171"]

#允许从任意主机进行HTTPS访问,不过需要用户登录认证(用户:elastic;安装时提示的密码:Jg+*c_O-bhFlK3jZvm54)
http.host: 0.0.0.0

#允许其他节点通过加密和相互验证加入群集
#transport.host: 0.0.0.0

3. 重启elasticsearch的server1节点

复制代码
[root@localhost elasticsearch]# systemctl restart elasticsearch
[root@localhost elasticsearch]# ss -antlp |grep 9200
LISTEN     0      32768     [::]:9200                  [::]:*                   users:(("java",pid=3736,fd=446))

#访问页面
curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:sz90w5zHSpSohfTp82jv  https://127.0.0.1:9200

1. 安装Elasticsearch主节点server2

注意:此处步骤看目录的第一大点所有步骤进行操作: "一、Elasticsearch服务的安装部署";server2的安装,只有其配置文件不同

2. 配置server2,及配置文件的详解

bash 复制代码
[root@erds-node elasticsearch]# cat elasticsearch.yml
cluster.name: my-es     #集群名需与server1一致
node.name: server2      #本机名称
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 0.0.0.0    #监听本机所有的接口地址
http.port: 9200
discovery.seed_hosts: ["10.8.109.166","10.8.109.170","10.8.109.171"]
cluster.initial_master_nodes: ["10.8.109.166","10.8.109.170","10.8.109.171"]

3. 重启elasticsearch的server2节点

bash 复制代码
[root@localhost elasticsearch]# systemctl restart elasticsearch
[root@localhost elasticsearch]# ss -antlp |grep 9200
LISTEN     0      32768     [::]:9200                  [::]:*                   users:(("java",pid=3736,fd=446))

#访问页面
curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:Jg+*c_O-bhFlK3jZvm54 https://127.0.0.1:9200

1. 安装Elasticsearch主节点server3步骤与server2相同

bash 复制代码
安装完成可输入进行检验:curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:x43LqggxgjpgeHErXY3d https://127.0.0.1:9200

三、 elasticsearch插件的安装

**

相关推荐
Elasticsearch18 小时前
一次编辑,更新所有仪表板:使用 Terraform 大规模管理 Kibana 可观测性配置
elasticsearch
Elasticsearch18 小时前
足够接近就是足够快:ES|QL Fast 模式如何让 Kibana 仪表板速度提升最高 100 倍
elasticsearch
Elasticsearch19 小时前
一分钟内从提示词生成仪表板,成本降低 5 倍:Kibana 中的 AI 仪表板和自定义 Vega-Lite 图表
elasticsearch
雾屿_Mistisle20 小时前
敏感文件泄露
大数据·elasticsearch·搜索引擎
Elasticsearch20 小时前
Elastic 9.5: Columnar 、 VectorDB 索引模式与自动校准,以及由 AI 驱动的告警分类整理
elasticsearch
晚安code20 小时前
一、Elasticsearch查询的 DSL 骨架:先把 JSON 看懂
elasticsearch
XS03010621 小时前
Git远程仓库实操笔记
笔记·git·elasticsearch
love530love21 小时前
Ubuntu系统通过Homebrew安装Lightpanda完整实战教程(含端口占用排坑)
大数据·linux·运维·人工智能·elasticsearch·搜索引擎
Elasticsearch1 天前
将 Embedding 模型加载到 Elasticsearch 中
elasticsearch
Elasticsearch2 天前
使用 Elasticsearch open inference API 对 OpenAI chat completions 进行支持
elasticsearch