linux运维知识体系

麒麟系统部署EFK架构

2025/03/25
165
0

🌟ElasticSearch集群部署

📌下载ES软件包(7.17.29)

官网下载:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.29-x86_64.rpm

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.29-x86_64.rpm

🛠️安装ElasticSearch

rpm -ivh elasticsearch-7.17.29-x86_64.rpm

elk191节点安装

elk192节点安装

elk193节点安装

📝修改ElasticSearch的配置文件

1.修改配置文件
vim /etc/elasticsearch/elasticsearch.yml
cluster.name: zhu-cluster
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["10.0.0.191", "10.0.0.192","10.0.0.193"]
cluster.initial_master_nodes: ["10.0.0.191", "10.0.0.192","10.0.0.193"]

2.检查
egrep -v '^#|^$' /etc/elasticsearch/elasticsearch.yml

📝同步配置文件到集群节点

scp /etc/elasticsearch/elasticsearch.yml 10.0.0.192:/etc/elasticsearch/
scp /etc/elasticsearch/elasticsearch.yml 10.0.0.193:/etc/elasticsearch/

🚀启动ES服务

systemctl daemon-reload
systemctl enable elasticsearch.service --now
ss -lntup | egrep "9200|9300"

elk191

elk192

elk193

🔍验证集群状态

http://10.0.0.191:9200/_cat/nodes

🌟Kibana环境部署

🧩下载Kibana(7.17.29)

官网下载:https://artifacts.elastic.co/downloads/kibana/kibana-7.17.29-x86_64.rpm

wget https://artifacts.elastic.co/downloads/kibana/kibana-7.17.29-x86_64.rpm

🎯安装Kibana

rpm -ivh kibana-7.17.29-x86_64.rpm

📝修改Kibana的配置文件

1.修改配置文件
vim /etc/kibana/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://10.0.0.191:9200","http://10.0.0.192:9200","http://10.0.0.193:9200"]
i18n.locale: "zh-CN"

2.检查
egrep -v "^#|^$" /etc/kibana/kibana.yml

🚀启动Kibana服务

systemctl enable --now elasticsearch.service
ss -lntup | grep 5601

🌏浏览器访问

http://10.0.0.191:5601/

🌟Filebeat环境部署

📌下载Filebeat

官方网站:https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.17.29-x86_64.rpm

wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.17.29-x86_64.rpm

🎯安装Filebeat

rpm -ivh filebeat-7.17.29-x86_64.rpm

📝修改Filebeat的配置文件

vim tcp-to-es.yaml
filebeat.inputs:
- type: tcp
  host: "0.0.0.0:9000"

#output.console:
#  pretty: true

# 将数据写入到ES集群
output.elasticsearch:
  # 指定ES集群地址
  hosts: ["http://10.0.0.191:9200","http://10.0.0.192:9200","http://10.0.0.193:9200"]
  # 指定ES的索引名称
  index: filebeat-tcp-xixi

# 禁用索引的生命周期,否则自定义索引名称无效
setup.ilm.enabled: false
# 定义索引模板
setup.template.name: "filebeat-tcp"
# 定义索引模板的匹配模式
setup.template.pattern: "filebeat-tcp*"
# 如果索引模板已经存在是否覆盖
setup.template.overwrite: false
# 配置索引模板
setup.template.settings:
  # 指定分片数量
  index.number_of_shards: 3
  # 指定副本数量
  index.number_of_replicas: 0

🚀启动Filebeat实例

filebeat -e -c /etc/filebeat/config/tcp-to-es.yaml

🔍发送测试数据

echo zhu | nc 10.0.0.192 9000

🛠️Kibana创建索引模式

🔍查看索引(message)