An Essential Guide to installing Cassandra on MacOS, including addressing a SIGSEGV Error in your Java Development Environment

Derek W. Warner-Reyes
3 min readDec 10, 2020

--

Here’s a quick-start guide to installing Cassandra on MacOS. Adapted in part from this awesome guide by Manish Yadav. If you need help learning CQL check this out (thanks TutorialsPoint!), and here’s a great doc from Apache on designing a schema for your Cassie database- err, keyspace.

Lou Bega, who referenced ‘a little bit of Cassandra in the Sun’ in the famous hit Mambo No. 5

First, dependencies:

python 3

pip3 install — upgrade pip setuptools

Java

brew cask install java

brew tap AdoptOpenJDK/openjdk

brew install adoptopenjdk8

Next, check for the java kit you just installed:

/usr/libexec/java_home -V

You can expect to see something like so:

Matching Java Virtual Machines (1):

1.8.0_275, x86_64: “AdoptOpenJDK 8” /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Note the version number of JDK we just installed, which I have bolded for readability. Next we use the following command to switch the default kit to that version (also bolded below:)

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_275`

Now when you run…

java -version

… you can expect to see something like this:

openjdk version “1.8.0_275”

You should be good to go on installing Cassandra:

Brew install Cassandra

With installation complete, you can now proceed to force Cassandra to run:

Cassandra -f

A lot of information will flash before your eyes as Cassandra connects to your consciousness via hindbrain interface. What you’ll be looking for at the end of the log is:

INFO [main] 2020–12–09 11:04:14,948 CassandraDaemon.java:650 — Startup complete

Startup complete — nice. A couple lines up is another important bit of information:

Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)…

Note that address. It’s very important. For now, leave this terminal running- this is your JDE process running Cassandra. You can initiate a shutdown sequence via CTRL + C, but be sure to close all DB connections first (or at least I would).

Anyhow: you can now enter the Cassandra shell via:

cqlsh

Next, your task will be to come to terms with CQL, Cassie’s dialect. I found this primer to be very helpful. PROTIP: CQL calls databases “keyspaces.” Here’s a template for writing a schema for your keyspace. You can instantiate a keyspace from a schema like so:

cqlsh -f /Users/dw/project/server/database/schema.cql

Remember that address and port from earlier? You can use those to connect to your Cassandra instance programmatically. For you next node.js project I suggest cassandra-driver:

const cassandra = require(‘cassandra-driver’);

const client = new cassandra.Client({

contactPoints: [‘localhost:9042’],

localDataCenter: ‘datacenter1’,

keyspace: ‘NAME OF YOUR KEYSPACE’

});

client.connect().then(console.log(‘connected to cassie’));

There you go! You are well on your way.

But wait! What if, for example, I close my Cassandra instance and try to start it back up, or I restart my computer, or my computer restarts itself of its own free will, and I get a nasty error like:

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x000000010f765ab8, pid=8065, tid=0x0000000000005d03

JRE version: OpenJDK Runtime Environment (8.0_275) (build 1.8.0_275-bre_2020_11_16_16_29-b00)

Java VM: OpenJDK 64-Bit Server VM (25.275-b00 mixed mode bsd-amd64 compressed oops)

Have no fear. First thing you should try is checking that your default JDK hasn’t been reset. Run:

java -version

If no active version is found run:

/usr/libexec/java_home -V

to view your installed JDEs. If your JDK machines are found, use the same command from installation above to select a default from one of those JDK machines:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_XXX`

Afterward, try restarting Cassandra (cassandra -f). That should work. If that doesn’t work, you may have an issue within the JDK install itself. My solution to this was a quick uninstall-reinstall cycle of all java dependencies:

brew cask uninstall adoptopenjdk8

brew uninstall adoptopenjdk

brew uninstall java

brew cask install java

brew tap AdoptOpenJDK/openjdk

brew install adoptopenjdk8

Afterward just switch your JAVA_HOME to your chosen version as explained above, and you should be good to go. Phew, close one!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Derek W. Warner-Reyes
Derek W. Warner-Reyes

Written by Derek W. Warner-Reyes

Software Engineer, Writer and Artist based in Portland, OR <3

No responses yet

Write a response