Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 88 lines (69 sloc) 2.47 KB
#!/bin/bash
set -e
# This script will automatically install and configure Logstash and Kibana
# For running Travis
TRAVIS=$1
# Special setup for Vagrant test
if [[ -d '/vagrant' ]]; then
ROOT='/vagrant'
else
# Grab the fullpath of our root directory
ROOT=$(cd `dirname ${BASH_SOURCE[0]}` && echo $PWD)
fi
# We'll set this header when using wget to be good network tenants
HEADER="Referer: https://github.com/stephen-mw/Logstash_kibana_auto_install"
apt-get update
apt-get install -y git-core redis-server openjdk-7-jre-headless rubygems \
ruby1.9.1-dev
# Redis serves as the queue for logstash logs
sed -ie 's#bind 127.0.0.1#bind 0.0.0.0#' /etc/redis/redis.conf
# This keeps redis background dumping from crashing if you run low
# on system memory. Don't do this in travis containers.
if [[ -z "${TRAVIS}" ]]; then
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
fi
/etc/init.d/redis-server restart
# Install and configure elasticsearch
wget --header "$HEADER" https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.1.deb \
-O /tmp/elasticsearch.deb
dpkg -i /tmp/elasticsearch.deb
rm /tmp/elasticsearch.deb
# These configurations are for a large, 192GB Dell R720. You'll need to adjust
# them for use on any smaller systems.
cp $ROOT/etc/elasticsearch/elasticsearch.yml .
cp $ROOT/default/elasticsearch /etc/default/elasticsearch
/etc/init.d/elasticsearch start
# Logstash is just a jar and requires some additional configs
LOGHOME=/etc/logstash
mkdir $LOGHOME && pushd $LOGHOME
wget --header "$HEADER" https://logstash.objects.dreamhost.com/release/logstash-1.1.13-flatjar.jar \
-O logstash.jar
cp $ROOT/conf/indexer.conf .
cp $ROOT/init/logstash.conf /etc/init/
mkdir /var/lib/logstash # Required working directory for logstash
service logstash start
popd
# Install and configure the Kibana frontend
pushd /opt/
git clone --branch=kibana-ruby https://github.com/stephen-mw/kibana2.git Kibana
pushd Kibana
sed -i 's#KibanaHost =.*#KibanaHost = "0.0.0.0"#' KibanaConfig.rb
sed -i 's#KibanaPort =.*#KibanaPort = 80#' KibanaConfig.rb
gem install bundler
bundle install
cp $ROOT/init/kibana.conf /etc/init/kibana.conf
service kibana start
popd
# Up the open FD limit for everyone
echo "soft nofile 1000000" >> /etc/security/limits.conf
echo "hard nofile 1000000" >> /etc/security/limits.conf
cat - <<FINISHED
Elasticsearch installation now complete.
Services running:
Logstash indexer
Elasticsearch
Redis
Kibana
Kibana is listening on port 80.
FINISHED