Get Elasticsearch up and runningedit

To take Elasticsearch for a test drive, you can create a hosted deployment on the Elasticsearch Service or set up a multi-node Elasticsearch cluster on your own Linux, macOS, or Windows machine.

Run Elasticsearch on Elastic Cloudedit

When you create a deployment on the Elasticsearch Service, the service provisions a three-node Elasticsearch cluster along with Kibana and APM.

To create a deployment:

  1. Sign up for a free trial and verify your email address.
  2. Set a password for your account.
  3. Click Create Deployment.

Once you’ve created a deployment, you’re ready to Index some documents.

Run Elasticsearch locally on Linux, macOS, or Windowsedit

When you create a deployment on the Elasticsearch Service, a master node and two data nodes are provisioned automatically. By installing from the tar or zip archive, you can start multiple instances of Elasticsearch locally to see how a multi-node cluster behaves.

To run a three-node Elasticsearch cluster locally:

  1. Download the Elasticsearch archive for your OS:

    Linux: elasticsearch-7.5.2-linux-x86_64.tar.gz

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.2-linux-x86_64.tar.gz

    macOS: elasticsearch-7.5.2-darwin-x86_64.tar.gz

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.2-darwin-x86_64.tar.gz

    Windows: elasticsearch-7.5.2-windows-x86_64.zip

  2. Extract the archive:

    Linux:

    tar -xvf elasticsearch-7.5.2-linux-x86_64.tar.gz

    macOS:

    tar -xvf elasticsearch-7.5.2-darwin-x86_64.tar.gz

    Windows PowerShell:

    Expand-Archive elasticsearch-7.5.2-windows-x86_64.zip
  3. Start Elasticsearch from the bin directory:

    Linux and macOS:

    cd elasticsearch-7.5.2/bin
    ./elasticsearch

    Windows:

    cd elasticsearch-7.5.2\bin
    .\elasticsearch.bat

    You now have a single-node Elasticsearch cluster up and running!

  4. Start two more instances of Elasticsearch so you can see how a typical multi-node cluster behaves. You need to specify unique data and log paths for each node.

    Linux and macOS:

    ./elasticsearch -Epath.data=data2 -Epath.logs=log2
    ./elasticsearch -Epath.data=data3 -Epath.logs=log3

    Windows:

    .\elasticsearch.bat -E path.data=data2 -E path.logs=log2
    .\elasticsearch.bat -E path.data=data3 -E path.logs=log3

    The additional nodes are assigned unique IDs. Because you’re running all three nodes locally, they automatically join the cluster with the first node.

  5. Use the cat health API to verify that your three-node cluster is up running. The cat APIs return information about your cluster and indices in a format that’s easier to read than raw JSON.

    You can interact directly with your cluster by submitting HTTP requests to the Elasticsearch REST API. If you have Kibana installed and running, you can also open Kibana and submit requests through the Dev Console.

    You’ll want to check out the Elasticsearch language clients when you’re ready to start using Elasticsearch in your own applications.

    GET /_cat/health?v

    The response should indicate that the status of the elasticsearch cluster is green and it has three nodes:

    epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
    1565052807 00:53:27  elasticsearch green           3         3      6   3    0    0        0             0                  -                100.0%

    The cluster status will remain yellow if you are only running a single instance of Elasticsearch. A single node cluster is fully functional, but data cannot be replicated to another node to provide resiliency. Replica shards must be available for the cluster status to be green. If the cluster status is red, some data is unavailable.

Talking to Elasticsearch with cURL commandsedit

Most of the examples in this guide enable you to copy the appropriate cURL command and submit the request to your local Elasticsearch instance from the command line.

A request to Elasticsearch consists of the same parts as any HTTP request:

curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'

This example uses the following variables:

<VERB>
The appropriate HTTP method or verb. For example, GET, POST, PUT, HEAD, or DELETE.
<PROTOCOL>
Either http or https. Use the latter if you have an HTTPS proxy in front of Elasticsearch or you use Elasticsearch security features to encrypt HTTP communications.
<HOST>
The hostname of any node in your Elasticsearch cluster. Alternatively, use localhost for a node on your local machine.
<PORT>
The port running the Elasticsearch HTTP service, which defaults to 9200.
<PATH>
The API endpoint, which can contain multiple components, such as _cluster/stats or _nodes/stats/jvm.
<QUERY_STRING>
Any optional query-string parameters. For example, ?pretty will pretty-print the JSON response to make it easier to read.
<BODY>
A JSON-encoded request body (if necessary).

If the Elasticsearch security features are enabled, you must also provide a valid user name (and password) that has authority to run the API. For example, use the -u or --u cURL command parameter. For details about which security privileges are required to run each API, see REST APIs.

Elasticsearch responds to each API request with an HTTP status code like 200 OK. With the exception of HEAD requests, it also returns a JSON-encoded response body.

Other installation optionsedit

Installing Elasticsearch from an archive file enables you to easily install and run multiple instances locally so you can try things out. To run a single instance, you can run Elasticsearch in a Docker container, install Elasticsearch using the DEB or RPM packages on Linux, install using Homebrew on macOS, or install using the MSI package installer on Windows. See Installing Elasticsearch for more information.