Elasticsearch - Installation and general settings
Installation of Elasticsearch is a breeze by which I mean it's as simple as downloading the zip/tar file and unzipping it.
1 2 3 4 | $ 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
1 2 3 4 | #elasticsearch.yml path.data: /var/elasticsearch/data path.logs: /var/elasticsearch/logs path.work: /tmp/elasticsearch |
1 2 3 4 5 6 | #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 |
But lets say that we using a package manager or puppet scripts to install elasticsearch and now we have no idea where the config files and data directories located. One easy way to get these information is to curl the elasticsearch node endpoint which returns back all the information regarding each node with all path and configuration information
1 2 3 4 5 6 7 8 9 10 11 12 13 | $ 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" } |
OK, now that we have elasticsearch unzipped and the data directory setup, lets update some minimal but essential Elasticsearch configuration:
1 2 3 4 5 | #elasticsearch.yml cluster.name: es-test-cluster node.name: es-node-1 node.master: true node.data: true |
Note that if the node.name is not provided, Elasticsearch automatically assigns a node name based on Marvel comic characters. This is fine as long as Elasticsearch process does not restart as it will assign a new name again which could be trouble if you are monitoring the ES process by node names.
Now that we have the basic elasticsearch settings updated/added, we can start elasticsearch by running:
1 2 3 4 5 | $ /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 |
Labels: Elasticsearch
<< Home