Elasticsearch 在 macOS 上启动失败

Elasticsearch failed to start on macos

我在 macos Monterey 上使用 brew 安装了 Elasticsearch

brew install elasticsearch

但是我无法启动服务

brew services start elasticsearch

brew info elasticsearch

这是日志

warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release
warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release
Exception in thread "main" java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
at java.base/java.lang.System.setSecurityManager(System.java:416)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82)

如果你运行:

brew info elasticsearch

你会看到:

Deprecated because it is switching to an incompatible license. Check out opensearch instead!

所以您应该使用 opensearch,即:

a community-driven, open source search and analytics suite derived from Apache 2.0 licensed Elasticsearch 7.10.2 & Kibana 7.10.2.

或者如果您想继续使用 Elasticsearch,请使用 official installation method for macOS,其中包括使用 tar.gz:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz.sha512
shasum -a 512 -c elasticsearch-8.1.2-linux-x86_64.tar.gz.sha512 
tar -xzf elasticsearch-8.1.2-linux-x86_64.tar.gz
cd elasticsearch-8.1.2/

或者你可以使用官方 Docker image.