Skip to content

Instantly share code, notes, and snippets.

@anhtranbk
Last active January 2, 2018 08:31
Show Gist options
  • Save anhtranbk/a480a1159b3afb1d374627305693f0b4 to your computer and use it in GitHub Desktop.
Save anhtranbk/a480a1159b3afb1d374627305693f0b4 to your computer and use it in GitHub Desktop.
Setup Elastic Search on server, sample for cluster with 3 nodes
# heap size
ES_HEAP_SIZE=30G
# max file descriptos
# https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html
# virtual memory
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
sysctl -w vm.max_map_count=262144
# swap
# https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html
# To disable it permanently, you’ll likely need to edit your /etc/fstab
sudo swapoff -a
# Add to last of /etc/securify/limits.conf
elastic soft memlock unlimited
elastic hard memlock unlimited
cluster.name: elasticsearch-sentiment
node.name: "master-23.160"
node.master: true
node.data: false
node.ingest: false
network.host: "192.168.23.160"
discovery.zen.ping.unicast.hosts: ["192.168.23.160", "192.168.23.161", "192.168.23.162"]
discovery.zen.minimum_master_nodes: 1
path.data: /storage/elastic/data
path.logs: /storage/elastic/logs
bootstrap.memory_lock: true
indices.fielddata.cache.size: 20%
VERSION=${1:-2.4.1}
rm -rf elasticsearch*
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${VERSION}/elasticsearch-${VERSION}.tar.gz
tar -zxvf elasticsearch-*.tar.gz
[ -d data ] || mkdir data
[ -d logs ] || mkdir logs
elasticsearch-${VERSION}/bin/plugin install license
elasticsearch-${VERSION}/bin/plugin install mobz/elasticsearch-head
elasticsearch-${VERSION}/bin/plugin install royrusso/elasticsearch-HQ
elasticsearch-${VERSION}/bin/plugin install mavel-agent
while :
do
echo 'Starting elasticsearch...'
export ES_JAVA_OPTS="-Djna.tmpdir=/data1/elastic/tmp -Xms12g -Xmx12g"
/data1/elastic/elasticsearch-${1:-5.3.0}/bin/elasticsearch
echo 'Elasticsearch stopped. Sleep 10s and restart...'
sleep 10s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment