Last active
August 29, 2015 14:07
-
-
Save alasta/aa929163d546e070bf5a to your computer and use it in GitHub Desktop.
Script d'installation pour une démo basic d'ELK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
##Variables | |
APACHE_DOCUMENTROOT="/var/www/html" | |
KIBANA_SOURCE_URL="https://download.elasticsearch.org/kibana/kibana/kibana-3.1.1.tar.gz" | |
KIBANA_FILENAME=${KIBANA_SOURCE_URL##*/} | |
###Script | |
##Installation du web server Apache | |
echo "#=> Installation du webserver Apache ..." | |
yum -y install httpd | |
chkconfig --level 2345 httpd on | |
#Fichier de configuration apache pour la demo | |
wget https://gist.githubusercontent.com/alasta/a70e19fdfc090f3dd231/raw/31873f23447f63895afafde351656d026b2fab4b/apache_demo_elk.conf -O /etc/httpd/conf.d/demo-kibana.conf | |
service httpd start | |
##Installation de Java | |
echo "#=> Installation de Java ..." | |
yum -y install java-1.7.0-openjdk | |
##Installation d Elasticsearch | |
echo "#=> Installation d\'elasticsearch via le repository ..." | |
#Import des key du repo | |
rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch | |
#Creation du fichier de repo | |
echo -e '[elasticsearch-1.3]\n | |
name=Elasticsearch repository for 1.3.x packages\n | |
baseurl=http://packages.elasticsearch.org/elasticsearch/1.3/centos\n | |
gpgcheck=1\n | |
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch\n | |
enabled=1' > /etc/yum.repos.d/elasticsearch.repo | |
yum -y install elasticsearch | |
chkconfig --level 2345 elasticsearch on | |
service elasticsearch start | |
#Installation de logstash | |
echo "#=> Installetion de logstash ..." | |
#Creation du fichier de repo | |
echo -e '[logstash-1.4]\n | |
name=logstash repository for 1.4.x packages\n | |
baseurl=http://packages.elasticsearch.org/logstash/1.4/centos\n | |
gpgcheck=1\n | |
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch\n | |
enabled=1' > /etc/yum.repos.d/logstash.repo | |
yum -y install logstash* | |
#Fichier de config mini logstash | |
wget https://gist.githubusercontent.com/alasta/4f382cb950afb12e9d23/raw/01202442caae3b12f37ca0cddca3fae92ec70b71/logstash_10-config.conf -O /etc/logstash/conf.d/10-config.conf | |
chkconfig --level 2345 logstash on | |
service logstash start | |
###Modification du rsyslog local pour le forward des logs local dans kibana | |
echo "#=> Backup et modification de la configuration de rsyslog ..." | |
cp /etc/rsyslog.conf /etc/rsyslog.conf.$(date +'%Y%m%d') | |
echo -e "# Generate by installation script demo ELK\n#Forward to logstash\n*.* @@127.0.0.1:5544" >> /etc/rsyslog.conf | |
service rsyslog restart | |
#Recuperation des sources | |
cd $APACHE_DOCUMENTROOT | |
wget $KIBANA_SOURCE_URL | |
tar xzf $KIBANA_FILENAME | |
chown -R apache:apache ${KIBANA_FILENAME%.tar.gz} | |
#Sauvegarde du fichier config.js de kibana | |
cp ${KIBANA_FILENAME%.tar.gz}/config.js ${KIBANA_FILENAME%.tar.gz}/config.js.orig | |
#Modification de l URL elasticsearch | |
sed -i -e 's/elasticsearch: "http.*/elasticsearch: "\/\/"+window.location.hostname+"\/my_elasticsearch",/' ${KIBANA_FILENAME%.tar.gz}/config.js | |
#URL a afficher dans un browser | |
logger installation de la demo ELK finie | |
echo 'Installation de la demo finie.' | |
echo 'Aller a l''adresse suivante :' | |
echo " http://IP_du_serveur/${KIBANA_FILENAME%.tar.gz}/index.html#/dashboard/file/guided.json" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script d'installation pour une démonstration d'ELK (Elasticsearch Logstash Kibana) sur une CentOS.
Pré-requis :