Apple MacBook Pro 2020, 16 GB, Sonoma 14.8
Documentation based on comments in this Github Elasticsearch issue and my self issue.Install Homebrew
Install Elasticsearch 7.17.4 and OpenJDK@21
Bash:
brew tap elastic/tap
brew install elastic/tap/elasticsearch-full
brew install openjdk@21
Symlink OpenJDK so the system Java wrappers can find it. This information is also displayed as a Homebrew “caveat” after installing OpenJDK.
Bash:
sudo ln -sfn /usr/local/opt/openjdk@21/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdk
Modify Elasticsearch .plist to use the OpenJDK
Edit Elasticsearchhomebrew.mxcl.elasticsearch-full.plist
to use the OpenJDK:/usr/local/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>
AppleScript:
<?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>/usr/local/Cellar/openjdk@21/21.0.8/libexec/openjdk.jdk/Contents/Home</string>
</dict>
</dict>
</plist>
Modify Elasticsearch YML
Bash:
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:
Bash:
echo "\nexport ES_JAVA_HOME=$(/usr/libexec/java_home)\n" >> ~/.zshrc
Run and Test Elasticsearch
In a new shell, launch Elasticsearch:
Bash:
brew services start elasticsearch-full
Bash:
$ curl -s http://localhost:9200