• 企业运维实战 ELK日志分析平台 Kinaba (Kibana安装、Kinaba安全认证、Kinaba监测)


    企业运维实战 ELK日志分析平台 Kinaba (Kibana安装、Kinaba安全认证、Kinaba监测)
    kibana数据可视化
    kibana的安装和配置
    kibana的使用
    启用xpack安全验证
    创建认证
    设置kibana连接ES的用户密码
    设置Logstash连接ES用户密码
    elasticsearch-head访问
    Metricbeat
    Filebeat
    我们在server4上进行安装kibana,并连接上elasticsearch和logstash

    kibana的安装和配置
    下载地址:https://elasticsearch.cn/download/\

    kibana安装

    rpm -ivh kibana-7.6.1-x86_64.rpmvim /etc/kibana/kibana.yml
    2 server.port: 5601
    7 server.host: “172.25.21.4”
    28 elasticsearch.hosts: [“http://172.25.21.1:9200”]
    37 kibana.index: “.kibana”
    115 i18n.locale: “zh-CN”

    启动并设置开机自启动
    systemctl enable --now kibana

    此时可以看到已经打开5601端口
    netstat -antlp|grep :5601

    kibana的使用
    选择自己浏览

    输入一个你在elasticsearch里面已经建立好的索引
    ps:需要在logstash主机后台运行这apachelog这个索引的监控
    选择时间戳

    创建成功

    创建可视化
    选择指标

    选择刚刚创建的索引(源)

    选择一个时间段

    此时可以看到在此时间段访问的次数

    压力测试
    ab -n 10 -c1 http://172.25.21.4/index.html

    可以看到计数已经改变

    保存这个可视化

    再次创建一个可视化

    还是选择刚刚那个索引

    加入x轴,设置ip访问量排行

    保存可视化

    新建仪表板

    添加刚刚创建的可视化

    保存仪表板
    启用xpack安全验证
    进入到监测,可以看到缺少xpack安全认证

    创建认证
    集群模式需要先创建证书:

    cd /usr/share/elasticsearch/
    bin/elasticsearch-certutil ca
    cp elastic-certificates.p12 /etc/elasticsearch
    cd /etc/elasticsearch
    chown elasticsearch elastic-certificates.p12
    将创建好的证书传给集群其他节点
    scp elastic-certificates.p12 server2:/etc/elasticsearch
    scp elastic-certificates.p12 server3:/etc/elasticsearch
    并且在其他节点也修改证书权限
    chown elasticsearch /etc/elasticsearch/elastic-certificates.p12
    配置所有的elasticsearch集群节点
    vim /etc/elasticsearch/elasticsearch.yml

    xpack.security.enabled: true
    xpack.security.transport.ssl.enabled: true
    xpack.security.transport.ssl.verification_mode: certificate
    xpack.security.transport.ssl.keystore.path: /etc/elasticsearch/elastic-certificates.p12
    xpack.security.transport.ssl.truststore.path: /etc/elasticsearch/elastic-certificates.p12
    然后所有节点重启elasticsearch
    systemctl restart elasticsearch
    1
    此时可以看到elasticsearch-head已经无法连接elasticsearch

    kibana需要登陆

    为启动了认证,ES集群重启正常后,要设置用户密码
    /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

    设置kibana连接ES的用户密码
    vim /etc/kibana/kibana.yml

    把密码改成刚才自己设置的密码

    重启服务
    systemctl restart kibana
    1
    可以使用elastic用户登录,权限更大

    设置Logstash连接ES用户密码
    在elasticsearch模块里面加入账户密码

    应用这个文件连接es
    /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/grok.conf
    1
    其他主机做压力测试,生成日志
    ab -n 10 -c 1 http://172.25.21.1/index.html
    可以看到在logstash已经上传日志到es上

    elasticsearch-head访问
    添加参数到es配置
    vim /etc/elasticsearch/elasticsearch.yml

    http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
    1

    重启服务
    systemctl restart elasticsearch
    1
    访问时候要在地址后面加入参数
    http://172.25.21.1:9100/?auth_user=elastic&auth_password=westos
    1
    此时可以看到已经连接成功

    Metricbeat
    再次进入到kibana的监测数据,选择使用内部收集设置

    进入设置模式,然后选择节点点击使用Metricbeat监测

    写入一个集群中的一个地址

    本来这个监测节点需要另起虚拟机,但是由于内存的原因,我们这里还是用server1-3来监测,使用自己监测自己,在实际生产环境中不建议这么使用

    在server1-3上

    在安装 Elasticsearch 的同一台服务器上安装 Metricbeat

    rpm -ivh metricbeat-7.6.1-x86_64.rpm
    在 Metricbeat 中启用并配置 Elasticsearch x-pack 模块

    metricbeat modules enable elasticsearch-xpack
    vim /etc/metricbeat/modules.d/elasticsearch-xpack.yml
    1
    2
    修改自己的hosts和用户密码

    配置 Metricbeat 以发送至监测集群
    vim /etc/metricbeat/metricbeat.yml
    1
    修改监测集群的hosts和用户密码

    启动设置开机自启动
    systemctl enable --now metricbeat
    1
    此时迁移状态自动变更,点击完成即可

    节点都部署完成后,选择禁用内部收集

    Filebeat

    在安装 Elasticsearch 的同一台服务器上安装 Filebeat
    rpm -ivh filebeat-7.6.1-x86_64.rpm
    1
    在 Filebeat 中启用并配置 elasticsearch 模块

    filebeat modules enable elasticsearch
    vim /etc/filebeat/modules.d/elasticsearch.yml
    1
    2
    修改var.paths

    server:
    enabled: true

    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths:
      - /var/log/elasticsearch/*.log
      - /var/log/elasticsearch/*_server.json
    
    • 1
    • 2
    • 3
    • 4
    • 5

    gc:
    enabled: true
    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths:
    - /var/log/elasticsearch/gc.log.[0-9]*
    - /var/log/elasticsearch/gc.log

    audit:
    enabled: true
    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths:
    - /var/log/elasticsearch/_access.log
    - /var/log/elasticsearch/
    _audit.json

    slowlog:
    enabled: true
    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths:
    - /var/log/elasticsearch/_index_search_slowlog.log
    - /var/log/elasticsearch/
    _index_indexing_slowlog.log
    - /var/log/elasticsearch/_index_search_slowlog.json
    - /var/log/elasticsearch/
    _index_indexing_slowlog.json

    deprecation:
    enabled: true
    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths:
    - /var/log/elasticsearch/_deprecation.log
    - /var/log/elasticsearch/
    _deprecation.json
    配置 Filebeat 以发送至监测集群
    vim /etc/filebeat/filebeat.yml
    修改监测集群的hosts和用户密码

    此时在节点处可以看到最近日志,点击左下角可以看详情日志

  • 相关阅读:
    Failed to start MySQL Community Server in Ubuntu
    mybatis-plus分页查询(springboot中实现单表和多表查询)
    linux shell求和计算脚本
    672.灯泡开关2|数学推理|6个周期|影响开关
    2023年【四川省安全员A证】复审考试及四川省安全员A证考试试题
    一文了解JavaScript 中数组所有API的使用
    当用Kiel打开代码时,电脑显示只读
    【zookeeper】zookeeper集群安装
    LeetCode第 310 场周赛
    UNIAPP之js/nvue混淆探索
  • 原文地址:https://blog.csdn.net/qq_44912603/article/details/126280966