Installing Elasticsearch 5.4 on Mac OS 10

The easiest way to install Elasticsearch is using brew. However it failed to install on my Mac OS 10.9.5

Failed Installation using Brew

You can use Brew:

brew update
brew install elasticsearch

This failed with:

elasticsearch: Java 1.8+ is required to install this formula.
JavaRequirement unsatisfied!

You can install with Homebrew-Cask:
  brew cask install java

You can download from:
  https://www.oracle.com/technetwork/java/javase/downloads/index.html
Error: An unsatisfied requirement failed this build.

Install Java:

brew cask install java

Install elasticsearch:

brew install elasticsearch
Error: elasticsearch 1.7.1 is already installed
To upgrade to 5.4.0, run `brew upgrade elasticsearch`

I had older version installed, to update:

brew upgrade elasticsearch

This installed elasticsearch 5.4.0 on my Mac. To start the ElasticSearch server:

/bin/elasticsearch
-bash: /bin/elasticsearch: No such file or directory
~/projects/lafon $which elasticsearch
/usr/local/bin/elasticsearch

Run:

/usr/local/bin/elasticsearch

This gave 'Permission denied' error. If you run it as sudo:

sudo /usr/local/bin/elasticsearch

 can not run elasticsearch as root

Running chmod or chown:

$chmod 777 /usr/local/var/log/elasticsearch
$chown bparanj /usr/local/var/log/elasticsearch

did not help.

Installing from Source

Installing from source is another option. Java 8 (only Oracle’s Java) is the prerequisite. Check if Java is installed on your machine.

java -v
No Java runtime present, requesting install.

Let's install Java version 1.8.0_73 or later. Download Java and run the installer to install Java. Go to control panel and click on Java to check the installed version. Install wget:

$ brew install wget

Download Elasticsearch:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.zip

You can also use Curl:

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz

and extract it using tar:

tar -xvf elasticsearch-5.4.0.tar.gz

Check sha1sum:

$ brew install md5sha1sum

sha1sum elasticsearch-5.4.0.zip
6ca6f8157fe2bb6b9d07ac6c77a96a5ff366e420  elasticsearch-5.4.0.zip

Go to https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz.sha1. The downloaded file will contain the sha. Compare the sha output from the terminal to the sha in the downloaded file. They should match.

$ ./bin/elasticsearch

No Java runtime present, requesting install.
Elasticsearch requires at least Java 8 but your Java version from /usr/bin/java does not meet this requirement

You need JDK not JRE, download Java SE Development Kit and install it. Check the version in the terminal:

$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Go to the directory where you unzipped the elasticsearch zip file, elasticsearch-5.4.0 directory and run:

$ ./bin/elasticsearch

Check Elastisearch installation:

$ curl -XGET 'localhost:9200/?pretty'
{
  "name" : "hnG_yFT",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "dk03YftTQrO6qH0iLxSkHg",
  "version" : {
    "number" : "5.4.0",
    "build_hash" : "780f8c4",
    "build_date" : "2017-04-28T17:43:27.229Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.0"
  },
  "tagline" : "You Know, for Search"
}

Testing Elasticsearch Installation

These steps in this article are tested on Mac OS. If you want to install it on a production box running Linux, you can use Ansible playbook for Elasticsearch. It is tested on Ubutu 14.04.

Useful Tips

Where is the Elasticsearch home directory?

curl "localhost:9200/_nodes/settings?pretty=true"
{
  "ok" : true,
  "cluster_name" : "rpcluster",
  "nodes" : {
    "NI-BTti6TxSLbGpJZ8Dhqw" : {
      "name" : "li552-13",
      "transport_address" : "inet[/198.58.102.13:9300]",
      "hostname" : "li552-13.members.linode.com",
      "version" : "0.90.12",
      "http_address" : "inet[/198.58.102.13:9200]",
      "attributes" : {
        "master" : "true"
      },
      "settings" : {
        "path.logs" : "/var/log/elasticsearch",
        "path.work" : "/tmp/elasticsearch",
        "path.conf" : "/etc/elasticsearch",
        "path.data" : "/var/lib/elasticsearch",
        "path.home" : "/usr/share/elasticsearch",
        "pidfile" : "/var/run/elasticsearch.pid",
        "script.disable_dynamic" : "true",
        "index.search.slowlog.threshold.query.trace" : "500ms",
        "transport.tcp.compress" : "true",
        "gateway.recover_after_nodes" : "1",
        "index.search.slowlog.threshold.query.debug" : "2s",
        "transport.tcp.port" : "9300",
        "index.search.slowlog.threshold.fetch.info" : "800ms",
        "index.indexing.slowlog.threshold.index.trace" : "500ms",
        "discovery.zen.minimum_master_nodes" : "1",
        "http.enabled" : "true",
        "node.master" : "true",
        "index.indexing.slowlog.threshold.index.debug" : "2s",
        "index.search.slowlog.threshold.query.info" : "5s",
        "transport.tcp.connect_timeout" : "10s",
        "index.indexing.slowlog.threshold.index.warn" : "10s",
        "index.search.slowlog.threshold.fetch.trace" : "200ms",
        "gateway.expected_nodes" : "1",
        "node.data" : "true",
        "cluster.name" : "rpcluster",
        "http.port" : "9200",
        "bootstrap.mlockall" : "true",
        "index.number_of_replicas" : "1",
        "index.search.slowlog.threshold.fetch.warn" : "1s",
        "gateway.type" : "local",
        "gateway.recover_after_time" : "30s",
        "node.name" : "li552-13",
        "discovery.zen.ping.multicast.enabled" : "false",
        "discovery.zen.ping.timeout" : "30s",
        "index.number_of_shards" : "5",
        "index.search.slowlog.threshold.fetch.debug" : "500ms",
        "http.max_content_length" : "100mb",
        "index.search.slowlog.threshold.query.warn" : "10s",
        "index.indexing.slowlog.threshold.index.info" : "5s",
        "name" : "li552-13"
      }
    }
  }
}

Look at the entry for settings -- path -- home:

"path.home" : "/usr/share/elasticsearch"

Where is elasticsearch.yml?

You can see it in the output as path.conf, this directory has the elasticsearch.yml file.

References


Related Articles