Skip to content

Instantly share code, notes, and snippets.

@hakanilter
Last active September 26, 2018 23:00
Show Gist options
  • Save hakanilter/98bb3cdaccaf01d3120879b430839f1d to your computer and use it in GitHub Desktop.
Save hakanilter/98bb3cdaccaf01d3120879b430839f1d to your computer and use it in GitHub Desktop.
ES6 Setup Scripts
#! /bin/sh
### BEGIN INIT INFO
# Provides: elasticsearch
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts elasticsearch
# Description: Starts elasticsearch using start-stop-daemon
### END INIT INFO
ES_HOME=/opt/elasticsearch
DAEMON=$ES_HOME/bin/elasticsearch
NAME=elasticsearch
DESC=elasticsearch
PID_FILE=$ES_HOME/$NAME.pid
DAEMON_OPTS="-d -p $PID_FILE"
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
if start-stop-daemon --start --pidfile $PID_FILE --startas $DAEMON -- $DAEMON_OPTS
then
echo "started."
else
echo "failed."
fi
;;
stop)
echo -n "Stopping $DESC: "
if start-stop-daemon --stop --pidfile $PID_FILE
then
echo "stopped."
else
echo "failed."
fi
;;
restart|force-reload)
${0} stop
sleep 0.5
${0} start
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
# Download
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz
# Extract
tar xvf elasticsearch-6.4.1.tar.gz
sudo mv elasticsearch-6.4.1 /opt/
cd /opt
sudo ln -s /opt/elasticsearch-6.4.1 elasticsearch
# Edit config file
# Install jdk8
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
# Memlock settings
sudo vim /etc/security/limits.conf
# add following lines
# elasticadmin soft memlock unlimited
# elasticadmin hard memlock unlimited
# Edit JVM settings
vim /opt/elasticsearch/config/jvm.options
# change values
# -Xms4g
# -Xmx4g
sudo sysctl -w vm.max_map_count=262144
# save init script (above) as /etc/init.d/elasticsearch
# enable script
sudo chmod +x /etc/init.d/elasticsearch
sudo update-rc.d elasticsearch defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment