之前使用 Linux 安装 Elasticsearch 并配置/Elasticsearch 安装过程中问题小记 两篇文章记录了 Elasticsearch 安装过程和注意点。
而这节主要说明 elk 中 l 所代表 logstash, 以及 k: kibana 相关内容
bin/logstash -f logstash.conf
wget https://repo.huaweicloud.com/java/jdk/11.0.1+13/jdk-11.0.1_linux-x64_bin.tar.gz
tar zxvf jdk-8u251-linux-x64.tar.gz
vi /etc/profile # java set export JAVA_HOME=/work/env/jdk11 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin 修改完 /etc/profile中的内容后,执行“立即生效”命令 “source /etc/profile”
在这里配置了环境变量可以使其他的用户都能够使用jdk,如果只是某个用户可以使用的话应该在该用户的家目录中配置环境变量
vim .bash_profile # java set export JAVA_HOME=/work/env/jdk11 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
启动logstash
bin/logstash -f config/logstash.conf
准备 logstash 配置文件
input { file { path => "/work/env/elk/logstash-7.8.0/data/movies.csv" start_position => "beginning" sincedb_path => "/dev/null" } } filter { csv { separator => "," columns => ["id","content","genre"] } mutate { split => { "genre" => "|" } remove_field => ["path", "host","@timestamp","message"] } mutate { split => ["content", "("] add_field => { "title" => "%{[content][0]}"} add_field => { "year" => "%{[content][1]}"} } mutate { convert => { "year" => "integer" } strip => ["title"] remove_field => ["path", "host","@timestamp","message","content"] } } output { elasticsearch { hosts => "http://127.0.0.1:9200" index => "movies" document_id => "%{id}" } stdout {} }
国内镜像:https://www.newbe.pro/tags/Mirrors/
# 下载 kibana 压缩包 wget https://mirrors.huaweicloud.com/kibana/7.8.0/kibana-7.8.0-linux-x86_64.tar.gz # 解压 并 进入 kibana 文件夹 tar -zxvf kibana-7.8.0-linux-x86_64.tar.gz && cd kibana-7.8.0 # 配置文件 以下内容 vim config/kibana.yml # ----------------- server.host: "0.0.0.0" elasticsearch.hosts: ["http://127.0.0.1:9200"] i18n.locale: "zh-CN"
bin/kibana # 启动 kibana
http://localhost:5601