- Using Homebrew
- Manual Elasticsearch Installation
When installing applications in a Unix-based operating system like OS X occasionally issues may arise. The reasons can range from missing dependencies that the new application relies on to incompatible versions of existing libraries and packages.
In this tutorial, we’ll explore two methods to help you properly install Elasticsearch on OS X.
Most OS X users should be familiar with
Homebrew (often simply called
brew). Homebrew is a basic package manager utility for OS X that allows for simple installation of other applications while Homebrew takes care of all the messy stuff in the background. For this reason, it is highly recommended that you use Homebrew to help you install Elasticsearch (or many other packages you may desire down the road).
If you don’t have Homebrew already installed, you can easily install it by following the instructions on the official homepage. As of the time of writing, this involves simply executing the below command in a terminal prompt, then following the on-screen instructions as necessary:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Brewing the Elasticsearch Formula
With Homebrew installed, you can then execute a few
brew commands to quickly install Elasticsearch and all the appropriate dependencies your system will need:
$ brew update $ brew install elasticsearch
Manual Elasticsearch Installation
If you need to manually install Elasticsearch, things become significantly more complicated, but it’s still possible if Homebrew won’t work for you.
If you haven’t done so recently, start by installing/updating Java on your system. If you plan to do development with Elasticsearch, get the JDK, otherwise the JRE will suffice. Both can be obtained from the official downloads page.
Download the latest release version of Elasticsearch from the official downloads page. Typically for OS X users you’ll want the
Copy the file into your preferred installation directory, then extract it. If working in a terminal, you can extract a
tar.gz file using the
tar -xvf [filename] command:
$ tar -xvf elasticsearch-2.3.1.tar.gz
Modify Your .bash_profile Variables
Next, open the
.bash_profile file in your home directory with your favorite text editor:
$ nano ~/.bash_profile
Within the profile you need to add/modify some
export lines to indicate the appropriate environment variables in order for Elasticsearch to function. Your file may have some of these present, and the values may be different, so double-check the values as necessary:
export ES_HOME=~/apps/elasticsearch/elasticsearch-2.3.1 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77/Contents/Home export PATH=$ES_HOME/bin:$JAVA_HOME/bin:$PATH
ES_HOMEvariable indicates the directory you installed (extracted) the
JAVA_HOMEis the home installation directory of your Java package (either JDK or JRE). Verify your own path and modify this variable if necessary.
PATHis, of course, the standard PATH variable that tells OS X where to find many executables. In this case, the export line is effectively adding onto the existing
PATHvariable so the system can find where Elasticsearch and Java are located.
Note: Be sure to close your terminal and open a new terminal window so that the
PATH variable will be properly updated.
Finally, you’re able to run Elasticsearch from the terminal window by simply executing the