Centos 7.9 安装 ELK8.1.0+MetricBeat

article/2025/10/7 22:23:04

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

目录

环境

一、前期准备:

1.下载ELK+MetircBeat rpm包 

2.CentOS 设置 

二、安装Elasticsearch

1.安装rpm

2.配置Elasticsearch

修改配置档

开防火墙

设置账号 

 开启Elasticsearch

 2.验证Elasticsearch

三、安装Kibana

1.安装rpm

2.配置

启动Kibana

无浏览器操作

3.初始化Kibana

4.加载样例数据

四、安装MetricBeat

1.官方流程

2.安装RPM

3.配置

4.启动MetricBeat

五、遇到过的问题

1.Kibana

取token报错 

Kibana Server is not ready yet and Unable to retrieve version information from Elasticsearch nodes. self signed certificate in certificate chain

2.MetricBeat

Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at https://192.168.50.101:9200: Get "https://192.168.50.101:9200": x509: certificate signed by unknown authority]

配置ssl.ca_trusted_fingerprint问题 Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at https://192.168.50.101:9200: Get "https://192.168.50.101:9200": decode 'ca_trusted_fingerprint': encoding/hex: invalid byte: U+003A ':']

总结


环境

Hyper-V + CentOS 7.9

系统:CentOS 7.9 

        下载URL:CentOS Mirrors List

虚拟机:Hyper-V

        开启方式:开始菜单->启用或关闭Windows功能->Hyper-V

        如果无法开启需要根据CPU修改BIOS

        


一、前期准备:

1.下载ELK+MetircBeat rpm包 

注意:版本一定要一致,否则平添烦恼

ElasticSearch:Elasticsearch 8.1.0 | Elastichttps://www.elastic.co/cn/downloads/past-releases/elasticsearch-8-1-0

Kibana:Kibana 8.1.0 | Elastichttps://www.elastic.co/cn/downloads/past-releases/kibana-8-1-0

Logstash:Logstash 8.1.0 | Elastichttps://www.elastic.co/cn/downloads/past-releases/logstash-8-1-0

FileBeat:Filebeat 8.1.0 | Elastichttps://www.elastic.co/cn/downloads/past-releases/filebeat-8-1-0

MetricBeat:Metricbeat 8.1.0 | Elastichttps://www.elastic.co/cn/downloads/past-releases/metricbeat-8-1-0选择RPM X86_64,下载后把安装包拷到机器里   

2.CentOS 设置 

vi /etc/sysctl.conf

在末尾加上

vm.max_map_count=262144


二、安装Elasticsearch

1.安装rpm

rpm -ivh elasticsearch-8.1.0-x86_64.rpm

 安装完成,执行命令:

systemctl enable elasticsearch #设为开机启动

2.配置Elasticsearch

修改配置档

vi /etc/elasticsearch/elasticsearch.yml

 需要修改的内容:

# 集群名,17行 
cluster.name: my-es
# node名,23行 
node.name: node-1 
# 数据目录,33行 
path.data: /root/data/elasticsearch/data 
# 日志目录,37行 
path.logs: /var/log/elasticsearch 
# 配置IP,55行 
network.host: 192.168.50.101 
# 配置站点端口,59行 
http.port: 9200 

标准如下

开防火墙

9200、9300是es server;5601是kibana

firewall-cmd --permanent --add-port={9200/tcp,9300/tcp,5601/tcp} 
firewall-cmd --reload

效果: 

设置账号 

cd /usr/share/elasticsearch/bin
./elasticsearch-users useradd fbguo -r superuser

 然后输入两次密码,效果:

 重置elastic(内置超级用户账号)

./elasticsearch-reset-password -u elastic

 效果

 

 开启Elasticsearch

systemctl start elasticsearch

 2.验证Elasticsearch

访问https://192.168.50.101:9200  注意是https

提示登录,使用刚刚创建的账号

 

成功

此时建议使用Hyper-V 设置检查点,以免之后操作错了不能roll-back


 

三、安装Kibana

1.安装rpm

rpm -ivh kibana-8.1.0-x86_64.rpm

效果: 

 设置开机启动

systemctl enable kibana.service

2.配置

启动Kibana

systemctl start kibana.service

查看状态

systemctl status kibana.service

如果有浏览器的机器可以按上图所说直接访问提供的网页进行初始化

本机是:http://localhost:5601/?code=484550

没有浏览器的执行下面的步骤

无浏览器操作

关闭kibana

systemctl stop kibana.service

修改配置档 

vi /etc/kibana/kibana.yml

需要修改的内容:

# 站点端口号 
server.port: 5601 
# 站点IP地址
server.host: "192.168.50.101“
#节点名
server.name: "my-kibana"
# 语言显示为中文
i18n.locale: "zh-CN“

效果图:

 

 开启kibana

systemctl start kibana.service

3.初始化Kibana

浏览器访问http://192.168.50.101:5601

 申请配置令牌

cd /usr/share/elasticsearch/bin
./elasticsearch-create-enrollment-token -s kibana --url "https://192.168.50.101:9200"

效果:

复制到浏览器

 提示需要验证码

 获取验证码

cd /usr/share/kibana/bin
./kibana-verification-code

效果

 

等待自动配置


 提示登录,使用自己申请的账号,本机是:fbguo

 成功

解决publicBaseUrl,我目前不解决好像也没遇到问题

解决方法是将kibana.yml中server.publicBaseUrl改成当前访问的地址,不以/结尾 

4.加载样例数据

点击添加集成

 

 三个都添加上

 点击左侧的Discover和Dashboard就可以查看了

 


 

四、安装MetricBeat

1.官方流程

先在集成搜索System

 

 点系统指标

这时候其实网页就会给一个设置流程,选RPM就可以,接下来可以参考官方的和我的流程

2.安装RPM

 rpm -ivh metricbeat-8.1.0-x86_64.rpm

效果

 设置开机启动

systemctl enable metricbeat.service

3.配置

修改配置档

vi /etc/metricbeat/metricbeat.yml

修改内容

setup.kibana:host: "192.168.50.101:5601"
output.elasticsearch:hosts: ["192.168.50.101:9200"]  protocol: "https"username: "fbguo"password: "xxxxxx"ssl.certificate_authorities: "/etc/elasticsearch/certs/http_ca.crt"

效果

 

PS:这里username官方提示使用elastic,但是那个密码是自动生成的记不住,我就用自己申请的账号了,官方用的是ssl.ca_trusted_fingerprint,这个我也试过,但是总是报错,我会放到最下面供大家看一下,我这里用的是ssl.certificate_authorities,如果别的机器要用metricbeat,请将这个certs一起复制过去

 

Update:后续解决了ssl.ca_trusted_fingerprint的问题

获取fingerprint

openssl x509 -fingerprint -sha256 -in /etc/elasticsearch/certs/http_ca.crt

效果

上面的Fingerprintj就是我们需要的东西,记得一定要把“:”去掉 

我的就是:C7CB98E26461C79530D9E2E3E6BD4C64347550F45CB51C9F0B06BB8CC87F15CD

 填到metricbeat.yml里

vi /etc/metricbeat/metricbeat.yml
setup.kibana:host: "192.168.50.101:5601"
output.elasticsearch:hosts: ["192.168.50.101:9200"]  protocol: "https"username: "fbguo"password: "xxxxxx"ssl.ca_trusted_fingerprint: "C7CB98E26461C79530D9E2E3E6BD4C64347550F45CB51C9F0B06BB8CC87F15CD"

效果图:

 

启用SYSTEM模块 

metricbeat modules enable system

也可以修改一下SYSTEM抓取的内容

vi /etc/metricbeat/modules.d/system.yml

我的效果:

 

4.启动MetricBeat

metricbeat setup #初次添加这个Metricbeat模块需要使用这个命令,后面加新机器就不需要了
service metricbeat start #启动

效果

 点击浏览器的检查数据

 成功

 点击系统指标仪表盘

 大盘

 点击单台机

 扩展到其他机器只需要安装MetricBeat,复制本机的elasticsearch/certs,编写metricbeat.yml即可

 


五、遇到过的问题

1.Kibana

取token报错 

ERROR: Failed to determine the health of the cluster. Unexpected http status [503]

根源:我是因为配置kibana.yml时候没配置server.name才出现的

解法:配置kibana.yml 的server.name

           网上也有说把elasticsearch.yml添加discovery.type: single-node,这个没试过

Kibana Server is not ready yet and Unable to retrieve version information from Elasticsearch nodes. self signed certificate in certificate chain

这个要分情况,systemctl status kibana -l 先看一下

 可以看到有个ERROR:

5月 24 14:43:48 localhost.localdomain kibana[5142]: [2022-05-24T14:43:48.012+08:00][ERROR][elasticsearch-service] Unable to retrieve version information from Elasticsearch nodes. self signed certificate in certificate chain
根源:我这边遇到这个问题是因为kibana.yml配多, 只需要配置server.port,server.host,server.name和中文就好,多配了别的就会有这个问题,ELK8.x应该是希望到网页端去配置,比如这个就是多配了elasticsearch.hosts: ["https://192.168.50.101:9200"]

解法:按我的这个配置server.port,server.host,server.name和中文即可,别多配

2.MetricBeat

Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at https://192.168.50.101:9200: Get "https://192.168.50.101:9200": x509: certificate signed by unknown authority]

根源:我的情况是metricbeat.yml 关于ssl的安全验证什么都没配(ssl.ca_trusted_fingerprint和ssl.certificate_authorities)

解法:我是配ssl.certificate_authorities解决的

配置ssl.ca_trusted_fingerprint问题 Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at https://192.168.50.101:9200: Get "https://192.168.50.101:9200": decode 'ca_trusted_fingerprint': encoding/hex: invalid byte: U+003A ':']

这个是通过下行命令配的

openssl x509 -fingerprint -sha256 -in /etc/elasticsearch/certs/http_ca.crt

效果:

然后我将fingerprint配到metricbeat.yml里

 就会报错

Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at https://192.168.50.101:9200: Get "https://192.168.50.101:9200": decode 'ca_trusted_fingerprint': encoding/hex: invalid byte: U+003A ':']

解法:我就改成配ssl.certificate_authorities

Update:我发现fingerprint的问题了要把“:”去掉:我这台就应该是C7CB98E26461C79530D9E2E3E6BD4C64347550F45CB51C9F0B06BB8CC87F15CD


 

总结

后续会在另一台机器上装Logstash和FileBeat


http://chatgpt.dhexx.cn/article/8cY2Pk0N.shtml

相关文章

Storm Metric

storm从0.9.0开始,增加了指标统计框架,用来收集应用程序的特定指标,并将其输出到外部系统。 本文中采用的监听类是LoggingMetricsConsumer,统计指标值将输出到metric.log日志文件中。 当然也可以自定义监听类,只需要实…

Beats:如何启动 Metricbeat 中的 MySQL 模块 - query Metricset

在我做之前的教程 “Observability:Elastic Metrics 应用介绍”,我发现当我尝试启动 MySQL 模块中的 query metricset 会出现错误。之后我发现官方文档也缺少相应的资料。在今天的文章中,我将介绍如上启动这个 metricset。在使用这个 metrics…

Metricbeat源码分析

0X00 版本信息 Golang:1.16.8 Metricbeat:7.14 0X01 Metricbeat介绍 Metricbeat quick start: installation and configuration | Metricbeat Reference [7.14] | Elastichttps://www.elastic.co/guide/en/beats/metricbeat/7.14/metricbeat-install…

Elk-Metricbeat配置Tomcat的日志分析 (Metricbeat-part3)

1, 安装软件 Metricbeat安装 请参考之前的文档链接: Metricbeat 8.4.0 linux 安装(Metricbeat-part1)_yangkei的博客-CSDN博客Metricbeat 能够以一种轻量型的方式,输送各种系统和服务统计数据,从 CPU 到内存,从 Redis 到 Nginx…

Metricbeat config file metricbeat.yml must be owned by the user identifier (uid=0) or root

Linux 上修改呢metricbeat.yml的权限,启动的时候报错。查了下解决方案 记录下 https://www.elastic.co/guide/en/beats/libbeat/5.3/config-file-permissions.html#config-file-permissions 简而言之就是所有者必须是root,然后权限必须是0644 sudo c…

Elk-Metricbeat配置Nginx的日志分析 (Metricbeat-part2)

1 情况说明: Metricbeat的基本安装部分可以参考: Metricbeat 8.4.0 linux 安装(Metricbeat-part1)_yangkei的博客-CSDN博客 下面来聊聊如何通过elkmetricbeat来监控Nginx日志。 借用网上以为大师的图就是这样子 Metricbeat 采集 Nginx 指标_叶康铭的…

metricbeat收集elasticsearch、kibana监控数据

一、kibana 1、下载metricbeat并部署到kibana所在的服务器 2、禁用 Kibana 监控指标的默认集合,在kibana.yml文件中增加如下配置: monitoring.kibana.collection.enabled: false3、从控制台或命令行,在生产集群上设置xpack.monitoring.col…

ELK日志采集平台(四)---轻量级采集工具metricbeat

目录 一、安装metricbeat 二、与kibana数据可视化联用 logstash是负责采集数据的,是入口,流向为logstash-> ES->kibana,但是它的资源消耗很大,有时候没那么多内存给他占用,同时有些定制的采集指标logstash无法…

Metricbeat安装下载,nginx模块使用

目录 MetricbeatMetricbeat组成下载启动Metricbeat Modulesystem module配置内容 Nginx Module开启Nginx Module 配置nginx module测试 Metricbeat 定期收集操作系统或应用服务的指标数据存储到Elasticsearch中,进行实时分析 Metricbeat组成 Metricbeat有2部分组成…

metricbeat对接kafka

在监控系统中经常用到kafka来处理数据,上层平台会从kafka直接取数据进行分析,今天分享下metricbeat监控的数据如何输出到kafka中,并对各配置项进行详细说明。 metricbeat环境搭建点这里 kafka环境搭建点这里 -在metricbeat配置文件中配置o…

Beats:通过 Metricbeat 实现外部对 Elastic Stack 的监控

自 Elastic 7.5 发布开始,通过外部监控 Elastic Stack 已经全面实施。 可以通过 Metricbeat 模块监视 Elasticsearch,Kibana,Logstash,APM 服务器和 Beats。 使用外部收集,用户现在可以收集和发送其 Elastic Stack 的…

Metricbeat 的使用

目标 统计并展示系统的信息 cpu, 内存等 (当然metricbeat能收集的信息种类还很多) 前提 版本: 5.x已经安装了ELK (elasticsearch, logstash (可选), kibana)安装了x-pack (配置了对应的security)(可选&a…

Metricbeat 8.4.0 linux 安装(Metricbeat-part1)

Metricbeat是一款轻量型指标采集器,用于从系统和服务收集指标。Metricbeat 能够以一种轻量型的方式,输送各种系统和服务统计数据,从 CPU 到内存,从 Redis 到 Nginx,不一而足。将 Metricbeat 部署到您的所有 Linux、Win…

Metricbeat部署指南

官网下载metricbeat,https://www.elastic.co/downloads/beats/metricbeat。 解压tar包,tar -zxvf metricbeat-7.0.0-linux-x86_64.tar.gz。 进入目录,cd metricbeat-7.0.0-linux-x86_64。 编辑metricbeat配置文件metricbeat.yml&#xff1…

metricbeat的基本使用

文章目录 概述metricbeat安装metricbeat启动案例举例1:收集系统运行的指标数据至es举例2:收集es运行的指标数据至es 概述 定期收集操作系统或应用服务的指标数据存储到Elasticsearch中,进行实时分析 metricbeat安装 去下载页下载&#xff…

Metricbeat安装与初级使用

metricbeat作用: 将 Metricbeat 部署到您所有的 Linux、Windows 和 Mac 主机,并将它连接到 Elasticsearch 就大功告成啦:您可以获取系统级的 CPU 使用率、内存、文件系统、磁盘 IO 和网络 IO 统计数据,以及获得如同系统上 top 命令…

Metricbeat和Filebeat的安装及配置

Beats的安装及配置 一、Metricbeat的安装配置 环境准备 下载与es同版本的metricbeat,这里为 metricbeat-7.11.1-linux-x86_64.tar.gz 这里使用root用户进行配置及启动metricbeat 已启动对应的ES服务及Kibana服务 metricbeat的安装 这里在/路径下建立beats文件…

windows安装wget

1、下载地址:http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe 2、双击下载的exe,同意协议,更改安装安装目录。 其余默认安装,继续下一步,安装完成 3、设置系统环境变量 添加path变量:…

手动编译源代码安装wget

从wget的源代码入手,来完成wget在Ubuntu上的安装,如果你的机器上已经默认安装了wget,请采用apt-get remove命令先卸载掉。 解决configure: error: –with-ssl was given, but GNUTLS/SSL is not available.;解决error: ./stdio.h…

win10安装wget,从此可以更快的下载文件 and windows10 下 zip命令行参数详解

1.win10安装wget 1.1安装下载 GNU Wget 1.21.3 for Windows 依次如下: 2、将下载好的wget.exe放到 C:/windows/system32文件夹下 也可以自行放置文件,添加到系统路径即可 第三步:配置系统环境变量(如下)电脑-属性…