Elastic stack8.10.4搭建、启用安全认证,启用https,TLS,SSL 安全配置详解

这篇具有很好参考价值的文章主要介绍了Elastic stack8.10.4搭建、启用安全认证,启用https,TLS,SSL 安全配置详解。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

ELK大家应该很了解了,废话不多说开始部署

kafka在其中作为消息队列解耦和让logstash高可用

kafka和zk 的安装可以参考这篇文章

深入理解Kafka3.6.0的核心概念,搭建与使用-CSDN博客

第一步、官网下载安装包

需要

elasticsearch-8.10.4

logstash-8.10.4

kibana-8.10.4

kafka_2.13-3.6.0

apache-zookeeper-3.9.1-bin.tar

filebeat-8.10.4-linux-x86_64.tar

第二步: 环境配置(每一台都做)

创建es用户
 

useradd es

配置主机名、配置IP地址、每台主机配置/etc/hosts名称解析

192.168.1.1 es1

192.168.1.2 es2

192.168.1.3 es3

将Linux系统的软硬限制最大文件数改为65536,将所有用户的最大线程数修改为65536

打开/etc/security/limits.conf文件,添加以下配置(每一台都做)

vim  /etc/security/limits.conf


* soft nofile 65536
* hard nofile 65536

* soft nproc 65536
* hard nproc 65536


es  hard   core    unlimited  #打开生成Core文件
es  soft   core    unlimited
es  soft   memlock unlimited #允许用户锁定内存
es  hard   memlock unlimited



soft  xxx  : 代表警告的设定,可以超过这个设定值,但是超过后会有警告。
hard  xxx  : 代表严格的设定,不允许超过这个设定的值。
nproc  : 是操作系统级别对每个用户创建的进程数的限制
nofile : 是每个进程可以打开的文件数的限制
soft nproc :单个用户可用的最大进程数量(超过会警告);
hard nproc:单个用户可用的最大进程数量(超过会报错);
soft nofile  :可打开的文件描述符的最大数(超过会警告);
hard nofile :可打开的文件描述符的最大数(超过会报错);

修改/etc/sysctl.conf文件,添加下面这行,并执行命令sysctl  -p使其生效

vim /etc/sysctl.conf

vm.max_map_count=262144  #限制一个进程可以拥有的VMA(虚拟内存区域)的数量,es要求最低65536
net.ipv4.tcp_retries2=5 #数据重传次数超过 tcp_retries2 会直接放弃重传,关闭 TCP 流

解压安装包,进入config文件夹,修改elasticsearch.yml 配置文件 

cluster.name: elk #集群名称
node.name: node1 #节点名称
node.roles: [ master,data ] #节点角色
node.attr.rack: r1  #机架位置,一般没啥意义这个配置
path.data: /data/esdata  
path.logs: /data/eslog
bootstrap.memory_lock: true  #允许锁定内存
network.host: 0.0.0.0 
http.max_content_length: 200mb
network.tcp.keep_alive: true
network.tcp.no_delay: true
http.port: 9200
http.cors.enabled: true #允许http跨域访问,es_head插件必须开启
http.cors.allow-origin: "*"  #允许http跨域访问,es_head插件必须开启
discovery.seed_hosts: ["ypd-dmcp-log01", "ypd-dmcp-log02"]
cluster.initial_master_nodes: ["ypd-dmcp-log01", "ypd-dmcp-log02"]
xpack.monitoring.collection.enabled: true #添加这个配置以后在kibana中才会显示联机状态,否则会显示脱机状态
xpack.security.enabled: true
#xpack.security.enrollment.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: elastic-certificates.p12  #我把文件都放在config下。所以直接写文件名,放在别处需要写路径
xpack.security.http.ssl.truststore.path: elastic-certificates.p12
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12k
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

配置jvm内存大小 

修改 jvm.options
-Xms6g #你服务器内存的一半,最高32G
-Xmx6g #你服务器内存的一半,最高32G

改好文件夹准备生成相关key

 创建ca证书,什么也不用输入,两次回车即可(会在当前目录生成名为elastic-stack-ca.p12的证书文件)

bin/elasticsearch-certutil  ca

 使用之前生成的ca证书创建节点证书,过程三次回车,会在当前目录生成一个名为elastic-certificates.p12的文件

 

bin/elasticsearch-certutil  cert --ca elastic-stack-ca.p12

 生成http证书,根据提示信息进行操作,主要是下面几步

bin/elasticsearch-certutil http

Generate a CSR? [y/N]n
Use an existing CA? [y/N]y
CA Path: /usr/local/elasticsearch-8.10.4/config/certs/elastic-stack-ca.p12
Password for elastic-stack-ca.p12:  直接回车,不使用密码
For how long should your certificate be valid? [5y] 50y#过期时间
Generate a certificate per node? [y/N]n
Enter all the hostnames that you need, one per line. #输入es的节点 两次回车确认
When you are done, press <ENTER> once more to move on to the next step.
es1
es2
es3

You entered the following hostnames.

 - es1
 - es2
 - es3

Is this correct [Y/n]y

When you are done, press <ENTER> once more to move on to the next step. #输入es的ip 两次回车确认

192.168.1.1
192.168.1.2
192.168.1.3

You entered the following IP addresses.
 - 192.168.1.1
 - 192.168.1.2
 - 192.168.1.3

Is this correct [Y/n]y

Do you wish to change any of these options? [y/N]n

接下来一直回车,然后会在当前目录生成名为:elasticsearch-ssl-http.zip的压缩文件

解压缩http证书文件到config下,证书在http文件夹里。名字是http.p12,mv出来到config下

 确保elasticsearch目录下所有文件的归属关系都是es用户

 chown -R es:es /home/es/elasticsearch-8.10.4

启动es

su - es #到es用户下
bin/elasticsearch  初次可以前台启动 没问题就放后台
bin/elasticsearch -d

复制整个es文件夹到es2,es3

只需要修改

node.name: es2 #节点名称

network.host: 192.168.1.2 #节点ip

node.name: es3 #节点名称

network.host: 192.168.1.3 #节点ip

 浏览器访问一下es的web ui

https://192.168.1.1:9200 

 elasticsearch ssl认证,elk,logstash,filebeat

生成账户密码

 

bin/elasticsearch-setup-passwords interactive

warning: ignoring JAVA_HOME=/usr/local/java/jdk1.8.0_361; using bundled JDK
******************************************************************************
Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This       command will be removed in a future release.
******************************************************************************

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]



这个时候就可以使用账号密码访问了

创建一个给kibana使用的用户

bin/elasticsearch-users useradd kibanauser
kibana不能用es超级用户,此处展示一下用法
bin/elasticsearch-users roles -a superuser kibanauser
加两个角色 不然没有监控权限
bin/elasticsearch-users roles -a kibana_admin kibanauser
bin/elasticsearch-users roles -a monitoring_user kibanauser

 然后配置kibana

解压然后修改kibana.yml

server.port: 5601
server.host: "0.0.0.0"

server.ssl.enabled: true
server.ssl.certificate: /data/elasticsearch-8.10.4/config/client.cer
server.ssl.key: /data/elasticsearch-8.10.4/config/client.key
elasticsearch.hosts: ["https://192.168.1.1:9200"]
elasticsearch.username: "kibanauser"
elasticsearch.password: "kibanauser"
elasticsearch.ssl.certificate: /data/elasticsearch-8.10.4/config/client.cer
elasticsearch.ssl.key: /data/elasticsearch-8.10.4/config/client.key
elasticsearch.ssl.certificateAuthorities: [ "/data/elasticsearch-8.10.4/config/client-ca.cer" ]
elasticsearch.ssl.verificationMode: certificate
i18n.locale: "zh-CN"
xpack.encryptedSavedObjects.encryptionKey: encryptedSavedObjects1234567890987654321 
xpack.security.encryptionKey: encryptionKeysecurity1234567890987654321
xpack.reporting.encryptionKey: encryptionKeyreporting1234567890987654321

启动

bin/kibana

访问 https://ip:5601 

 配置logstash

解压后在conf下创建一个配置文件,我取名logstash.conf

input {
  kafka {
        bootstrap_servers => "192.168.1.1:9092"
        group_id => "logstash_test"
        client_id => 1 #设置相同topic,设置相同groupid,设置不同clientid,实现LogStash多实例并行消费kafka
        topics => ["testlog"]
        consumer_threads => 2 #等于 topic分区数
        codec => json {    #添加json插件,filebeat发过来的是json格式的数据
            charset => "UTF-8"
        }
        decorate_events => false #此属性会将当前topic、offset、group、partition等信息也带到message中
        type => "testlog" #跟topics不重合。因为output读取不了topics这个变量
}
 
}
filter {
  mutate {
    remove_field => "@version"  #去掉一些没用的参数
    remove_field => "event"
    remove_field => "fields"
    
    }
}


output {
  elasticsearch {
    cacert => "/data/elasticsearch-8.10.4/config/client-ca.cer"
    ssl => true
    ssl_certificate_verification => false
    user => elastic
    password => "123456"
    action => "index"
    hosts => "https://192.168.1.1:9200"
    index => "%{type}-%{+YYYY.MM.dd}"
}

}

修改jvm.options

-Xms6g #你服务器内存的一半,最高32G
-Xmx6g #你服务器内存的一半,最高32G

 

 启动logstash

bin/logstash -f conf/logstash.conf

最后去服务器上部署filebeat 

filebeat.inputs:
- type: filestream 跟以前的log类似。普通的日志选这个就行了
  id: testlog1  
  enabled: true
  paths:
    - /var/log/testlog1.log
  field_under_root: true #让kafka的topic: '%{[fields.log_topic]}'取到变量值
  fields:
    log_topic: testlog1  #跟id不冲突,id输出取不到变量值
  multiline.pattern: '^\d(4)'    # 设置多行合并匹配的规则,意思就是不以4个连续数字,比如2023开头的 视为同一条
  multiline.negate: true   # 如果匹配不上
  multiline.match: after  # 合并到后面

- type: filestream 
  id: testlog2
  enabled: true
  paths:
    - /var/log/testlog2
  field_under_root: true 
  fields:
    log_topic: testlog2
  multiline.pattern: '^\d(4)' 
  multiline.negate: true
  multiline.match: after



filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml 
  reload.enabled: true  #开启运行时重载配置
  #reload.period: 10s
path.home: /data/filebeat-8.10.4/  #指明filebeat的文件夹。启动多个时需要
path.data: /data/filebeat-8.10.4/data/
path.logs: /data/filebeat-8.10.4/logs/

processors:
  - drop_fields: #删除不需要显示的字段
      fields: ["agent","event","input","log","type","ecs"]

output.kafka:
  enabled: true
  hosts: ["10.8.74.35:9092"]   #kafka地址,可配置多个用逗号隔开
  topic: '%{[fields.log_topic]}'   #根据上面添加字段发送不同topic

初步的部署这就完成了。后面的使用才是大头,路漫漫其修远兮 文章来源地址https://www.toymoban.com/news/detail-764435.html

到了这里,关于Elastic stack8.10.4搭建、启用安全认证,启用https,TLS,SSL 安全配置详解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

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

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

相关文章

  • Kafka三种认证模式,Kafka 安全认证及权限控制详细配置与搭建

    Kafka三种认证模式,Kafka 安全认证及权限控制详细配置与搭建。 Kafka三种认证模式 使用kerberos认证

    2024年02月04日
    浏览(42)
  • Elastic Stack(1):Elastic Stack简介

    1 简介 ELK是一个免费开源的日志分析架构技术栈总称,官网https://www.elastic.co/cn。包含三大基础组件,分别是Elasticsearch、Logstash、Kibana。但实际上ELK不仅仅适用于日志分析,它还可以支持其它任何数据搜索、分析和收集的场景,日志分析和收集只是更具有代表性。并非唯一性。

    2024年01月19日
    浏览(37)
  • Kibana-elastic--Elastic Stack--ELK Stack

    Kibana 是什么? | Elastic 将数据转变为结果、响应和解决方案 使用 Kibana 针对大规模数据快速运行数据分析,以实现可观测性、安全和搜索。对来自任何来源的任何数据进行全面透彻的分析,从威胁情报到搜索分析,从日志到应用程序监测,不一而足。 虫瞻图(英语:worm\\\'s-eye

    2024年02月15日
    浏览(28)
  • 【MongoDB】集群搭建实战 | 副本集 Replica-Set | 分片集群 Shard-Cluster | 安全认证

    副本集 MongoDB副本集(Replica Set)是一组维护相同数据集的 MongoDB 实例,它可以提供数据的冗余和高可用性。 副本集由一个主节点(Primary)和多个从节点(Secondary)组成。 客户端所有写操作都会发送到主节点,主节点会记录oplog,然后将写操作同步到从节点。 从节点可以进行

    2024年02月05日
    浏览(34)
  • Elastic Stack 8.0 安装 - 保护你的 Elastic Stack 现在比以往任何时候都简单

    在 8.0 中,我们很高兴为所有用户带来简化的安全功能。 从 7.1 开始,我们向所有人免费提供了确保 Elastic Stack 安全所需的所有功能。 然而,我们知道设置安全性并不好玩,你需要专注于你的项目目标。 好消息给你! 从 8.0 开始,自管理集群默认启用 Elastic Stack 安全性,配置

    2023年04月08日
    浏览(32)
  • Elastic:使用 Docker 安装 Elastic Stack 8.x 并开始使用

    Elastic Stack 8.0 终于于最近发布了。在我之前的文章 “Elastic Stack 8.0 安装 - 保护你的 Elastic Stack 现在比以往任何时候都简单” 我已经详细地描述了如何在本地部署 Elasticsearch 及 Kibana。设置 Elasticsearch 的最简单方法是使用 Elastic Cloud 上的 Elasticsearch Service 创建托管部署。 如果你

    2024年02月16日
    浏览(26)
  • Elastic Stack 环境配置与框架简介

    目录 简介 什么是Elastic Stack Elasticasearch Logstash Kibana Beats 框架图 下载 配置 一、安装java环境 启动 Elasticsearch Kibana FileBeat Logstash 测验 Elastic Stack 缩写为elk,它由三个软件组成: Elasticsearch 、 Logstash 、 Kibana ,因此缩写为elk,随着版本的变化,添加了一个新软件 Beats ,因此其全

    2024年02月12日
    浏览(31)
  • 运用 Elastic Stack 收集 docker 容器日志

    Elastic Stack 在收集日志方面有很多的方面的应用。在今天的文章中,我将使用 docker 来安装 Elastic Stack。我将演示如何使用 docker 安装 Filebeat 并收集容器的日志。 在我之前的文章 “Beats:为 Filebeat 配置 inputs”,我展示了如何使用 Filebeat 来收集 container 里的日志数据。在那篇文

    2023年04月08日
    浏览(27)
  • Elastic(ELK) Stack 架构师成长路径

    Elastic Stack(ELK Stack)是一个开源的日志分析平台,由 Elasticsearch、Logstash 和 Kibana 三个组件组成,主要用于数据搜索、分析和可视化。要成为一名 ELK Stack 架构师,需要遵循一定的成长路径,以便逐步掌握相关知识和技能。 基本了解:在这个阶段,您需要学习基本的ELK Stack概

    2023年04月21日
    浏览(37)
  • ArcGIS 10.4安装教程!

    软件介绍: ArcGIS是一款专业的电子地图信息编辑和开发软件,提供一种快速并且使用简单的方式浏览地理信息,无论是2D还是3D的信息。软件内置多种编辑工具,可以轻松的完成地图生产全过程,为地图分析和处理提供了新的解决方案,可以无限的进行数据和地图的共享。同

    2024年02月09日
    浏览(29)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包