ELK自動(dòng)安裝腳本
專注于為中小企業(yè)提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)北川羌族免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。一、簡(jiǎn)介
ELK由Elasticsearch、Logstash和Kibana三部分組件組成;
Elasticsearch是個(gè)開源分布式搜索引擎,它的特點(diǎn)有:分布式,零配置,自動(dòng)發(fā)現(xiàn),索引自動(dòng)分片,索引副本機(jī)制,restful風(fēng)格接口,多數(shù)據(jù)源,自動(dòng)搜索負(fù)載等。
Logstash是一個(gè)完全開源的工具,它可以對(duì)你的日志進(jìn)行收集、分析,并將其存儲(chǔ)供以后使用
kibana 是一個(gè)開源和免費(fèi)的工具,它可以為 Logstash 和 ElasticSearch 提供的日志分析友好的 Web 界面,可以幫助您匯總、分析和搜索重要數(shù)據(jù)日志。
二、核心組件
Logstash: logstash server端用來搜集日志;
Elasticsearch: 存儲(chǔ)各類日志;
Kibana: web化接口用作查尋和可視化日志;
Filebeat是一個(gè)日志文件托運(yùn)工具,在你的服務(wù)器上安裝客戶端后,filebeat會(huì)監(jiān)控日志目錄或者指定的日志文件,追蹤讀取這些文件(追蹤文件的變化,不停的讀),并且轉(zhuǎn)發(fā)這些信息到elasticsearch或者logstarsh中存放。
三、安裝腳本
注意:vim /etc/hosts 添加ip及主機(jī)名; 注意:服務(wù)器的內(nèi)存如果服務(wù)器內(nèi)存低的話會(huì)導(dǎo)致elasticsearch啟動(dòng)不了;
自定義shell腳本名稱 vim Autoinstall_ELK_V1.3.sh 復(fù)制粘貼一下內(nèi)容執(zhí)行。
#!/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.1 clear echo "#############################################################################" 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 1 software_dir="/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 software wget_fun() { if [ ! -d ${software_dir} ];then mkdir -p ${software_dir} && cd ${software_dir} else cd ${software_dir} fi for software in $elasticsearch_url $kibana_url $logstash_url $filebeat_url do wget -c $software done clear } #initial system:install java wget;set hostname;disable firewalld init_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 1 sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config setenforce 0 yum install -y java-1.8.0-openjdk wget hostnamectl set-hostname elk-server systemctl stop firewalld cat >>/etc/security/limits.conf<<EOF * soft nofile 65536 * hard nofile 65536 * soft nGproc 65536 * hard nproc 65536 EOF } #install elasticsearch install_elasticsearch() { cd $software_dir tar zxf elasticsearch-5.4.1.tar.gz mv elasticsearch-5.4.1 /usr/local/elasticsearch mkdir -p /usr/local/elasticsearch/data /usr/local/elasticsearch/logs useradd elasticsearch chown -R elasticsearch:elasticsearch /usr/local/elasticsearch echo "vm.max_map_count = 655360" >>/etc/sysctl.conf && sysctl -p if [ ${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} fi cat >>/usr/local/elasticsearch/config/elasticsearch.yml<<EOF cluster.name: my-application node.name: elk-server path.data: /usr/local/elasticsearch/data path.logs: /usr/local/elasticsearch/logs network.host: 127.0.0.1 http.port: 9200 discovery.zen.ping.unicast.hosts: ["elk-server"] EOF su - elasticsearch -c "nohup /usr/local/elasticsearch/bin/elasticsearch &" } #install logstash install_logstash() { cd $software_dir tar -zxf logstash-5.4.1.tar.gz mv logstash-5.4.1 /usr/local/logstash cat>/usr/local/logstash/config/01-syslog.conf<<EOF input { beats { port => "5044" } } output { elasticsearch { hosts => "127.0.0.1:9200" } stdout { codec => rubydebug } } EOF nohup /usr/local/logstash/bin/logstash -f /usr/local/logstash/config/01-syslog.conf & >/dev/null } #install filebeat install_filebeat() { cd $software_dir tar -zxf filebeat-5.4.1-linux-x86_64.tar.gz mv filebeat-5.4.1-linux-x86_64 /usr/local/filebeat cat >/usr/local/filebeat/filebeat.yml<<EOF filebeat.prospectors: - input_type: log paths: - /var/log/*.log output.logstash: hosts: ["127.0.0.1:5044"] EOF cd /usr/local/filebeat/ nohup /usr/local/filebeat/filebeat & >/dev/null } #install kibana install_kibana() { cd $software_dir tar -zxf kibana-5.4.1-linux-x86_64.tar.gz mv kibana-5.4.1-linux-x86_64 /usr/local/kibana cat >> /usr/local/kibana/config/kibana.yml <<EOF server.port: 5601 server.host: "0.0.0.0" elasticsearch.url: "http://127.0.0.1:9200" EOF nohup /usr/local/kibana/bin/kibana & >/dev/null } check() { port=$1 program=$2 check_port=`netstat -lntup|grep ${port}|wc -l` check_program=`ps -ef|grep ${program}|grep -v grep|wc -l` if [ $check_port -gt 0 ] && [ $check_program -gt 0 ];then action "${program} run is ok!" /bin/true else action "${program} run is error!" /bin/false fi } main() { init_sys wget_fun install_elasticsearch install_filebeat install_logstash install_kibana echo -e "\033[32m Checking Elasticsearch...\033[0m" sleep 20 check :9200 "elasticsearch" echo -e "\033[32m Checking Logstash...\033[0m" sleep 2 check ":9600" "logstash" echo -e "\033[32m Checking Kibana...\033[0m" sleep 2 check ":5601" "kibana" action "ELK install is success!" /bin/true echo "url:http://$IP:5601" } main四、腳本安裝
安裝完成訪問:http://IP:5601即可訪問;
五、配置
通過web界面訪問,創(chuàng)建index patterns;
六、查看日志與dashboard
配置完成!當(dāng)你發(fā)現(xiàn)你的才華與目標(biāo)相差甚遠(yuǎn)的時(shí)候,不如安心的好好學(xué)習(xí)!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
新聞標(biāo)題:ELK自動(dòng)部署腳本-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://jinyejixie.com/article6/dipcig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、用戶體驗(yàn)、網(wǎng)站收錄、定制開發(fā)、微信公眾號(hào)、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容