Quickstart

    The Docker Compose commands used in this guide are written with a hyphen (for example, ). If you installed Docker Desktop on your machine, which automatically installs a bundled version of Docker Compose, then you should remove the hyphen. For example, change docker-compose to docker compose.

    You’ll need a special file, called a Compose file, that Docker Compose uses to define and create the containers in your cluster. The OpenSearch Project provides a sample Compose file that you can use to get started. Learn more about working with Compose files by reviewing the official .

    1. Before running OpenSearch on your machine, you should disable memory paging and swapping performance on the host to improve performance and increase the number of memory maps available to OpenSearch. See important system settings for more information.

    2. Download the sample Compose file to your host. You can download the file with command line utilities like curl and wget, or you can manually copy from the OpenSearch Project documentation-website repository using a web browser.

      1. # Using cURL:
      2. curl -O https://raw.githubusercontent.com/opensearch-project/documentation-website/2.7/assets/examples/docker-compose.yml
      3. # Using wget:
      4. wget https://raw.githubusercontent.com/opensearch-project/documentation-website/2.7/assets/examples/docker-compose.yml
    3. In your terminal application, navigate to the directory containing the docker-compose.yml file you just downloaded, and run the following command to create and start the cluster as a background process.

      1. docker-compose up -d
    4. Confirm that the containers are running with the command docker-compose ps. You should see an output like the following:

      1. $ docker-compose ps
      2. NAME COMMAND SERVICE STATUS PORTS
      3. opensearch-dashboards "./opensearch-dashbo…" opensearch-dashboards running 0.0.0.0:5601->5601/tcp
      4. opensearch-node1 "./opensearch-docker…" opensearch-node1 running 0.0.0.0:9200->9200/tcp, 9300/tcp, 0.0.0.0:9600->9600/tcp, 9650/tcp
      5. opensearch-node2 "./opensearch-docker…" opensearch-node2 running 9200/tcp, 9300/tcp, 9600/tcp, 9650/tcp
    5. Query the OpenSearch REST API to verify that the service is running. You should use -k (also written as --insecure) to disable host name checking because the default security configuration uses demo certificates. Use -u to pass the default username and password (admin:admin).

      1. {
      2. "name" : "opensearch-node1",
      3. "cluster_uuid" : "W0B8gPotTAajhMPbC9D4ww",
      4. "version" : {
      5. "number" : "2.6.0",
      6. "build_type" : "tar",
      7. "build_hash" : "7203a5af21a8a009aece1474446b437a3c674db6",
      8. "build_date" : "2023-02-24T18:58:37.352296474Z",
      9. "build_snapshot" : false,
      10. "lucene_version" : "9.5.0",
      11. "minimum_wire_compatibility_version" : "7.10.0",
      12. "minimum_index_compatibility_version" : "7.0.0"
      13. },
      14. "tagline" : "The OpenSearch Project: https://opensearch.org/"
      15. }
    6. Explore OpenSearch Dashboards by opening http://localhost:5601/ in a web browser on the same host that is running your OpenSearch cluster. The default username is admin and the default password is admin.

    Create an index and define field mappings using a dataset provided by the OpenSearch Project. The same fictitious e-commerce data is also used for sample visualizations in OpenSearch Dashboards. To learn more, see .

    1. Download ecommerce-field_mappings.json. This file defines a for the sample data you will use.

      1. # Using cURL:
      2. curl -O https://raw.githubusercontent.com/opensearch-project/documentation-website/2.7/assets/examples/ecommerce-field_mappings.json
      3. # Using wget:
      4. wget https://raw.githubusercontent.com/opensearch-project/documentation-website/2.7/assets/examples/ecommerce-field_mappings.json
    2. Download ecommerce.json. This file contains the index data formatted so that it can be ingested by the bulk API. To learn more, see and Bulk.

      1. # Using cURL:
      2. curl -O https://raw.githubusercontent.com/opensearch-project/documentation-website/2.7/assets/examples/ecommerce.json
      3. # Using wget:
    3. Define the field mappings with the mapping file.

    4. Upload the index to the bulk API.

      1. curl -H "Content-Type: application/x-ndjson" -X PUT "https://localhost:9200/ecommerce/_bulk" -ku admin:admin --data-binary "@ecommerce.json"
    5. Query the data using the search API. The following command submits a query that will return documents where customer_first_name is .

      1. curl -H 'Content-Type: application/json' -X GET "https://localhost:9200/ecommerce/_search?pretty=true" -ku admin:admin -d' {"query":{"match":{"customer_first_name":"Sonya"}}}'
    6. Access OpenSearch Dashboards by opening http://localhost:5601/ in a web browser on the same host that is running your OpenSearch cluster. The default username is admin and the default password is admin.

    7. On the top menu bar, go to Management > Dev Tools.
    8. In the left pane of the console, enter the following:

      1. GET ecommerce/_search
      2. {
      3. "query": {
      4. "match": {
      5. "customer_first_name": "Sonya"
      6. }
      7. }
      8. }
    9. Choose the triangle icon at the top right of the request to submit the query. You can also submit the request by pressing Ctrl+Enter (or Cmd+Enter for Mac users). To learn more about using the OpenSearch Dashboards console for submitting queries, see .

    You successfully deployed your own OpenSearch cluster with OpenSearch Dashboards and added some sample data. Now you’re ready to learn about configuration and functionality in more detail. Here are a few recommendations on where to begin:

    Review these common issues and suggested solutions if your containers fail to start or exit unexpectedly.

    Eliminate the need for running your Docker commands with sudo by adding your user to the docker user group. See Docker’s for more information.

    If you installed Docker Desktop, then Docker Compose is already installed on your machine. Try docker compose (without the hyphen) instead of docker-compose. See .

    OpenSearch will fail to start if your host’s vm.max_map_count is too low. Review the important system settings if you see the following errors in the service log, and set vm.max_map_count appropriately.

    1. opensearch-node1 | ERROR: [1] bootstrap checks failed
    2. opensearch-node1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    3. opensearch-node1 | ERROR: OpenSearch did not exit normally - check the logs at /usr/share/opensearch/logs/opensearch-cluster.log