【服务部署】ELFK架构篇之Elasticsearch

文章目录

一、单点部署

1.环境准备

bash 复制代码
系统环境:Ubuntu Server 22.04
服务版本:Elasticsearch 7.17.29

服务下载:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.29-amd64.deb

2.软件包安装

shell 复制代码
[root@elfk01 ~]# dpkg -i elasticsearch-7.17.29-amd64.deb 

3.修改配置文件

shell 复制代码
[root@elfk01 ~]# egrep -v "^.*#|^$" /etc/elasticsearch/elasticsearch.yml 
cluster.name: elfk-single
network.host: 0.0.0.0
discovery.type: single-node

4.启动服务

shell 复制代码
[root@elkf01 ~]# systemctl daemon-reload 
[root@elkf01 ~]# systemctl enable --now elasticsearch.service 
[root@elkf01 ~]# ss -ntl | egrep "92|300"
LISTEN 0      4096               *:9200            *:*          
LISTEN 0      4096               *:9300            *:*          

5.访问测试

shell 复制代码
[root@elfk01 ~]# curl 10.0.0.91:9200
{
  "name" : "elfk01",
  "cluster_name" : "elfk-single",
  "cluster_uuid" : "qrS21bRfSfGdqEIjcSTj3A",
  "version" : {
    "number" : "7.17.29",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "580aff1a0064ce4c93293aaab6fcc55e22c10d1c",
    "build_date" : "2025-06-19T01:37:57.847711500Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.3",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@elfk01 ~]# curl 10.0.0.91:9200/_cat/nodes
10.0.0.91 31 97 14 0.39 0.17 0.06 cdfhilmrstw * elfk01

二、ES集群部署实战

1.停止ES单点

bash 复制代码
[root@elfk01 ~]# systemctl stop elasticsearch.service 
[root@elfk01 ~]# ss -ntl | egrep "92|300"

2.修改配置文件

bash 复制代码
[root@elfk01 ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml 
cluster.name: elfk-cluster
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.seed_hosts: ["10.0.0.91", "10.0.0.92","10.0.0.93"]
cluster.initial_master_nodes: ["10.0.0.91", "10.0.0.92","10.0.0.93"]
#discovery.type: single-node  把单点模式注释掉

3.清理旧数据

bash 复制代码
[root@elfk01 ~]# rm -rf /var/{log,lib}/elasticsearch/*
[root@elfk01 ~]# ll /var/{log,lib}/elasticsearch/
/var/lib/elasticsearch/:
total 8
drwxr-s---  2 elasticsearch elasticsearch 4096 Oct 29 11:36 ./
drwxr-xr-x 61 root          root          4096 Oct 29 10:08 ../
​
/var/log/elasticsearch/:
total 8
drwxr-s---  2 elasticsearch elasticsearch 4096 Oct 29 11:36 ./
drwxrwxr-x 10 root          syslog        4096 Oct 29 10:08 ../

4.分发软件包

bash 复制代码
[root@elfk01 ~]# scp elasticsearch-7.17.29-amd64.deb 10.0.0.92:~
[root@elfk01 ~]# scp elasticsearch-7.17.29-amd64.deb 10.0.0.93:~

5.多节点安装ES服务

bash 复制代码
[root@elfk02 ~]# dpkg -i elasticsearch-7.17.29-amd64.deb 
[root@elfk03 ~]# dpkg -i elasticsearch-7.17.29-amd64.deb 

6.同步配置文件

bash 复制代码
[root@elfk01 ~]# scp /etc/elasticsearch/elasticsearch.yml 10.0.0.92:/etc/elasticsearch/
[root@elfk01 ~]# scp /etc/elasticsearch/elasticsearch.yml 10.0.0.93:/etc/elasticsearch/

7.多节点需同时启动ES服务

bash 复制代码
[root@elfk01 ~]# systemctl enable --now elasticsearch.service
[root@elfk01 ~]# ss -ntl | egrep "92|300"
LISTEN 0      4096               *:9200            *:*          
LISTEN 0      4096               *:9300            *:*          

[root@elfk02 ~]# systemctl enable --now elasticsearch.service 
[root@elfk02 ~]# ss -ntl | egrep "92|300"
LISTEN 0      4096               *:9300            *:*          
LISTEN 0      4096               *:9200            *:*          
​
[root@elfk03 ~]# systemctl enable --now elasticsearch.service 
[root@elfk03 ~]# ss -ntl | egrep "92|300"
LISTEN 0      4096               *:9300            *:*          
LISTEN 0      4096               *:9200            *:*          

8.验证集群状态

bash 复制代码
[root@elfk01 ~]# curl 10.0.0.91:9200/_cat/nodes
10.0.0.92 21 97 12 0.33 0.31 0.14 cdfhilmrstw - elfk02
10.0.0.91 29 97 16 0.31 0.17 0.06 cdfhilmrstw * elfk01
10.0.0.93 23 97 52 0.89 0.34 0.12 cdfhilmrstw - elfk03

[root@elfk01 ~]# curl 10.0.0.92:9200/_cat/nodes
10.0.0.91 29 97  1 0.29 0.17 0.06 cdfhilmrstw * elfk01
10.0.0.93 23 97 50 0.90 0.36 0.13 cdfhilmrstw - elfk03
10.0.0.92 22 97  1 0.30 0.31 0.14 cdfhilmrstw - elfk02

[root@elfk01 ~]# curl 10.0.0.93:9200/_cat/nodes
10.0.0.93 23 97 55 0.90 0.36 0.13 cdfhilmrstw - elfk03
10.0.0.92 22 97  4 0.30 0.31 0.14 cdfhilmrstw - elfk02
10.0.0.91 29 97  0 0.29 0.17 0.06 cdfhilmrstw * elfk01

[root@elfk01 ~]# curl 10.0.0.93:9200
{
  "name" : "elfk03",
  "cluster_name" : "elfk-cluster",
  "cluster_uuid" : "Gcu4sGGlTO25jN2uTPjcHg",
  "version" : {
    "number" : "7.17.29",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "580aff1a0064ce4c93293aaab6fcc55e22c10d1c",
    "build_date" : "2025-06-19T01:37:57.847711500Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.3",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

下期分享:Kibana服务部署

相关推荐
艾莉丝努力练剑20 小时前
【Linux线程】Linux系统多线程(九):线程池实现(附代码示例)
linux·运维·服务器·c++·学习·架构
2301_7807896620 小时前
游戏盾是如何防护各个重要的游戏端口呢
服务器·网络·人工智能·游戏·架构·零信任
小江的记录本1 天前
【分布式】分布式核心组件——分布式锁:Redis/ZooKeeper/etcd 实现方案(附全方位对比表)、优缺点、Redlock、时钟回拨问题
java·网络·redis·分布式·后端·zookeeper·架构
小江的记录本1 天前
【分布式】分布式核心组件——分布式ID生成:雪花算法、号段模式、美团Leaf、百度UidGenerator、时钟回拨解决方案
分布式·后端·算法·缓存·性能优化·架构·系统架构
南棱笑笑生1 天前
20260420给万象奥科的开发板HD-RK3576-PI适配瑞芯微原厂的Buildroot时调通AP6256并实测网速109Mbits/sec
大数据·elasticsearch·搜索引擎·rockchip
HTTP帕克猴子1 天前
为什么现代网站越来越依赖“中间层架构”?
架构
Elastic 中国社区官方博客1 天前
Elasticsearch:使用 Agent Builder 的 A2A 实现 - 开发者的圣诞颂歌
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
懂懂tty1 天前
CRA 迁移 Rspack(实战)
前端·架构
历程里程碑1 天前
2. Git版本回退全攻略:轻松掌握代码时光机
大数据·c++·git·elasticsearch·搜索引擎·github·全文检索
小程故事多_801 天前
破除迷思,Harness Engineering从来都不是时代过渡品
人工智能·架构·prompt·aigc