• ELK7.X中配置x-pack


    Elasticsearch:分布式的 RESTful 风格的搜索和数据分析引擎,能够解决不断涌现出的各种用例。作为 Elastic Stack 的核心,它集中存储您的数据,帮助您发现意料之中以及意料之外的情况。

    Kibana:能够以图表的形式呈现数据,并且具有可扩展的用户界面,供您全方位配置和管理 Elastic Stack。

    X-Pack:将诸多强大功能集合到一个单独的程序包中,更将它带上了一个新的层次。
    Elasticsearch配置文件

    transport.host: localhost
    
    transport.tcp.port: 9300
    
    http.port: 9200
    
    network.host: 0.0.0.0
    
    bootstrap.memory_lock: false
    
    bootstrap.system_call_filter: false
    

    运行:./elasticsearch-6.2.4/bin/elasticsearch -d(-d参数是后台启动)
    访问地址:http://localhost:9200/?pretty,这边可以使用chrome的elasticsearch head插件来访问
    在这里插入图片描述

    elasticsearch 7.3使用x-pack kibana登录v

    第一步:切换到elasticsearch的目录下,使用下列命令生成证书

    bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""

    第二步:打开config/elasticsearch.yaml,在尾部添加下面一行代码:

    xpack.security.enabled: true
    xpack.security.transport.ssl.enabled: true
    xpack.security.transport.ssl.verification_mode: certificate
    xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
    xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

    然后启动elasticsearch

    第三步:新打开一个终端,使用cd命令切换到elasticsearch目录,然后使用 bin/elasticsearch-setup-passwords auto 命令自动生成好几个默认用户和密码。 如果想手动生成密码,则使用 bin/elasticsearch-setup-passwords interactive 命令。一般默认会生成好几个管理员账户,其中一个叫elastic的用户是超级管理员。

    [root@cmdb-server bin]# ./elasticsearch-setup-passwords auto
    Initiating the setup of passwords for reserved users elastic,apm_system,kibana,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 = vwMHscFAEtfqTh6hca8f
    
    Changed password for user kibana
    PASSWORD kibana = EFvC6s0tJ5DLQf0khfom
    
    Changed password for user logstash_system
    PASSWORD logstash_system = JOhNQEImNzS7JRDRdZOc
    
    Changed password for user beats_system
    PASSWORD beats_system = Rh3YIxCaaLyoCcA82K6m
    
    Changed password for user remote_monitoring_user
    PASSWORD remote_monitoring_user = FTkrJp5VPSoWiIqVVxKF
    
    Changed password for user elastic
    PASSWORD elastic = yLPivO0kca63PaAjxtQv
    

    第四步:验证一下。打开浏览器,输入我们的elasticsearch的网址,比如本地的http://localhost:9200/ ,然后会弹出一个输入框,让我们输入账号和密码,输入后则可以看到一些介绍。

    5、多节点集群X-Pack安全如何配置?

    最简单的方法,
    假定是初始部署集群阶段。

    步骤1:清空data文件;
    步骤2:将配置好的带证书的文件copy到另一台机器;
    步骤3:根据集群配置ip、角色等信息即可。

    1、X-Pack简介

    X-Pack是一个Elastic Stack的扩展,将安全,警报,监视,报告和图形功能包含在一个易于安装的软件包中。虽然elasticsearch-7.2.1已经全面集成x-pack不需要单独安装,但是自带的x-pack仍然是试用版,所以要想无限期使用全部功能还得破解或购买,本文就x-pcak配置做一个记录。

    首先安装好Elasticsearch、kibana、logstash,本文承接前面的安装文档:

    https://www.cnblogs.com/heyongboke/p/11348325.html   转载

    这里我使用的ELK版本均为7.2.1

    x-pack插件安装顺序:

    1
    2
    3
    4
    5
    (1)ElasticSearch
     
    (2)kibana
     
    (3)logstash

      

    2、elasticsearch配置x-pack

    2.1、elasticsearch-7.2.1开启安全验证配置

    1
    2
    3
    4
    5
    6
    #配置elasticsearch.yml配置文件
    [root@ELK1 config]# vim /home/elk/elasticsearch-7.2.1/config/elasticsearch.yml
     
      
    #加上这条:设置x-pack为开启
    xpack.security.enabled: true

      

    2.2、运行elasticsearch

    1
    2
    3
    [root@ELK1 config]# su - elasticsearch
     
    [elasticsearch@ELK1 ]# /home/elk/elasticsearch-7.2.1/bin/elasticsearch -d

      

    2.3、启用trial license(30天试用) 

    1
    curl -H "Content-Type:application/json" -XPOST http://192.168.3.181:9200/_xpack/license/start_trial?acknowledge=true

      

    2.4、设置密码

    1
    2
    3
    4
    5
    #在elasticsearch-7.2.1/bin/目录下运行elasticsearch-setup-passwords设置密码(账号默认为elastic):
     
    ./elasticsearch-setup-passwords interactive
     
    它会不止是设置elasticsearch,其他的kibana、logstash也会一起设置了,密码最好全设置同一个

      

    2.5、修改密码方式

    1
    curl -H "Content-Type:application/json" -XPOST -u elastic 'http://192.168.3.181:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

      

    3、Kibana的配置x-pack:

    1
    2
    3
    4
    5
    6
    #打开kibana的kibana.yml配置文件:
    [root@ELK1 config]# vim /home/elk/kibana-7.2.1-linux-x86_64/config/kibana.yml
     
    #修改如下配置
    elasticsearch.username: "elastic"
    elasticsearch.password: "123456"

      

    4、logstash配置x-pack:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    #打开自定义的logstash的配置文件logstash.conf,在output中增加elasticsearch的用户名和密码
     
    [root@ELK1 ~]# vim /home/elk/logstash-7.2.1/config/logstash.conf
     
    input {
      beats {
        port => 5044
      }
    }
     
    output {
      stdout {
        codec => rubydebug
      }
      elasticsearch {
        hosts => ["192.168.3.181:9200","192.168.3.182:9200","192.168.3.183:9200"]
        user => "elastic"
        password => "123456"
      }
    }

      

    5、启动

    修改完配置后,启动elk,顺序为:elasticsearch,logstash、kibana。

    登录界面如下图:

  • 相关阅读:
    前端 “一键换肤“ 的 N 种方案及css中var()和:root用法
    给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效
    Python三方模块
    Lazarus+LAMW强制APP屏幕方向
    定制lazarus compiler config
    CentOS8的网络IP配置详解
    mongoDB导入导出
    离线安装docker并导入导出镜像
    Docker初级实战
    dwm 美化
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/13993434.html
Copyright © 2020-2023  润新知