Skip to content

Instantly share code, notes, and snippets.

@hkhamm
Last active November 8, 2023 15:53
Show Gist options
  • Save hkhamm/a9a2b45dd749e5d3b3ae to your computer and use it in GitHub Desktop.
Save hkhamm/a9a2b45dd749e5d3b3ae to your computer and use it in GitHub Desktop.
Installing Cassandra on Mac OS X

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Install Python

Mac OS X has a copy of Python preinstalled, but this makes sure you get the newest version.

brew install python

Install cql

To use cqlsh, the Cassandra query language shell, you need to install cql:

pip install cql

Install Cassandra

This installs Apache Cassandra:

brew install cassandra

Starting/Stopping Cassandra

Use this command to start Cassandra:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist

Use this command to stop Cassandra:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist

On Mavericks, Homebrew failed to move the plist file into LaunchAgents, which gives this error message:

launchctl: Couldn't stat("/Users/<user>/Library/LaunchAgents/homebrew.mxcl.cassandra.plist"): No such file or directory

To fix this just issue the following command. Then, try using the launchctl load command again:

cp /usr/local/Cellar/cassandra/<version number>/homebrew.mxcl.cassandra.plist ~/Library/LaunchAgents/

Cassandra file locations

  • Properties: /usr/local/etc/cassandra
  • Logs: /usr/local/var/log/cassandra
  • Data: /usr/local/var/lib/cassandra/data

Links

Have fun with Cassandra!

@AgusQuintanar
Copy link

that is because you have python 3 and not python 2. mac os version doesn't matter

@amanda1210
Copy link

It seems like the URL in Install Homebrew section is 404 not found. And I found a new one that works:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 

Hope it's helpful.

@rush2abhi
Copy link

I am still facing the same issue on running cqlsh. Using Catalina OS - 10.15.7

@a0s
Copy link

a0s commented Jan 4, 2021

So, what i have:

This is not working (there is infinite loop in logs):

brew services start cassandra

But this is working:

JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_275` cassandra -f

And i wondering how to update /usr/local/Cellar/cassandra/3.11.9_1/homebrew.mxcl.cassandra.plist properly?

I tried this:

<?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>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.cassandra</string>
	<key>ProgramArguments</key>
	<array>
		<string>JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_275`</string>
		<string>/usr/local/opt/cassandra/bin/cassandra</string>
		<string>-f</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>WorkingDirectory</key>
	<string>/usr/local/var/lib/cassandra</string>
</dict>
</plist>

and this

<?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>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.cassandra</string>
	<key>ProgramArguments</key>
	<array>
		<string>JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home</string>
		<string>/usr/local/opt/cassandra/bin/cassandra</string>
		<string>-f</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>WorkingDirectory</key>
	<string>/usr/local/var/lib/cassandra</string>
</dict>
</plist>

without any success

UPD: the final variant

/usr/local/Cellar/cassandra/3.11.9_1/homebrew.mxcl.cassandra.sh (don't forget chmod +x):

#!/bin/sh
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
/usr/local/bin/cassandra -f

/usr/local/Cellar/cassandra/3.11.9_1/homebrew.mxcl.cassandra.plist:

<?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>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.cassandra</string>
	<key>Program</key>
	<string>/usr/local/Cellar/cassandra/3.11.9_1/homebrew.mxcl.cassandra.sh</string>
	<key>RunAtLoad</key>
	<true/>
	<key>WorkingDirectory</key>
	<string>/usr/local/var/lib/cassandra</string>
</dict>
</plist>

@kharmabum
Copy link

@a0s 🙇

@nbhargav3
Copy link

@a0s literally a savior, thanks!

@martingg88
Copy link

I am trying to install Stratio plugin and in the guiding here they say:

Copy the generated JAR to the lib folder of your compatible Cassandra installation: cp plugin/target/cassandra-lucene-index-plugin-*.jar <CASSANDRA_HOME>/lib/

my question is where is CASSANDRA_HOME because i couldn't find any directory including cassandra and has lib as subdirectory?

@ramialbatal you manage to solve this issue?

@FanchenBao
Copy link

pip install cql has been deprecated. cqlsh now comes with brew install cassandra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment