How to start Cassandra on a (M1) Macbook?

Viewed 2366

I can't get Cassandra (3.11.10) to start on my Macbook with M1 chip. It gives the following error messages:

ERROR [main] 2021-07-09 13:12:46,807 NativeLibraryDarwin.java:64 - Failed to link the C library against JNA. Native methods will be unavailable.
java.lang.UnsatisfiedLinkError: /Users/tom/apache-cassandra-3.11.10/tmp/jna8890560385007025439.tmp: dlopen(/Users/tom/apache-cassandra-3.11.10/tmp/jna8890560385007025439.tmp, 1): no suitable image found.  Did find:
        /Users/tom/apache-cassandra-3.11.10/tmp/jna8890560385007025439.tmp: no matching architecture in universal wrapper
        /Users/tom/apache-cassandra-3.11.10/tmp/jna8890560385007025439.tmp: no matching architecture in universal wrapper

I'm using OpenJDK 1.8.0_292 (Azul Zulu).

3 Answers

I found that replacing the JNA jar in Cassandra's lib directory (for example apache-cassandra-3.11.10/lib/jna-4.2.12.jar) with the latest (5.8.0, from https://search.maven.org/artifact/net.java.dev.jna/jna/5.8.0/jar) fixes the problem. At least just to get a development environment going.

Unfortunately, the JNA (v4.2.2) JAR which ships with Cassandra 3.11 (and 4.0 soon) does not include the patch which allows builds for Apple M1's Darwin arm64 (see JNA PR #1238).

At the time of writing, there isn't a workaround available but if you just want to try using Cassandra, you can launch a Cassandra database on Astra on the free-tier and it doesn't require a credit card. It comes bundled with Stargate.io -- a data access platform which allows you to connect to a Cassandra cluster using REST API, GraphQL API or JSON/Doc API so you can build an app immediately without having to download/install/configure Cassandra.

Alternatively, you can try K8ssandra.io -- a cloud-native distribution of Cassandra that runs on Kubernetes with all the tools bundled in for automated repairs, backups, monitoring with Prometheus + Grafana, and Stargate.io. Cheers!

For cassandra-4.0.1 on M1 use jna-5.10.0 to replace the jna jar. You can get that jar if you have maven installed and execute

mvn dependency:get -Dartifact=net.java.dev.jna:jna:5.10.0

then you can find the jar in ~/.m2/repostory/net/java/dev/jna

Related