Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Elk log collection display

Shulou Source: shulou.com Published: 2022-06-03 04:41:56 11月25日 Update

[elasticsearch7.6 installation]

System preparation:

Operating system: centos 7 x64

JAVA software version: java8 (official documentation)

Elasticsearch version: 6.6.2

Install JDK and set the environment variables:

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

View the java version:

Java-version

Install elasticsearch:

Tar zxvf elasticsearch-6.6.2.tar.gz

Modify the configuration file:

Config\ elasticsearch.yml

Cluster.name cluster name

Node.name Node name

Path.data

Path.logs

All public network IP can be accessed by network.host 0VOV 0RU 0RU 0.

Http.port http request port number. Default is 9200.

Modify the configuration file

Config\ jvm.options

-Xms1g

-Xmx1g

Start elasticsearch

Bin\ elasticsearch

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

Elasticsearch does not allow the use of root user startup.

Useradd elk

Chown-R elk:elk elasticsearch-6.6.2

Chown-R elk:elk elk

. / elasticsearch

Vi / etc/security/limits.conf

Soft nofile 65536hard nofile 65536

Vi / etc/sysctl.conf

Vm.max_map_count=262144

Visit elasticsearch

Http://192.168.1.129:9200

Create a new startup script

Vi startup.sh

Nohup / usr/local/elasticsearch-6.6.2/bin/elasticsearch > > / usr/local/elasticsearch-6.6.2/output.log 2 > & 1 &

Chmod axix startup.sh

Turn off elasticsearch:

Jps

Kill-9 process number

[install kibana]

Tar zxvf kibana-6.6.2-linux-x86_64.tar.gz

Kibana is an open source analysis and visualization platform designed for use with Elasticsearch.

You can use kibana to search, view, and interact with the data stored in the Elasticsearch index

Using a variety of different charts, tables, maps and other kibana can easily show advanced data analysis and visualization.

Configuration file config\ bibana.yml

Server.port: 5601

Server.host: "0.0.0.0"

Elasticsearch.hosts: ["http://localhost:9200"]

Visit:

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 panel use]

GET / kibana_sample_data_logs/_settings

[logstash installation and configuration]

Tar logstash-6.6.2.tar.gz

Use logstash to collect nginx logs and display them in kibana, and modify the configuration file config\ logstash.conf

Input {

File {

Path = > "/ usr/local/nginx/logs/access.log"

Type = > "nginxaccess"

Start_position = > "beginning"

}

}

Filter {

Grok {

Match = > {"message" = > "% {HTTPD_COMBINEDLOG}"}

}

}

Output {

# output to elasticsearch:

Elasticsearch {

Hosts = > ["127.0.0.1 9200"]

Index = > "nginx-% {+ YYYY.MM.dd}"

}

}

Start the script:

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 &

Tags: Configuration file version name data system script analysis visualization log different advanced operating system variable slogan chart map official platform data analysis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Xiaomi vpn MySQL