Product Engineer, CTO & a Beer Enthusiast
Experiments, thoughts and scripts documented for posterity.
Sep, 2014
Installation of Elasticsearch is a breeze by which I mean it's as simple as downloading the zip/tar file and unzipping it.
$ wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.zip
$ unzip elasticsearch-1.3.2.zip -d /usr/share/elasticsearch
$ /usr/share/elasticsearch/bin/plugin -install mobz/elasticsearch-head
$ /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-cloud-aws/2.3.0
In the above bash script, we are essentially downloading the file, unzipping and installing couple of plugins for administration and cloud discovery. Now that we have Elasticsearch unzipped, we can optionally provide location to it's data, log and configuration folder. There are two ways to provide Elastisearch this configuration. First way is to provide the paths in the yml configuration file elasticsearch.yml. For example
#elasticsearch.yml
path.data: /var/elasticsearch/data
path.logs: /var/elasticsearch/logs
path.work: /tmp/elasticsearch
Second way is running Elasticsearch in daemon mode, you can setup the paths in the sysconfig file generally located at /etc/sysconfig/elasticsearch. The configuration in this file is passed onto ES as command line settings when elasticsearch is started.
#vi /etc/sysconfig/elasticsearch
LOG_DIR=/var/log/elasticsearch
DATA_DIR=/var/lib/elasticsearch
WORK_DIR=/tmp/elasticsearch
CONF_DIR=/etc/elasticsearch
CONF_FILE=/etc/elasticsearch/elasticsearch.yml
Note that the configuration in the elasticsearch.yml file overrides the sysconfig file
$ curl http://localhost:9200/_nodes?pretty
"path" : {
"conf" : "/etc/elasticsearch",
"data" : "/var/elasticsearch/data",
"logs" : "/var/elasticsearch/logs",
"work" : "/tmp/elasticsearch",
"home" : "/usr/share/elasticsearch"
},
"node" : {
"data" : "true",
"master" : "true"
}
More information on the directory structure can be found at Elasticsearch Directory layout
#elasticsearch.yml
cluster.name: es-test-cluster
node.name: es-node-1
node.master: true
node.data: true
List of all configuration can be found at: Elasticsearch configuration file
$ /usr/share/elasticsearch/bin/elasticsearch
#(or) in daemon mode
$ /usr/share/elasticsearch/bin/elasticsearch -d
#(or) using init.d script if one installed by the package manager
$ /etc/init.d/elasticsearch start