Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

ELK automatic deployment script

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

ELK automatic installation script

I. brief introduction

ELK is composed of Elasticsearch, Logstash and Kibana.

Elasticsearch is an open source distributed search engine, its characteristics are: distributed, zero configuration, automatic discovery, index automatic slicing, index copy mechanism, restful style interface, multiple data sources, automatic search load and so on.

Logstash is a completely open source tool that collects, analyzes, and stores your logs for future use.

Kibana is an open source and free tool that provides a friendly Web interface for log analysis for Logstash and ElasticSearch to help you aggregate, analyze, and search important data logs.

II. Core components

Logstash: the logstash server side is used to collect logs

Elasticsearch: store all kinds of logs

Kibana: the web interface is used for lookup and visualization logs

Filebeat is a log file shipping tool. After installing the client on your server, filebeat will monitor the log directory or specified log files, track and read these files (track changes in files, keep reading), and forward these information to elasticsearch or logstarsh for storage.

III. Installation script

Note: add ip and hostname to vim / etc/hosts; Note: server memory will cause elasticsearch not to start if the server memory is low

Customize the name of the shell script vim Autoinstall_ELK_V1.3.sh copy and paste the content to execute.

#! / bin/bash#mail:lishilong@co-mall.com#data:2019/1/9#AutoInstall ELK scripts#Software:elasticsearch-5.4.1/logstash-5.4.1/filebeat-5.4.1/kibana-5.4.1clearecho "# # "echo" # Auto Install ELK. # # "echo" # Press Ctrl+C to cancel # # "echo" # Any key to continue # # "echo" # Softwae:elasticsearch-5.4.1/logstash-5.4.1/filebeat-5.4.1/kibana-5.4.1 # # "echo" # # # "read-n 1softwareware dirt =" / usr/local/software "elasticsearch_url=" https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.1.tar.gz"kibana_url="https://artifacts.elastic.co/downloads/kibana/kibana- 5.4.1-linux-x86_64.tar.gz "logstash_url=" https://artifacts.elastic.co/downloads/logstash/logstash-5.4.1.tar.gz"filebeat_url="https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.4.1-linux-x86_64.tar.gz"sys_version=`cat / etc/redhat-release | awk'{print $4}'| cut-d. -f1`IP = `ip addr | grep "inet" | grep-v 127.0.0.1 | awk'{print $2}'| cut-d /-f1`jvm _ conf= "/ usr/local/elasticsearch/config/jvm.options" sys_mem= `free-m | grep Mem: | awk'{print $2}'| awk'{sum+=$1} END {print sum/1024}'| cut-d. -f1` # wget softwarewget_fun () {if [!-d ${software_dir}]; then mkdir-p ${software_dir} & & cd ${software_dir} else cd ${software_dir} fifor software in $elasticsearch_url $kibana_url $logstash_url $filebeat_urldo wget-c $softwaredoneclear} # initial system:install java wget;set hostname;disable firewalldinit_sys () {[- f / etc/init.d/functions] & &. / etc/init.d/functions ["${sys_version}"! = "7"] & & echo "Error:This Scripts Support Centos7.xx" & & exit 1 [$(id-u)! = "0"] & & echo "Error: You must be root to run this script" & & exit 1sed-I "s/SELINUX=enforcing/SELINUX=disabled/" / etc/selinux/configsetenforce 0yum install-y java-1.8.0-openjdk wgethostnamectl set-hostname elk-server Systemctl stop firewalldcat > > / etc/security/limits.conf/etc/sysctl.conf & & sysctl-pif [${sys_mem}-eq 0] Then sed-I "s# `grep" ^-Xmx "${jvm_conf} `#"-Xmx512m "# g" ${jvm_conf} sed-I "s# `grep" ^-Xms "${jvm_conf}` #"-Xms512m "# g" ${jvm_conf} else sed-I "s# `grep" ^-Xmx "${jvm_conf}` #"-Xmx$ {sys_mem} g "# g" ${jvm_conf} sed-I "s# `grep "^-Xms" ${jvm_conf} `# "- Xms$ {sys_mem} g" # g "${jvm_conf} ficat > > / usr/local/elasticsearch/config/elasticsearch.yml rubydebug}} EOFnohup / usr/local/logstash/bin/logstash-f / usr/local/logstash/config/01-syslog.conf & > / dev/null} # install filebeatinstall_filebeat () {cd $software_dirtar-zxf filebeat-5.4.1-linux-x86_64.tar.gzmv filebeat-5.4 .1-linux-x86_64 / usr/local/filebeatcat > / usr/local/filebeat/filebeat.yml > / usr/local/kibana/config/kibana.yml

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report