Skip to content

Instantly share code, notes, and snippets.

@gb-swatanabe
Last active November 12, 2015 04:11
Show Gist options
  • Save gb-swatanabe/bfa56036a46c2c133fdd to your computer and use it in GitHub Desktop.
Save gb-swatanabe/bfa56036a46c2c133fdd to your computer and use it in GitHub Desktop.
Kibana / elasticsearch / logstash / fluentd検証用
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# https://docs.vagrantup.com.
config.vm.box = "ubuntu/trusty64"
# VM hostname and port forwardings
config.vm.hostname = "eval-kibana"
{ 5601 => 5601,
9200 => 9200 }.each do |gport,hport|
config.vm.network "forwarded_port", guest: gport, host: hport
end
# VM settings
config.vm.provider "virtualbox" do |vb|
vb.name = "%s_%s" % [config.vm.hostname, config.vm.box.gsub(%r(\A.*/),"")]
vb.cpus = 4
vb.memory = 8192
{ "vram" => "16",
"paravirtprovider" => "default",
"nictype1" => "virtio",
"nictype2" => "virtio" }.each do |id,value|
vb.customize ["modifyvm", :id, "--#{id}", value]
end
end
# shared folder
config.vm.synced_folder ".", "/mnt/vagrant"
# provisionings
config.vm.provision "shell", inline: <<-SHELL
# TZ
echo 'Asia/Tokyo' > /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata
# logstash + elasticsearch
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
(
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main"
echo "deb http://packages.elasticsearch.org/logstash/2.0/debian stable main"
) > /etc/apt/sources.list.d/elasticsearch-2.x.list
apt-get update
apt-get install -y openjdk-7-jre elasticsearch logstash
update-rc.d elasticsearch defaults 95 10
(
echo 'cluster.name: #{config.vm.hostname}.elasticsearch'
echo 'discovery.zen.ping.multicast.enabled: false'
echo 'network.host: 0.0.0.0'
) >> /etc/elasticsearch/elasticsearch.yml
# elasticsearch plugin
/usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head
# kibana
cd /opt
KIBANA="kibana-4.2.0-linux-x64"
curl -sL https://download.elastic.co/kibana/kibana/${KIBANA}.tar.gz | tar xzpf -
chown -R vagrant /opt/${KIBANA}
(
echo 'start on stopped rc RUNLEVEL=[2345]'
echo "exec /opt/${KIBANA}/bin/kibana >/dev/null 2>&1 &"
) > /etc/init/kibana.conf
# fluentd + plugin
curl -sL https://toolbelt.treasuredata.com/sh/install-ubuntu-trusty-td-agent2.sh | sh
/opt/td-agent/usr/sbin/td-agent-gem install --no-ri --no-rdoc \
fluent-plugin-elasticsearch \
fluent-plugin-stdin \
fluent-plugin-record-reformer
# finish
echo ''
echo '*************************************'
echo '**** PLEASE RUN "vagrant reload" ****'
echo '*************************************'
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment