Installing Elasticsearch on macOS and Linux
A free video tutorial from Bo Andersen
4.5 instructor rating • 4 courses • 62,433 students
Learn how to install Elasticsearch on macOS and Linux.
Learn more from the full courseComplete Guide to Elasticsearch
Learn Elasticsearch from scratch and begin learning the ELK stack (Elasticsearch, Logstash & Kibana) and Elastic Stack.
12:10:23 of on-demand video • Updated September 2020
- How to build a powerful search engine with Elasticsearch
- The theory of Elasticsearch and how it works under-the-hood
- Write complex search queries
- Be proficient with the concepts and terminology of Elasticsearch
English In this lecture, I am going to show you how to install Elasticsearch on Mac or Linux. If you are using Windows, please continue to the next lecture. When I say "install Elasticsearch," that's probably not entirely accurate, though. We won't be installing Elasticsearch as an application, because Elasticsearch just consists of a bunch of "jar" files, being Java archives. In case you are not familiar with "jar" files, they are basically just files that aggregate Java class files, metadata, and resources. You can think of them as zip files for Java projects. Elasticsearch itself is packaged as a "jar" file, along with its dependencies such as Apache Lucene. With these "jar" files, running Elasticsearch is as simple as running a convenient script that is distributed together with the "jar" files. You will see that in a moment. The point is that we will not be installing anything, but rather downloading the files needed to run Elasticsearch. Elasticsearch ships with a version of OpenJDK, which means that you don't need to install Java. If you have it installed already, Elasticsearch will use the JVM pointed to by the "JAVA_HOME" environment variable; otherwise it will use the bundled OpenJDK for your convenience. Alright, so let's get to business! I have the download page for Elasticsearch opened up. To save you from some clicking around, I have attached the link to this lecture. Simply click on the download link that matches your operating system - either macOS or Linux in this case. Both of them are tarballs, so the process from here will be the same. I have moved the tarball to the desktop in advance, so the next thing I need to do, is to extract it. The easiest way to do it, is to double-click the file. I know this works on macOS, and I imagine that the same applies for Linux distributions. I am going to use the command line though, because then you also know how to do it on a remote server in case you need to set up Elasticsearch somewhere other than on your development machine. I have a terminal window opened up at the directory in which I placed the tarball - the desktop in this case. Now that the archive has been extracted, let's navigate to the extracted directory. I am going to show you the contents of this directory in a moment, but for now, let's just start up Elasticsearch to verify that everything works as intended. Doing so is extremely easy, as we just need to run a script named "elasticsearch" located within the "bin" directory. Elasticsearch is now starting up, and should be ready within a moment or two. Alright, Elasticsearch is now up and running. That was easy, wasn't it? Elasticsearch is running in the foreground, meaning that if you close the terminal window in which it is running, the process will be shut down. To shut it down more gracefully, you can press the CTRL and C keys simultaneously. Running Elasticsearch as a service (i.e. as a background process or daemon) is also easy, but that's a topic for later in the course. We don't see any errors within the output, so everything should work correctly. Just to be 100% sure, let's send a request to Elasticsearch. To be precise, we will send an HTTP request to the REST API. Elasticsearch is running on localhost at port 9200, so that's the endpoint that we will send a request to. To send the request, I will use the cURL command line tool, which should be available on your operating system. You are also free to use any other HTTP client, such as Postman. With cURL, all we need to do, is to write "curl" followed by the endpoint. This will use the "GET" HTTP verb by default. The response is a JSON object, meaning that everything is indeed working. That's all there is to (quote-unquote) "installing" Elasticsearch on macOS or Linux, so let's continue.