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,鏃犳硶瀹夎kibana33[0m"
				else
					echo "------------------------------------------"
					echo -e "33[45;30m寮€濮嬪畨瑁卥ibana33[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鑴氭湰的主要内容,如果未能解决你的问题,请参考以下文章

鍒嗕韩涓€涓壒閲忎慨鏀规枃浠剁紪鐮佺殑python鑴氭湰

CTF瀹炴垬9 XSS璺ㄧ珯鑴氭湰婕忔礊

shell鍒涘缓鏁版嵁搴撶殑鑴氭湰

瀛楀吀鑴氭湰鍜孧D5鐖嗙牬鑴氭湰

XSS鎻掑叆缁曡繃涓€浜涙柟寮忔€荤粨

瀹夎apache鑴氭湰