############################### Logstash - Elasticsearch cluster Setup ##################################
Register server with satellite
rhn-channel --add --channel=clone-epel_rhel6x_x86_64 -u XXXX -p XXXX
Install Oracle Java 8
echo "Installing Oracle Java 8"
mkdir /opt/collegis/software/java
cd /opt/collegis/software/java
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz"
tar -zxvf jdk-8u20-linux-x64.tar.gz
update-alternatives --install /usr/bin/java java /opt/collegis/software/java/jdk1.8.0_20/bin/java 2
Install Elasticsearch
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
yum install -y --nogpgcheck elasticsearch
chkconfig --level 3 elasticsearch on
Configuring Elasticsearch
echo "### Below is added using install script ###" >> /etc/elasticsearch/elasticsearch.yml
Node name
echo "cluster.name: collegis_es_cluster" >> /etc/elasticsearch/elasticsearch.yml
echo "node.name: $yourhostname" >> /etc/elasticsearch/elasticsearch.yml
echo "node.datacenter: latisys" >> /etc/elasticsearch/elasticsearch.yml
echo "node.master: false" >> /etc/elasticsearch/elasticsearch.yml
echo "node.data: true" >> /etc/elasticsearch/elasticsearch.yml
echo "index.number_of_shards: 5" >> /etc/elasticsearch/elasticsearch.yml
echo "index.number_of_replicas: 1" >> /etc/elasticsearch/elasticsearch.yml
echo "bootstrap.mlockall: true" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Threadpool Settings
Search pool
echo "threadpool.search.type: fixed" >> /etc/elasticsearch/elasticsearch.yml
echo "threadpool.search.size: 20" >> /etc/elasticsearch/elasticsearch.yml
echo "threadpool.search.queue_size: 100" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Bulk pool
echo "threadpool.bulk.type: fixed" >> /etc/elasticsearch/elasticsearch.yml
echo "threadpool.bulk.size: 60" >> /etc/elasticsearch/elasticsearch.yml
echo "threadpool.bulk.queue_size: 300" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Index pool
echo "threadpool.index.type: fixed" >> /etc/elasticsearch/elasticsearch.yml
echo "threadpool.index.size: 20" >> /etc/elasticsearch/elasticsearch.yml
echo "threadpool.index.queue_size: 100" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Indices settings
echo "indices.memory.index_buffer_size: 30%" >> /etc/elasticsearch/elasticsearch.yml
echo "indices.memory.min_shard_index_buffer_size: 12mb" >> /etc/elasticsearch/elasticsearch.yml
echo "indices.memory.min_index_buffer_size: 96mb" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Cache Sizes
echo "indices.fielddata.cache.size: 15%" >> /etc/elasticsearch/elasticsearch.yml
echo "indices.fielddata.cache.expire: 6h" >> /etc/elasticsearch/elasticsearch.yml
echo "indices.cache.filter.size: 15%" >> /etc/elasticsearch/elasticsearch.yml
echo "indices.cache.filter.expire: 6h" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Indexing Settings for Writes
echo "index.refresh_interval: 30s" >> /etc/elasticsearch/elasticsearch.yml
echo "index.translog.flush_threshold_ops: 50000" >> /etc/elasticsearch/elasticsearch.yml
echo "" >> /etc/elasticsearch/elasticsearch.yml
Minimum nodes alive to constitute an operational cluster
echo "#### Prevent split brain ES Cluster n/2+1 ####" >> /etc/elasticsearch/elasticsearch.yml
echo "discovery.zen.minimum_master_nodes: 2" >> /etc/elasticsearch/elasticsearch.yml
echo "#" >> /etc/elasticsearch/elasticsearch.yml
echo 'discovery.zen.ping.unicast.hosts: ["nodename-1p", "nodename-2p", "nodename-3p", "nodename-4p", "nodename-5p", "nodename-6p", "nodename-7p", "nodename-8p"]' >> /etc/elasticsearch/elasticsearch.yml
echo "#discovery.zen.ping.multicast.enabled: false" >> /etc/elasticsearch/elasticsearch.yml
Making changes to /etc/security/limits.conf to allow more open files for elasticsearch
mv /etc/security/limits.conf /etc/security/limits.bak
grep -Ev "# End of file" /etc/security/limits.bak > /etc/security/limits.conf
echo "elasticsearch soft nofile 65536" >> /etc/security/limits.conf
echo "elasticsearch hard nofile 65536" >> /etc/security/limits.conf
echo "elasticsearch - memlock unlimited" >> /etc/security/limits.conf
echo "# End of file" >> /etc/security/limits.conf
Modify elasticsearch service for ulimit -l unlimited to allow mlockall to work correctly
sed -i -e 's|^#ES_HEAP_SIZE=2g|ES_HEAP_SIZE=16g|' /etc/init.d/elasticsearch
sed -i -e 's|^#MAX_LOCKED_MEMORY=|MAX_LOCKED_MEMORY=unlimited|' /etc/init.d/elasticsearch
Set Elasticsearch to start on boot
chkconfig elasticsearch on
Set Elasticsearch to start on boot
chkconfig elasticsearch on
Restart Elasticsearch service
service elasticsearch restart