shell-涓€閿畨瑁匛LK鑴氭湰
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell-涓€閿畨瑁匛LK鑴氭湰相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/server' title='server'>server
vim 閫夋嫨 done path link messages tabs 瀹夎澶辫触瀹夎鐜
绯荤粺 :centos7
杞欢淇℃伅:
lasticsearch-6.6.2.rpm
jdk-8u131-linux-x64_.rpm
kibana-6.6.2-x86_64.rpm
logstash-6.6.0.rpm
鎻愰啋淇℃伅
璇锋彁鍓嶅啓閰嶇疆鏂囦欢,骞朵繚璇侀厤缃枃浠朵笌鑴氭湰澶勪簬鍚屼竴鐩綍鍐?/font>
浠ュ強鍥涗釜瀹夎鍖?/font>
鑴氭湰浠g爜
#!/bin/bash echo "璇峰皢鑴氭湰涓庨厤缃枃浠跺拰瀹夎鍖呮斁鍦ㄥ悓涓€璺緞涓? # 鍏抽棴闃茬伀澧欎笌selinux systemctl stop firewalld.service setenforce 0 ip=`ifconfig ens33 |grep netmask |awk -F "[ ]" 鈥榹print $10}鈥榒 while : do echo "璇烽€夋嫨E,L,K瀹夎椤圭洰" read -p "鏄惁宸茬粡瀹夎:(J/E/L/K/0)" ELK case $ELK in j) echo "------------------------------------------" echo -e " 33[43;1m妫€娴媕ava瀹夎鍖匼033[37m" ls jdk-8u131-linux-x64_.rpm &>/dev/null if [ $? -eq 0 ];then echo "瀹夎java" rpm -ivh jdk-8u131-linux-x64_.rpm &>/dev/null echo -e " 33[43;1m瀹夎瀹屾瘯 33[0m" else echo -e " 33[1;5;31m 娌℃湁瀹夎鍖?鑷姩瀹夎閫€鍑篭033[0m" fi echo "------------------------------------------" ;; e) echo -e "璀﹀憡淇℃伅: 33[1;5;31m璇峰厛瀹夎jdk鍚庡畨瑁呮湰椤圭洰 33[0m" echo "------------------------------------------" echo -e " 33[44;30m妫€娴媏lasticsearch瀹夎鍖匼033[37m" ls elasticsearch-6.6.2.rpm &>/dev/null if [ $? -eq 0 ];then echo "瀹夎elasticsearch" yum -y install elasticsearch-6.6.2.rpm &>/dev/null echo "淇敼閰嶇疆鏂囦欢" echo "cluster.name: wg007" >>/etc/elasticsearch/elasticsearch.yml echo "node.name: node-1" >>/etc/elasticsearch/elasticsearch.yml echo "network.host: $ip" >>/etc/elasticsearch/elasticsearch.yml echo "http.port: 9200" >>/etc/elasticsearch/elasticsearch.yml echo "淇敼缁撴潫" echo "鍚姩elasticsearch" systemctl restart elasticsearch.service # 鍙屾鎵ц鍚姩 systemctl restart elasticsearch.service echo "妫€娴嬫垚鍔熸€? ll /var/log/elasticsearch/wg007.log if [ $? -eq 0 ];then echo -e " 33[44;30m瀹夎瀹屾瘯 33[0m" else echo -e " 33[44;30m瀹夎澶辫触,閫€鍑篭033[0m" fi else echo -e " 33[1;5;31m 娌℃湁瀹夎鍖?鑷姩瀹夎閫€鍑篭033[0m" fi echo "------------------------------------------" ;; l) echo -e "璀﹀憡淇℃伅: 33[1;5;31m璇峰厛瀹夎jdk鍚庡畨瑁呮湰椤圭洰 33[0m" echo "------------------------------------------" echo -e " 33[46;30m妫€娴嬪畨瑁呭寘 33[37m" ls logstash-6.6.0.rpm &>/dev/null if [ $? -eq 0 ];then echo "瀹夎logstash" yum -y install logstash-6.6.0.rpm &>/dev/null echo "淇敼閰嶇疆鏂囦欢" cp -f messages.conf /etc/logstash/conf.d/ sed -i "s/ip/$ip/g" /etc/logstash/conf.d/messages.conf echo "鍙屽惎鍔╨ogstash" systemctl start logstash.service systemctl restart logstash.service echo "璧嬩簣鏉冮檺" chmod -R 777 /var/log/ ls /var/log/logstash/logstash-plain.log &>/dev/null if [ $? -eq 0 ];then echo -e " 33[46;30m瀹夎瀹屾瘯 33[0m" else echo -e " 33[46;30m瀹夎澶辫触,閫€鍑篭033[0m" fi else echo -e " 33[1;5;31m 娌℃湁瀹夎鍖?鑷姩瀹夎閫€鍑篭033[0m" fi echo "------------------------------------------" ;; k) echo -e "璀﹀憡淇℃伅: 33[1;5;31m涓嶅緱涓巈lasticsearch瀹夎鍦ㄤ竴鍙版満鍣╘033[0m" rpm -q elasticsearch &>/dev/null if [ $? -eq 0 ];then echo -e " 33[1;5;31m宸茬粡瀹夎elasticsearch,鏃犳硶瀹夎kibana 33[0m" else echo "------------------------------------------" echo -e " 33[45;30m寮€濮嬪畨瑁卥ibana 33[37m" ls logstash-6.6.0.rpm &>/dev/null if [ $? -eq 0 ];then echo "寮€濮嬪畨瑁? yum -y install kibana-6.6.2-x86_64.rpm &>/dev/null echo "淇敼閰嶇疆鏂囦欢" echo "server.port: 5601" >>/etc/kibana/kibana.yml echo "server.host: "$ip"" >>/etc/kibana/kibana.yml read -p "璇疯緭鍏lasticsearch鐨刬p:" IP echo "elasticsearch.hosts: ["http://$IP:9200"]" >>/etc/kibana/kibana.yml echo "鍚姩鏈嶅姟" echo "楠岃瘉" netstat -anlp |grep 5601 &>/dev/null if [ $? -eq 0 ];then echo -e " 33[45;30m瀹夎瀹屾瘯,鍙互鍘绘祻瑙堝櫒鏌ョ湅 33[0m" else echo -e " 33[45;30m瀹夎澶辫触,閫€鍑篭033[0m" fi else echo -e " 33[1;5;31m娌℃湁瀹夎鍖?鑷姩瀹夎閫€鍑篭033[0m" fi fi echo "--------------------------------------------------" ;; 0) exit 0 ;; *) echo "杈撳叆閿欒" esac done
閰嶇疆鏂囦欢
vim messages.conf
input {
file {
path = varlogmessages
type = system-log
start_position = beginning
}
}
output {
elasticsearch {
hosts = ip:9200
index = system_log-%{+YYYY.MM.dd}
}
}
以上是关于shell-涓€閿畨瑁匛LK鑴氭湰的主要内容,如果未能解决你的问题,请参考以下文章