กรุณาปิด โปรแกรมบล๊อกโฆษณา เพราะเราอยู่ได้ด้วยโฆษณาที่ท่านเห็น
Please close the adblock program. Because we can live with the ads you see


Install Elasticsearch and OpenJDK MacOS Sonoma 14.8

วิธีการทํา Install Elasticsearch and OpenJDK MacOS Sonoma 14.8

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 Elasticsearch homebrew.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>
The entire homebrew.mxcl.elasticsearch-full.plist should look like:

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
In a new shell, curl the local Elasticsearch URL:
Bash:
$ curl -s http://localhost:9200
Example output:
2025-09-26_13-29-27.webp
 


กลับ
ยอดนิยม ด้านล่าง