Install elasticsearch 5
Add key:
# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Add elasticsearch.repo. Using text editor, add below lines to /etc/yum.repos.d/elasticsearch.repo:
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
Install elasticsearch:
# yum install elasticsearch -y
Set elasticsearch to start automatically using systemd:
# systemctl daemon-reload && systemctl enable elasticsearch.service
Set hostname to be resolved locally using /etc/hosts. Use DNS if you have one:
# cat /etc/hosts
192.168.10.10 node1
Bind hostname to elasticsearch, by uncommenting below line in /etc/elasticsearch/elasticsearch.yml. The node name can be anything to your liking, but must be similar to the one set in step 5:
network.host: node1
Set bootstrap memory lock to be true in /etc/elasticsearch/elasticsearch.yml
bootstrap.memory_lock: true
Set maximum number of memory bytes that may be locked into RAM in /usr/lib/systemd/system/elasticsearch.service, by uncommenting below line
LimitMEMLOCK=infinity
Reload systemctl
# systemctl daemon-reload
Set java heap size for elasticsearch to use in /etc/sysconfig/elasticsearch(rule of thumb, use ½ of your physical memory. In this example 2GB for system with 4GB):
ES_JAVA_OPTS="-Xms2g -Xmx2g"
MAX_OPEN_FILES=65536
MAX_LOCKED_MEMORY=unlimited
The config file will look like below:
# grep -v ^# /etc/sysconfig/elasticsearch | grep -v ^$
ES_JAVA_OPTS="-Xms2g -Xmx2g"
MAX_OPEN_FILES=65536
MAX_LOCKED_MEMORY=unlimited
Set file limits for elasticsearch in /etc/security/limits.conf (this change needs reboot for the change to take effect):
elasticsearch - nofile 65535
elasticsearch - memlock unlimited
The config file will look like below:
# grep -v ^# /etc/security/limits.conf | grep -v ^$ | tail -5
elasticsearch - nofile 65535
elasticsearch - memlock unlimited
Reboot the machine
# reboot
Stop & start elasticsearch:
# systemctl stop elasticsearch.service && systemctl start elasticsearch.service
Test whether elasticsearch is running, output should be something like below:
# curl -XGET node1:9200/?pretty
{
"name" : "Cp8oag6",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : {
"number" : "5.0.0",
"build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,
"lucene_version" : "6.2.0"
},
"tagline" : "You Know, for Search"
}
Prepared by :
Date : 2 Dec 2016
Last updated: 31 August 2017