The first thing you need to do before installing Elasticsearch on OS X, is to ensure that you have at least version 7 of Java installed. This should be the case, but to be sure, open up your Terminal and enter the java -version command. If you see 1.7.X or 1.8.X in the output, then you are good to go.
Now it is time to download Elasticsearch. To do so, either navigate the download page in your browser or run the below command in your terminal. You should download either the .zip or the .tar.gz file.
curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.1.0/elasticsearch-2.1.0.tar.gz
Be sure to replace the above version with the most recent version!
Extracting the Archive
Next, you need to extract the archive that you just downloaded in the above step. To do so, simply find the file in Finder and double-click on it, or execute the below commands within the terminal.
cd /path/to/archive tar -zxvf elasticsearch-2.1.0.tar.gz
Again, be sure to replace the version number with the one that you downloaded.
Starting Elasticsearch on OS X
Now that you have successfully downloaded and extracted the archive, it is time to start Elasticsearch on your Mac. In your terminal, make sure that your working directory is the directory where you extracted the archive (you may move this directory around freely). Then run the following commands.
cd bin ./elasticsearch
The second command loads up Elasticsearch, and shortly after executing the above commands, you should begin to see some informational messages being output by Elasticsearch. Congratulations, your cluster is now running on your Mac!
Testing the Installation
To test that you have correctly installed Elasticsearch on OS X, simply open a new Terminal window and run the following command.
curl -X GET http://localhost:9200/
You should now see a JSON response being output in your terminal, indicating that everything is working as intended. Here we make use of cURL and Elasticsearch’s REST API.
As you can see, the installation is very, very easy and straight forward. Job well done!