ELK搭建

本次ELK安装版本均为7.17.21,8.0版本容易出软件如兼容的问题,故选择7的最后一个版本进行安装

前期准备:

  elastic官网:https://www.elastic.co/

  elasticsearch下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-17-21

  logstash下载地址:https://www.elastic.co/cn/downloads/past-releases/logstash-7-17-21

  kibana下载地址:https://www.elastic.co/cn/downloads/past-releases/kibana-7-17-21

elasticsearch

  tar -xvf elasticsearch-7.17.21-linux-x86_64.tar.gz

  cd elasticsearch-7.17.21

  vim config/elasticsearch.yml

    xpack.security.enabled: true    #开启https安全校验,未开启的情况下kibana无法使用

    xpack.security.authc.api_key.enabled: true     #开启api接口访问

      ./bin/elasticsearch-setup-passwords interactive      #重置es密码,执行后会在控制台打印出用户名和密码

  useradd esuser  #创建esuser用户

  su esuser        #root用户不能启动elasticsearch  需要切换到esuser用户启动

  后台启动:nohup ./bin/elasticsearch  > /dev/null 2>&1 &     

kibana

  tar -xvf kibana-7.17.21-linux-x86_64.tar.gz

  cd kibana-7.17.21-linux-x86_64/

      elasticsearch开启htts安全设置时需要生成加密字符串   ./bin/kibana-encryption-keys generate  并配置到kibana.yml中

  vim config/kibana.yml

    elasticsearch.username: "es user name"

    elasticsearch.password: "es password"

  后台启动:nohup ./bin/kibana --allow-root > /dev/null 2>&1 &       #root用户启动需要加--allow-root   非root用户可不加

  kibana访问:http://ip:5601

logstash  

tar -xvf logstash-7.17.21-linux-x86_64.tar.gz

  cd logstash-7.17.21

  mkdir conf.d

  创建配置文件,多个配置文件ipput需加type字段,在output中对type进行判断,否则会出现同一来源的日志进入所有配置的output中

      

# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.
input {
  file {
    path => "/home/www/jzwl/api/resource/log/sql/*.log"
    #start_position => "beginning"
    type=>"api"
  }
}

output {
  if [type] == "api"{
    elasticsearch {
      hosts => ["http://localhost:9200"]
      index => "jzwl-api-%{+YYYY.MM.dd}"
      user => "es username"
      password => "es password"
    }
  }
}

  

  后台启动:

nohup ./bin/logstash -f ./conf.d/ > /dev/null 2>&1 & 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小斌0810

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值