How to run Elasticsearch 6 on an Apple Silicon Mac?
For developing an application, I need to run Elasticsearch 6 on an Apple Silicon Mac.
I've tried to run it with Docker. Reading Docker Desktop for Apple silicon, I've installed Rosetta2 with:
softwareupdate --install-rosetta
And added the --platform linux/amd64
command line option.
Running:
docker run -d --platform linux/amd64 --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.8.18
I obtain the warning about the AVX instruction set:
OpenJDK 64-Bit Server VM warning: UseAVX=2 is not supported on this CPU, setting it to UseAVX=0
So I added the command line option : -e "ES_JAVA_OPTS=-XX:UseAVX=0"
, but I still obtain:
[2021-08-22T00:06:20,727][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: org.elasticsearch.bootstrap.BootstrapException: java.io.IOException: Cannot run program "/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller": error=0, Failed to exec spawn helper: pid: 131, exit value: 1
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.18.jar:6.8.18]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.18.jar:6.8.18]
Caused by: org.elasticsearch.bootstrap.BootstrapException: java.io.IOException: Cannot run program "/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller": error=0, Failed to exec spawn helper: pid: 131, exit value: 1
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.18.jar:6.8.18]
... 6 more
Caused by: java.io.IOException: Cannot run program "/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller": error=0, Failed to exec spawn helper: pid: 131, exit value: 1
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1142) ~[?:?]
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) ~[?:?]
at org.elasticsearch.bootstrap.Spawner.spawnNativeController(Spawner.java:118) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Spawner.spawnNativeControllers(Spawner.java:86) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:165) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.18.jar:6.8.18]
... 6 more
Caused by: java.io.IOException: error=0, Failed to exec spawn helper: pid: 131, exit value: 1
at java.lang.ProcessImpl.forkAndExec(Native Method) ~[?:?]
at java.lang.ProcessImpl.<init>(ProcessImpl.java:313) ~[?:?]
at java.lang.ProcessImpl.start(ProcessImpl.java:244) ~[?:?]
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1109) ~[?:?]
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) ~[?:?]
at org.elasticsearch.bootstrap.Spawner.spawnNativeController(Spawner.java:118) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Spawner.spawnNativeControllers(Spawner.java:86) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:165) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.18.jar:6.8.18]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.18.jar:6.8.18]
... 6 more
Then I look at Machine learning settings in Elasticsearchedit , where it states:
Machine learning uses SSE4.2 instructions, so it works only on machines whose CPUs support SSE4.2. If you run Elasticsearch on older hardware, you must disable machine learning (by setting xpack.ml.enabled to false).
So I added the command line option: -e"xpack.ml.enabled=false"
, Elasticsearch now starts but nothing appears in the log and it doesn't answer to requests.
My question is: How to run Elasticsearch 6 on an Apple Silicon Mac ?
Solution 1:
This is generally not supported, but there is a report that https://hub.docker.com/r/webhippie/elasticsearch/ might work.
If you didn't have a good reason to upgrade yet, maybe running it on M1 might help? Native support (without Rosetta) has been added in 7.12.
Solution 2:
I just had this issue, i worked out that you can run elasticsearch using the curl instructions here, but wanted to use docker.
To do this, I organized files like this:
.
├── Dockerfile-elastic
└── elasticsearch.yml
Dockerfile:
# Dockerfile-elastic.yml
FROM arm64v8/openjdk:8-jdk-buster
WORKDIR /usr
# add a non root user
RUN useradd -m elasticuser
# Download extras
RUN apt update
RUN apt install -y curl nano
# Download elasticsearch
RUN curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.23.tar.gz
RUN tar -xvf elasticsearch-6.8.23.tar.gz
# Add config
ADD elasticsearch.yml /usr/elasticsearch-6.8.23/config/elasticsearch.yml
RUN chown -R elasticuser: .
USER elasticuser
ENV JAVA_HOME=/usr/local/openjdk-18/bin/java
ENV discovery.type=single-node
ENV xpack.security.enabled: false
ENV xpack.ml.enabled: false
RUN cd elasticsearch-6.8.23/bin
RUN chown -R elasticuser: elasticsearch-6.8.23
EXPOSE 9200 9300
CMD cd /usr/elasticsearch-6.8.23/bin/ && ./elasticsearch
elasticsearch.yml:
# elasticsearch.yml
xpack.security.enabled: false
xpack.ml.enabled: false
http.host: 0.0.0.0
transport.host: 0.0.0.0
Commands:
Build: docker build -f Dockerfile-elastic -t elastic .
Run: docker run -p 9200:9200 -p 9300:9300 elastic