Skip to content

Instantly share code, notes, and snippets.

@w33ble
Last active May 17, 2017 19:24
Show Gist options
  • Save w33ble/757e6905190967523be05208c508cc2c to your computer and use it in GitHub Desktop.
Save w33ble/757e6905190967523be05208c508cc2c to your computer and use it in GitHub Desktop.
Elasticsearch + Kibana on CentOS 7 (bring your own JDK)
{
"apps": [{
"name": "elasticsearch",
"interpreter": "bash",
"script": "./elasticsearch-5.3.1/bin/elasticsearch"
}, {
"name": "kibana",
"interpreter": "bash",
"script": "./kibana-5.3.1-linux-x86_64/bin/kibana"
}]
}
Vagrant.require_version ">= 1.8.0"
$elasticVersion = "5.3.1"
# download the jdk from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
$jdkVersion = "8u131"
$downloads = "https://artifacts.elastic.co/downloads"
$esConfig = <<SCRIPT
# dumb check to see if this already ran
if [ ! -d /usr/java ]; then
echo "#### Elasticserch settings" >> /etc/security/limits.conf
echo "* soft nproc 65535" >> /etc/security/limits.conf
echo "* hard nproc 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
echo "* soft memlock unlimited" >> /etc/security/limits.conf
echo "* hard memlock unlimited" >> /etc/security/limits.conf
sysctl -w vm.max_map_count=262144
ulimit -n 65535
ulimit -l unlimited
fi
SCRIPT
$jdkInstall = <<SCRIPT
if [ ! -d /usr/java ]; then
sudo rpm -Uvh jdk-8u131-linux-x64.rpm
echo 'export JAVA_HOME="/usr/java/latest"' >> /etc/profile
fi
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network :forwarded_port, host: 3030, guest: 5601
config.vm.network :forwarded_port, host: 3031, guest: 9200
config.vm.provision "file", source: "./pm2_apps.json", destination: "pm2_apps.json"
config.vm.provision "file", source: "./jdk-#{$jdkVersion}-linux-x64.rpm", destination: "jdk-8u131-linux-x64.rpm"
config.vm.provision "shell",
inline: "curl #{$downloads}/elasticsearch/elasticsearch-#{$elasticVersion}.tar.gz -o elasticsearch-#{$elasticVersion}.tar.gz"
config.vm.provision "shell",
inline: "curl #{$downloads}/kibana/kibana-#{$elasticVersion}-linux-x86_64.tar.gz -o kibana-#{$elasticVersion}-linux-x86_64.tar.gz"
config.vm.provision "shell", inline: $esConfig
config.vm.provision "shell", inline: $jdkInstall
config.vm.provision "shell", inline: "tar zxvf elasticsearch* && sudo chown -R vagrant.vagrant elasticsearch*"
config.vm.provision "shell", inline: "elasticsearch-#{$elasticVersion}/bin/elasticsearch-plugin install -b x-pack"
config.vm.provision "shell", inline: "tar zxvf kibana* && sudo chown -R vagrant.vagrant kibana*"
config.vm.provision "shell", inline: "kibana-#{$elasticVersion}-linux-x86_64/bin/kibana-plugin install x-pack"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "80", "--cpus", "2"]
vb.memory = 2048
end
end
@w33ble
Copy link
Author

w33ble commented May 5, 2017

Download the JDK RPM from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and drop it next to this Vagrantfile, then just run vagrant up and you're all set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment