elk日志搜集展现

【elastic<a href="https://www.fons.com.cn/tag/search" target="_blank">search6.6设备】
体系预备:
操作体系:centos 7 x64
JAVA软件版别:java8(官方文档)
Elasticsearch版别:6.6.2

设备JDK并设置环境变量:
rpm -ivh jdk-8u192-linux-x64.rpm

vi /etc/profile
export JAVA_HOME=/usr/java/latest

vi .bash_profile
export PATH=$JAVA_HOME/bin:$PATH

检查java版别:
java -version

设备elasticsearch:
tar zxvf elasticsearch-6.6.2.tar.gz
修改装备文件:
configelasticsearch.yml
cluster.name 集群称谓
node.name 节点称谓
path.data
path.logs
network.host 0:0:0:0 悉数外网IP可拜访
http.port http央求端口号,默以为9200
修改装备文件
configjvm.options
-Xms1g
-Xmx1g

建议elasticsearch
binelasticsearch
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
elasticsearch不允许运用root用户建议。

useradd elk

chown -R elk:elk elasticsearch-6.6.2
chown -R elk:elk elk
./elasticsearch

vi /etc/security/limits.conf

  • soft nofile 65536
  • hard nofile 65536
    vi /etc/sysctl.conf
    vm.max_map_count=262144

拜访elasticsearch
http://192.168.1.129:9200
新建建议脚本
vi startup.sh
nohup /usr/local/elasticsearch-6.6.2/bin/elasticsearch >> /usr/local/elasticsearch-6.6.2/output.log 2>&1 &
chmod a+x startup.sh
封闭elasticsearch:
jps
kill -9 进程号

【设备kibana】
tar zxvf kibana-6.6.2-linux-x86_64.tar.gz
Kibana是一个开源的剖析与可视化途径,规划出来用于和Elasticsearch一同运用的。
你可以用kibana查找、检查、交互存放在Elasticsearch索引里的数据,
运用各种不同的图表、表格、地图等kibana可以很轻易地展现高档数据剖析与可视化。

装备文件configbibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]

拜访:
http://127.0.0.1:5601

vi startup.sh
nohup /usr/local/kibana-6.6.2-linux-x86_64/bin/kibana >> /usr/local/kibana-6.6.2-linux-x86_64/output.log 2>&1 &

【kibana面板运用】
GET /kibana_sample_data_logs/_settings

【logstash设备及装备】
tar logstash-6.6.2.tar.gz

运用logstash搜集nginx日志并在kibana展现,修改装备文件configlogstash.conf
input {
file {
path => "/usr/local/nginx/logs/access.log"
type => "nginxaccess"
start_position => "beginning"
}
}

filter {
grok {
match => { "message" => "%{HTTPD_COMBINEDLOG}" }
}
}

output {
#输出到elasticsearch:
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "nginx-%{+YYYY.MM.dd}"
}
}
建议脚本:
startup.sh
#!/bin/bash
nohup /usr/local/logstash-6.6.2/bin/logstash -f /usr/local/logstash-6.6.2/config/logstash.conf >> /usr/local/logstash-6.6.2/output.log 2>&1 &