CentOS yum 安装 EFK 7.17

这篇具有很好参考价值的文章主要介绍了CentOS yum 安装 EFK 7.17。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

软件 说明
elasticsearch 分布式、高扩展、高实时的搜索与数据分析引擎
kibana 一个基于浏览器的Elasticsearch分析和搜索仪表板
filebeat 收集文件数据
文档 文档链接
elasticsearch 7.17 yum 文档 https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rpm.html
kibana 7.17 yum 文档 https://www.elastic.co/guide/en/kibana/7.17/rpm.html
filebeat 7.17 yum 文档 https://www.elastic.co/guide/en/beats/filebeat/7.17/setup-repositories.html

为何不选择 ELK(Elasticsearch、Logstash、Kibana)?

  • Logstash 占用资源太多,而 Filebeat 是轻量级的,可以忽略不计

说明

  • 为了文档满足所有部署条件及相关限制,故将 elasticsearch、kibana、filebeat 分别安装在三台服务器上

安装过程

  • 在 elasticsearch 所在的服务器上操作

    1. 导入 elasticsearch GPG 密钥
      rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
      
    2. 添加 elasticsearch yum 源
      在 CentOS 中新增文件 /etc/yum.repos.d/elasticsearch.repo
       vi /etc/yum.repos.d/elasticsearch.repo
      
      文件内容:
      [elasticsearch]
      name=Elasticsearch repository for 7.x packages
      baseurl=https://artifacts.elastic.co/packages/7.x/yum
      gpgcheck=1
      gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
      enabled=0
      autorefresh=1
      type=rpm-md
      
    3. 搜索 elasticsearch 版本号
       yum --showduplicates list elasticsearch --enablerepo=elasticsearch
      
       [root@centos7-2009 yum.repos.d]# yum --showduplicates list elasticsearch --enablerepo=elasticsearch
       Loaded plugins: fastestmirror
       Loading mirror speeds from cached hostfile
        * base: mirrors.aliyun.com
        * extras: mirrors.aliyun.com
        * updates: mirrors.huaweicloud.com
       Available Packages
       elasticsearch.x86_64                                                         7.0.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.0.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.1.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.1.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.2.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.2.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.3.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.3.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.3.2-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.4.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.4.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.4.2-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.5.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.5.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.5.2-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.6.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.6.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.6.2-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.7.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.7.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.8.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.8.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.9.0-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.9.1-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.9.2-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.9.3-1                                                          elasticsearch
       elasticsearch.x86_64                                                         7.10.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.10.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.10.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.11.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.11.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.11.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.12.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.12.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.13.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.13.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.13.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.13.3-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.13.4-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.14.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.14.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.14.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.15.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.15.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.15.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.16.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.16.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.16.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.16.3-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.0-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.1-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.2-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.3-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.4-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.5-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.6-1                                                         elasticsearch
       elasticsearch.x86_64                                                         7.17.7-1                                                         elasticsearch
       [root@centos7-2009 yum.repos.d]# 
      
    4. 安装 elasticsearch,由于个版本存在差异,本文以 7.17(当前时间为
      2022-10-28,7.17为主版本7的最新版)为例,为了防止后续主版本7有所更改,导致本文配置无效,故安装时指定版本为 7.17
      sudo yum install -y --enablerepo=elasticsearch elasticsearch-7.17.7-1
      
      [root@centos7-2009 yum.repos.d]# sudo yum install -y --enablerepo=elasticsearch elasticsearch-7.17.7-1
      Loaded plugins: fastestmirror
      Loading mirror speeds from cached hostfile
      * base: mirrors.aliyun.com
      * extras: mirrors.aliyun.com
      * updates: mirrors.huaweicloud.com
        Resolving Dependencies
        --> Running transaction check
        ---> Package elasticsearch.x86_64 0:7.17.7-1 will be installed
        --> Finished Dependency Resolution
      
      Dependencies Resolved
       
      ===========================================================================================================================================================
        Package                                 Arch                             Version                            Repository                               Size
      ===========================================================================================================================================================
      Installing:
      elasticsearch x86_64 7.17.7-1 elasticsearch 300 M
      
      Transaction Summary
      ===========================================================================================================================================================
      Install 1 Package
      
      Total download size: 300 M
      Installed size: 501 M
      Downloading packages:
      elasticsearch-7.17.7-x86_64.rpm | 300 MB 00:00:30     
      Running transaction check
      Running transaction test
      Transaction test succeeded
      Running transaction
      Creating elasticsearch group... OK
      Creating elasticsearch user... OK
      Installing : elasticsearch-7.17.7-1.x86_64 1/1
      ### 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
      Created elasticsearch keystore in /etc/elasticsearch/elasticsearch.keystore
      Verifying  : elasticsearch-7.17.7-1.x86_64 1/1
      
      Installed:
      elasticsearch.x86_64 0:7.17.7-1
      
      Complete!
      [root@centos7-2009 yum.repos.d]#
      
    5. elasticsearch 常用命令
      1. 查看状态
      systemctl status elasticsearch.service
      
      1. 查看开机启动状态
      systemctl list-unit-files | grep elasticsearch.service
      
      1. 启动
      systemctl start elasticsearch.service
      
      1. 停止
      systemctl stop elasticsearch.service
      
      1. 重启
      systemctl restart elasticsearch.service
      
      1. 打开开机自启
      systemctl enable elasticsearch.service
      
      1. 关闭开机自启
      systemctl disable elasticsearch.service
      
    6. 查看状态
      curl 127.0.0.1:9200/_cat/health
      
      如果返回下列信息,表示正常启动:
      [root@centos7-2009 yum.repos.d]# curl 127.0.0.1:9200/_cat/health
      1666948679 09:17:59 elasticsearch green 1 1 3 3 0 0 0 0 - 100.0%
      
    7. elasticsearch 远程访问
      1. 开放端口
      firewall-cmd --zone=public --add-port=9200/tcp --permanent
      firewall-cmd --reload
      firewall-cmd --list-all
      
      1. 修改 /etc/elasticsearch/elasticsearch.yml 文件,使 elasticsearch 可以远程访问:
      vi /etc/elasticsearch/elasticsearch.yml
      
      network.host: 0.0.0.0
      
      1. 修改了远程连接后,需要将下列配置放开(名称可以自己指定),否则启动失败:
      cluster.name: my-application
      node.name: node-1
      cluster.initial_master_nodes: ["node-1"]
      
      1. 重启 elasticsearch
      systemctl restart elasticsearch.service
      
  • 在 kibana 所在的服务器上操作

    1. 导入 kibana GPG 密钥(与 elasticsearch 相同)
    rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
    
    1. 添加 kibana yum 源
      在 CentOS 中新增文件 /etc/yum.repos.d/kibana.repo,文件内容:

      vi /etc/yum.repos.d/kibana.repo 
      
      [kibana-7.x]
      name=Kibana repository for 7.x packages
      baseurl=https://artifacts.elastic.co/packages/7.x/yum
      gpgcheck=1
      gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
      enabled=1
      autorefresh=1
      type=rpm-md
      
    2. 搜索 kibana 版本号

      yum --showduplicates list kibana
      
      [root@centos8 ~]# yum --showduplicates list kibana
      CentOS-8.5.2111 - Base - mirrors.aliyun.com                                                                                 38 kB/s | 3.9 kB     00:00    
      CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                                                               20 kB/s | 1.5 kB     00:00    
      CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                                                            41 kB/s | 4.3 kB     00:00    
      Extra Packages for Enterprise Linux 8 - x86_64                                                                              46 kB/s | 4.7 kB     00:00    
      Kibana repository for 7.x packages                                                                                         8.3 MB/s |  47 MB     00:05    
      Available Packages
      kibana.x86_64                                                              7.0.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.0.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.1.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.1.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.2.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.2.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.3.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.3.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.3.2-1                                                               kibana-7.x
      kibana.x86_64                                                              7.4.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.4.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.4.2-1                                                               kibana-7.x
      kibana.x86_64                                                              7.5.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.5.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.5.2-1                                                               kibana-7.x
      kibana.x86_64                                                              7.6.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.6.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.6.2-1                                                               kibana-7.x
      kibana.x86_64                                                              7.7.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.7.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.8.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.8.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.9.0-1                                                               kibana-7.x
      kibana.x86_64                                                              7.9.1-1                                                               kibana-7.x
      kibana.x86_64                                                              7.9.2-1                                                               kibana-7.x
      kibana.x86_64                                                              7.9.3-1                                                               kibana-7.x
      kibana.x86_64                                                              7.10.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.10.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.10.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.11.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.11.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.11.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.11.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.11.2-1                                                              kibana-7.x
      kibana.x86_64                                                              7.11.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.12.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.12.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.12.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.12.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.13.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.13.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.13.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.13.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.13.2-1                                                              kibana-7.x
      kibana.x86_64                                                              7.13.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.13.3-1                                                              kibana-7.x
      kibana.x86_64                                                              7.13.3-1                                                              kibana-7.x
      kibana.aarch64                                                             7.13.4-1                                                              kibana-7.x
      kibana.x86_64                                                              7.13.4-1                                                              kibana-7.x
      kibana.aarch64                                                             7.14.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.14.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.14.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.14.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.14.2-1                                                              kibana-7.x
      kibana.x86_64                                                              7.14.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.15.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.15.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.15.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.15.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.15.2-1                                                              kibana-7.x
      kibana.x86_64                                                              7.15.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.16.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.16.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.16.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.16.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.16.2-1                                                              kibana-7.x
      kibana.x86_64                                                              7.16.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.16.3-1                                                              kibana-7.x
      kibana.x86_64                                                              7.16.3-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.0-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.0-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.1-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.1-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.2-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.2-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.3-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.3-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.4-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.4-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.5-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.5-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.6-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.6-1                                                              kibana-7.x
      kibana.aarch64                                                             7.17.7-1                                                              kibana-7.x
      kibana.x86_64                                                              7.17.7-1                                                              kibana-7.x
      [root@centos8 ~]#
      
    3. 安装 kibana 7.17.7-1

      sudo yum install -y kibana-7.17.7-1
      

      安装过程

      [root@centos8 ~]# sudo yum install -y kibana-7.17.7-1
      Last metadata expiration check: 0:01:34 ago on Fri 28 Oct 2022 05:45:21 PM CST.
      Dependencies resolved.
      ===========================================================================================================================================================
       Package                            Architecture                       Version                                Repository                              Size
      ===========================================================================================================================================================
      Installing:
       kibana                             x86_64                             7.17.7-1                               kibana-7.x                             256 M
      
      Transaction Summary
      ===========================================================================================================================================================
      Install  1 Package
      
      Total download size: 256 M
      Installed size: 649 M
      Downloading Packages:
      kibana-7.17.7-x86_64.rpm                                                                                                   9.1 MB/s | 256 MB     00:28    
      -----------------------------------------------------------------------------------------------------------------------------------------------------------
      Total                                                                                                                      9.1 MB/s | 256 MB     00:28     
      Running transaction check
      Transaction check succeeded.
      Running transaction test
      Transaction test succeeded.
      Running transaction
        Preparing        :                                                                                                                                   1/1 
        Running scriptlet: kibana-7.17.7-1.x86_64                                                                                                            1/1 
        Installing       : kibana-7.17.7-1.x86_64                                                                                                            1/1 
        Running scriptlet: kibana-7.17.7-1.x86_64                                                                                                            1/1 
      Creating kibana group... OK
      Creating kibana user... OK
      
      Created Kibana keystore in /etc/kibana/kibana.keystore
      
        Verifying        : kibana-7.17.7-1.x86_64                                                                                                            1/1 
      
      Installed:
        kibana-7.17.7-1.x86_64                                                                                                                                   
      
      Complete!
      [root@centos8 ~]# 
      
    4. kibana 常用命令

      1. 查看状态
      systemctl status kibana.service
      
      1. 查看开机启动状态
      systemctl list-unit-files | grep kibana.service
      
      1. 启动
      systemctl start kibana.service
      
      1. 停止
      systemctl stop kibana.service
      
      1. 重启
      systemctl restart kibana.service
      
      1. 打开开机自启
      systemctl enable kibana.service
      
      1. 关闭开机自启
      systemctl disable kibana.service
      
    5. 开放端口

      firewall-cmd --zone=public --add-port=5601/tcp --permanent
      firewall-cmd --reload
      firewall-cmd --list-all
      
    6. 修改 /etc/kibana/kibana.yml 开放远程连接

      vi /etc/kibana/kibana.yml
      
      server.host: "0.0.0.0"
      
    7. 启动

      systemctl start kibana.service
      
    8. 浏览器访问: http://kibana服务的ip:5601
      显示:Kibana server is not ready yet,原因:kibana 未连接到 elasticsearch

    9. 修改 /etc/kibana/kibana.yml,连接到 elasticsearch

      vi /etc/kibana/kibana.yml
      
      elasticsearch.hosts: ["http://elasticsearch服务器的IP:9200"]
      
    10. 重启 kibana

      systemctl restart kibana.service
      
    11. 访问 http://kibana服务的ip:5601 ,正常显示内容,但是内容为英文

    12. 修改 /etc/kibana/kibana.yml,将语言改为中文

      vi /etc/kibana/kibana.yml
      
      i18n.locale: "zh-CN"
      
    13. 重启 kibana

      systemctl restart kibana.service
      
    14. 浏览器访问: http://kibana服务的ip:5601/app/fleet/agents ,可查看到需要开启 xpack.security.enabled
      xpack.security.authc.api_key.enabled

  • 在 elasticsearch 所在的服务器上操作

    1. 修改 /etc/elasticsearch/elasticsearch.yml 文件,启用 xpack.security.enabled
      vi /etc/elasticsearch/elasticsearch.yml
      
      xpack.security.enabled: true
      xpack.security.transport.ssl.enabled: true
      
    2. 重启 elasticsearch
      systemctl restart elasticsearch.service
      
    3. 执行下列命令,自动生成密码
      /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto
      
      保存执行结果
      [root@centos7-2009 yum.repos.d]# /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto
      Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
      The passwords will be randomly generated and printed to the console.
      Please confirm that you would like to continue [y/N]y
      
      
      Changed password for user apm_system
      PASSWORD apm_system = 56NDmS7zsVL17oU5C9kh
      
      Changed password for user kibana_system
      PASSWORD kibana_system = gYZtnvSz5d6Nzy4m1PP5
      
      Changed password for user kibana
      PASSWORD kibana = gYZtnvSz5d6Nzy4m1PP5
      
      Changed password for user logstash_system
      PASSWORD logstash_system = ewnuRmRl4hkmWKOF8src
      
      Changed password for user beats_system
      PASSWORD beats_system = BmqUkhVW48TUYr1Dun9S
      
      Changed password for user remote_monitoring_user
      PASSWORD remote_monitoring_user = SLPxYg42EgKBXejBrRiu
      
      Changed password for user elastic
      PASSWORD elastic = F7M6EklcuAgKIvaMy0JP
      
      [root@centos7-2009 yum.repos.d]# 
      
    4. 访问 127.0.0.1:9200/_cat/health
      其中 ZWxhc3RpYzpGN002RWtsY3VBZ0tJdmFNeTBKUA== 为上述生成的 elastic + 英文冒号 + 密码 计算 Base64 得到的,即:Basic验证
      curl 127.0.0.1:9200/_cat/health --header 'Authorization: Basic ZWxhc3RpYzpGN002RWtsY3VBZ0tJdmFNeTBKUA=='
      
      [root@centos7-2009 yum.repos.d]# curl 127.0.0.1:9200/_cat/health --header 'Authorization: Basic ZWxhc3RpYzpGN002RWtsY3VBZ0tJdmFNeTBKUA=='
      1666952483 10:21:23 elasticsearch green 1 1 10 10 0 0 0 0 - 100.0%
      
  • 在 kibana 所在的服务器上操作

    1. 修改 /etc/kibana/kibana.yml 文件,配置密码,密码是上述生成的
      elasticsearch.username: "kibana_system"
      elasticsearch.password: "gYZtnvSz5d6Nzy4m1PP5"
      
    2. 重启 kibana
      systemctl restart kibana.service
      
    3. 浏览器访问: http://kibana服务的ip:5601 ,提示输入密码,可使用上述生成的密码:elastic/F7M6EklcuAgKIvaMy0JP
    4. 浏览器访问: http://kibana服务的ip:5601/app/fleet/agents ,可查看到 xpack.security.enabled 已配置成功
  • 在 elasticsearch 所在的服务器上操作

    1. 修改 /etc/elasticsearch/elasticsearch.yml 文件,启用 xpack.security.authc.api_key.enabled
      vi /etc/elasticsearch/elasticsearch.yml
      
      xpack.security.authc.api_key.enabled: true
      
    2. 重启 elasticsearch
      systemctl restart elasticsearch.service
      
    3. 浏览器访问: http://kibana服务的ip:5601/app/fleet/agents
      ,即可发现无 xpack.security.enabled、xpack.security.authc.api_key.enabled 提示了,说明已配置完成
  • 在 filebeat 所在的服务器上操作

    1. 导入 filebeat GPG 密钥(与 elasticsearch 相同)

      rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
      
    2. 添加 filebeat yum 源

      vi /etc/yum.repos.d/elastic.repo
      
      [elastic-7.x]
      name=Elastic repository for 7.x packages
      baseurl=https://artifacts.elastic.co/packages/7.x/yum
      gpgcheck=1
      gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
      enabled=1
      autorefresh=1
      type=rpm-md
      
    3. 搜索 filebeat 版本号

      yum --showduplicates list filebeat
      
      [root@dev ~]# yum --showduplicates list filebeat
      已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
      
      This system is not registered with an entitlement server. You can use subscription-manager to register.
      
      Repository base is listed more than once in the configuration
      Repository updates is listed more than once in the configuration
      Repository extras is listed more than once in the configuration
      Repository centosplus is listed more than once in the configuration
      Loading mirror speeds from cached hostfile
      epel/x86_64/metalink                                                                                                  | 8.0 kB  00:00:00     
       * base: mirrors.tuna.tsinghua.edu.cn
       * epel: mirrors.tuna.tsinghua.edu.cn
       * extras: mirrors.bupt.edu.cn
       * updates: mirrors.bupt.edu.cn
      base                                                                                                                  | 3.6 kB  00:00:00     
      docker-ce-stable                                                                                                      | 3.5 kB  00:00:00     
      elastic-7.x                                                                                                           | 1.3 kB  00:00:00     
      epel                                                                                                                  | 4.7 kB  00:00:00     
      extras                                                                                                                | 2.9 kB  00:00:00     
      runner_gitlab-ci-multi-runner/x86_64/signature                                                                        |  862 B  00:00:00     
      runner_gitlab-ci-multi-runner/x86_64/signature                                                                        | 1.0 kB  00:00:00 !!! 
      runner_gitlab-ci-multi-runner-source/signature                                                                        |  862 B  00:00:00     
      runner_gitlab-ci-multi-runner-source/signature                                                                        |  951 B  00:00:00 !!! 
      runner_gitlab-runner/x86_64/signature                                                                                 |  862 B  00:00:00     
      runner_gitlab-runner/x86_64/signature                                                                                 | 1.0 kB  00:00:00 !!! 
      runner_gitlab-runner-source/signature                                                                                 |  862 B  00:00:00     
      runner_gitlab-runner-source/signature                                                                                 |  951 B  00:00:00 !!! 
      updates                                                                                                               | 2.9 kB  00:00:00     
      (1/4): elastic-7.x/primary                                                                                            | 457 kB  00:00:00     
      (2/4): epel/x86_64/group_gz                                                                                           |  98 kB  00:00:00     
      (3/4): epel/x86_64/updateinfo                                                                                         | 1.0 MB  00:00:00     
      (4/4): epel/x86_64/primary_db                                                                                         | 7.0 MB  00:00:00     
      elastic-7.x                                                                                                                        1432/1432
      可安装的软件包
      filebeat.i686                                                       7.0.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.0.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.0.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.0.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.1.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.1.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.1.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.1.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.2.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.2.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.2.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.2.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.3.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.3.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.3.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.3.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.3.2-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.3.2-1                                                       elastic-7.x
      filebeat.i686                                                       7.4.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.4.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.4.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.4.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.4.2-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.4.2-1                                                       elastic-7.x
      filebeat.i686                                                       7.5.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.5.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.5.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.5.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.5.2-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.5.2-1                                                       elastic-7.x
      filebeat.i686                                                       7.6.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.6.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.6.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.6.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.6.2-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.6.2-1                                                       elastic-7.x
      filebeat.i686                                                       7.7.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.7.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.7.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.7.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.8.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.8.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.8.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.8.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.9.0-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.9.0-1                                                       elastic-7.x
      filebeat.i686                                                       7.9.1-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.9.1-1                                                       elastic-7.x
      filebeat.i686                                                       7.9.2-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.9.2-1                                                       elastic-7.x
      filebeat.i686                                                       7.9.3-1                                                       elastic-7.x
      filebeat.x86_64                                                     7.9.3-1                                                       elastic-7.x
      filebeat.i686                                                       7.10.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.10.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.10.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.10.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.10.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.10.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.11.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.11.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.11.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.11.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.11.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.11.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.12.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.12.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.12.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.12.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.13.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.13.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.13.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.13.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.13.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.13.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.13.3-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.13.3-1                                                      elastic-7.x
      filebeat.i686                                                       7.13.4-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.13.4-1                                                      elastic-7.x
      filebeat.i686                                                       7.14.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.14.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.14.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.14.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.14.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.14.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.15.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.15.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.15.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.15.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.15.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.15.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.16.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.16.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.16.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.16.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.16.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.16.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.16.3-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.16.3-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.0-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.0-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.1-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.1-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.2-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.2-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.3-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.3-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.4-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.4-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.5-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.5-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.6-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.6-1                                                      elastic-7.x
      filebeat.i686                                                       7.17.7-1                                                      elastic-7.x
      filebeat.x86_64                                                     7.17.7-1                                                      elastic-7.x
      [root@dev ~]# 
      
    4. 安装 filebeat 7.17.7-1

      sudo yum install -y filebeat-7.17.7-1
      
      [root@dev ~]# sudo yum install -y filebeat-7.17.7-1
      已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
      
      This system is not registered with an entitlement server. You can use subscription-manager to register.
      
      Repository base is listed more than once in the configuration
      Repository updates is listed more than once in the configuration
      Repository extras is listed more than once in the configuration
      Repository centosplus is listed more than once in the configuration
      Loading mirror speeds from cached hostfile
       * base: mirrors.tuna.tsinghua.edu.cn
       * epel: mirrors.tuna.tsinghua.edu.cn
       * extras: mirrors.bupt.edu.cn
       * updates: mirrors.bupt.edu.cn
      正在解决依赖关系
      --> 正在检查事务
      ---> 软件包 filebeat.x86_64.0.7.17.7-1 将被 安装
      --> 解决依赖关系完成
      
      依赖关系解决
      
      =============================================================================================================================================
       Package                          架构                           版本                              源                                   大小
      =============================================================================================================================================
      正在安装:
       filebeat                         x86_64                         7.17.7-1                          elastic-7.x                          33 M
      
      事务概要
      =============================================================================================================================================
      安装  1 软件包
      
      总下载量:33 M
      安装大小:125 M
      Downloading packages:
      filebeat-7.17.7-x86_64.rpm                                                                                            |  33 MB  00:00:06     
      Running transaction check
      Running transaction test
      Transaction test succeeded
      Running transaction
      警告:RPM 数据库已被非 yum 程序修改。
        正在安装    : filebeat-7.17.7-1.x86_64                                                                                                 1/1 
        验证中      : filebeat-7.17.7-1.x86_64                                                                                                 1/1 
      
      已安装:
        filebeat.x86_64 0:7.17.7-1                                                                                                                 
      
      完毕!
      [root@dev ~]# 
      
    5. filebeat 常用命令

      1. 查看状态
        systemctl status filebeat.service
        
      2. 查看开机启动状态
        systemctl list-unit-files | grep filebeat.service
        
      3. 启动
        systemctl start filebeat.service
        
      4. 停止
        systemctl stop filebeat.service
        
      5. 重启
        systemctl restart filebeat.service
        
      6. 打开开机自启
        systemctl enable filebeat.service
        
      7. 关闭开机自启
        systemctl disable filebeat.service
        
    6. 修改 /etc/filebeat/filebeat.yml 文件,让 filebeat 连接到 kibana、elasticsearch

      vi /etc/filebeat/filebeat.yml
      
      setup.kibana:
         host: "kibana服务器IP:5601"
      
      output.elasticsearch:
         hosts: ["elasticsearch服务器IP:9200"]
         username: "elastic"
         password: "F7M6EklcuAgKIvaMy0JP"
      
    7. 查看 filebeat 可收集日志的类型与配置文件

      cd /etc/filebeat/modules.d/
      ll
      
    8. 开启 apache 日志收集(根据自己的需要选择配置)

      sudo filebeat modules enable apache
      

      开启结果

      [root@dev ~]# sudo filebeat modules enable apache
      Enabled apache
      [root@dev ~]# 
      

      配置 apache 日志收集的路径

      vi /etc/filebeat/modules.d/apache.yml
      
       - module: apache
         access:
         enabled: true
         var.paths:
         # 收集日志的路径
             - /logs/*.log
      
    9. 启动 filebeat

      systemctl start filebeat.service
      
    10. 查看日志收集

      tail -f /var/lib/filebeat/registry/filebeat/log.json
      
    11. 浏览器访问网址: http://kibana服务器IP:5601/app/logs/stream ,即可查看到收集的日志文章来源地址https://www.toymoban.com/news/detail-430818.html

到了这里,关于CentOS yum 安装 EFK 7.17的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • centos7 中使用yum方式安装Elasticsearch和kibana

    Elasticsearch 是目前全文搜索引擎的首选。它可以快速地储存、搜索和分析海量数据,在企业内同样是一款应用非常广泛的搜索引擎服务。本教程实现单机centos7安装es和kibana。 浏览器打开:http://ip:9200/?pretty 安装ES时添加yum源中已经包含了kibana,下面直接使用yum安装即可。 浏览

    2024年01月23日
    浏览(53)
  • Centos7快速安装Elasticsearch 7.17.7

    从 Elasticsearch 7.x 版本开始,Elasticsearch 发行版包括了自己的 JDK。因此,您不需要单独安装 Java。以下是在 CentOS 7 上安装 Elasticsearch 7.17.7 的完整步骤:(数据默认保存在/var/lib/elasticsearch下,自行更改) 添加 Elasticsearch 仓库: 首先,创建一个新文件: 然后,将以下内容粘贴到

    2024年02月04日
    浏览(50)
  • 【软件安装教程】elasticsearch7.17安装设置用户名和密码

    链接:https://pan.baidu.com/s/1f3jTc4kaQvu_i9pVbuXdPQ  提取码:l3g1  下载后解压    bin :存入一些二进制脚本,包括启动 ES、安装插件命令等都在这里。 config :存放 ES 的配置文件,主要是 elasticsearch.yml 。 jdk :ES 自带的 Java 环境,所以我们无需自己安装 Java 环境。 lib :存放 ES 相关

    2024年02月13日
    浏览(64)
  • ES7.5升级7.17后在写多读少场景下CPU、IO飙升

    1.ES PAAS管理的集群升级了100+,从7.5升级到7.17 (保证每个大版本最终仅维护一个小版本集群) 2.由于业务使用差异大,也出了不少问题,前面的文章也有提到过Integer类型字段使用terms查询效率低的情况 3.这里再分析一个CPU、IO飙升的场景 1.用户报障:“ES集群写入吞吐量变小了

    2023年04月08日
    浏览(32)
  • 将 CentOS 7 的 YUM 软件源更改为阿里云的镜像源

    你可以按照以下步骤将 CentOS 7 的 YUM 软件源更改为阿里云的镜像源: 先备份原有的 CentOS-Base.repo 文件 下载阿里云的 CentOS 7 的 repo 文件 清除并生成新的缓存 现在你的 CentOS 7 的 yum 软件源应该已经被更改为了阿里云的镜像源,你可以尝试安装或者更新软件包看看是否成功。 这

    2024年02月12日
    浏览(49)
  • centos通过yum安装redis

    1. 安装yum添加epel源(此步根据环境,如果有源则可跳过,在阿里去可跳过) yum install epel-release 2 使用yum安装Redis yum install redis 出现如下图所示的内容,默认的安装路径是在 /usr/bin 目录下:  文件安装路径 该目录以及默认配置到环境变量,因此可以在任意目录下运行这些命令

    2024年01月23日
    浏览(41)
  • CentOS通过yum安装Docker

    要安装Docker Engine,你需要以下CentOS版本中的一个维护版本: CentOS 7 CentOS 8 (stream) CentOS 9 (stream) centos-extras 仓库必须被启用。这个仓库默认是启用的,但如果你已经禁用了它,你需要重新启用它。 旧版本的Docker以 docker 或 docker-engine 为名。在尝试安装新版本之前,请卸载任何此

    2024年02月07日
    浏览(50)
  • Centos下安装yum(完整教程)

    查看已安装的yum 删除已有的yum 下载以下安装包 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下载最新版本 安装 用FIleZillia 上传的服务器的一个目录下 cd /mnt 目录下,执行以下命令: 测试yum: 安装完成!

    2024年02月11日
    浏览(37)
  • CentOS yum安装jdk8

    在CentOS系统中使用 yum 命令安装JDK 8,你可以按照以下步骤操作: 更新系统包 : 在开始安装之前,建议先更新你的系统包,确保使用的是最新的软件包信息。 检查已安装的Java版本(可选) : 如果你不确定系统中是否已有Java安装,可以先检查一下。 卸载已有的Java(如果需要)

    2024年04月27日
    浏览(36)
  • Linux:centos yum安装指令指南

    如果我们在Linux中输入命令发现该命令没有的时候,我们就可以通过yum来安装这个命令 具体分为两步:搜索,安装 首先搜索centos yum 安装 + 指令 以zip指令为例,在搜索框中输入centos yum 安装zip 安装 复制安装命令到shell,直接安装即可

    2024年02月01日
    浏览(46)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包