Skip to content

Instantly share code, notes, and snippets.

@todgru
Created February 9, 2023 23:52
Show Gist options
  • Save todgru/0ba097d63318313f12a52594217f8e2b to your computer and use it in GitHub Desktop.
Save todgru/0ba097d63318313f12a52594217f8e2b to your computer and use it in GitHub Desktop.
Install Elasticsearch 7.x on Apple Macbook Pro M1 Ventura 13.2

Elasticsearch Setup Apple MacBook Pro M1

Apple MacBook Pro M1, 32 GB, Ventura 13.2

Documentation based on comments in this Github Elasticsearch issue.

Install Homebrew

Install Homebrew if not yet installed.

Verify Homebrew is a recent version:

$ brew --version
Homebrew 3.6.21
Homebrew/homebrew-core (git revision c26f1c8714c; last commit 2023-02-08)
Homebrew/homebrew-cask (git revision b69d2bf867; last commit 2023-02-08)

Install Elasticsearch and OpenJDK

brew tap elastic/tap
brew install elastic/tap/elasticsearch-full
brew install openjdk

Symlink OpenJDK so the system Java wrappers can find it. This information is also displayed as a Homebrew “caveat” after installing OpenJDK.

sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Modify Elasticsearch .plist to use the OpenJDK

Edit Elasticsearch homebrew.mxcl.elasticsearch-full.plist to use the OpenJDK:

code /opt/homebrew/Cellar/elasticsearch-full/7.17.4/homebrew.mxcl.elasticsearch-full.plist

Find the full path to OpenJDK:

/usr/libexec/java_home

Insert the following before the last closing </dict>:

    <key>EnvironmentVariables</key>
    <dict>
      <key>ES_JAVA_HOME</key>
      <string>insert the full path from /usr/libexec/java_home here</string>
    </dict>

The entire homebrew.mxcl.elasticsearch-full.plist should look like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <false/>
    <key>Label</key>
    <string>homebrew.mxcl.elasticsearch-full</string>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/homebrew/opt/elasticsearch-full/bin/elasticsearch</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
    </dict>
    <key>RunAtLoad</key>
    <true/>
    <key>WorkingDirectory</key>
    <string>/opt/homebrew/var</string>
    <key>StandardErrorPath</key>
    <string>/opt/homebrew/var/log/elasticsearch.log</string>
    <key>StandardOutPath</key>
    <string>/opt/homebrew/var/log/elasticsearch.log</string>
    <key>EnvironmentVariables</key>
    <dict>
      <key>ES_JAVA_HOME</key>
      <string>/opt/homebrew/Cellar/openjdk/19.0.2/libexec/openjdk.jdk/Contents/Home</string>
    </dict>
  </dict>
</plist>

Modify Elasticsearch YML

echo "\nxpack.ml.enabled: false\n" >> /opt/homebrew/etc/elasticsearch/elasticsearch.yml

Set ES_JAVA_HOME

Add the ES_JAVA_HOME environment variable by setting to ~/.zshrc:

echo "\nexport ES_JAVA_HOME=$(/usr/libexec/java_home)\n" >> ~/.zshrc

Run and Test Elasticsearch

In a new shell, launch Elasticsearch:

elasticsearch

In a new shell, curl the local Elasticsearch URL:

$ curl -s http://localhost:9200

Example output:

{
  "name" : "my-machine",
  "cluster_name" : "elasticsearch_foo_bar",
  "cluster_uuid" : "some-uuid",
  "version" : {
    "number" : "7.17.4",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "build-hash",
    "build_date" : "2022-05-18T18:04:20.964345128Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
Copy link

ghost commented Jun 14, 2024

source ~/.zshrc before running elasticsearch command

@ashanp
Copy link

ashanp commented Jun 26, 2024

Thank you, works fine in one go. works great in M3 chipset as well.

@frosit
Copy link

frosit commented Aug 15, 2024

works on an old 2012 mbp opencore monterey as well, besides the /opt paths.

@brandonpark
Copy link

worked perfect m3 max on macOS Sonoma 14.5

@dendyb
Copy link

dendyb commented Oct 7, 2024

Oct 7, 2024, work perfectly on Sequoia 15.0.1 (M1, 2020) thank you very much

@abhishek2432001
Copy link

Thank you!

@dang-n-309
Copy link

Thank you so much! You saved my life! <3

@tomhundt
Copy link

tomhundt commented Aug 9, 2025

This worked for me on M1 MBP, Sequoia 15.7 beta.

  • Did not have to put ES_JAVA_HOME definition into the /opt/homebrew/Cellar/elasticsearch-full/7.17.4/homebrew.mxcl.elasticsearch-full.plist file.
  • Did add export ES_JAVA_HOME=$(/usr/libexec/java_home) to my shell profile.
  • Did have to downgrade to openjdk@17 (and uninstall the default openjdk one, which is 24 right now). This is because 17 still has Security Manager, and otherwise you get errors about it being no longer supported. source If you do this, make sure you undo/redo the symlinks in the brew output.
  • Did brew install elasticvue -- because it looks useful

If I start running into problems with 7.17.4, there are instructions on getting the "fixed" 7.17.14 here so I'll try that next. At this point I'm just glad it's working ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment