本次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 &
标签:ELK,7.17,21,kibana,api,elasticsearch,logstash,搭建 From: https://www.cnblogs.com/shenxiaobin/p/18207730