Skip to content

Instantly share code, notes, and snippets.

@Micka33
Last active March 17, 2022 10:55
Show Gist options
  • Save Micka33/89897e1490240a56c036 to your computer and use it in GitHub Desktop.
Save Micka33/89897e1490240a56c036 to your computer and use it in GitHub Desktop.
cassandra on mac OSX

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
pip install cassandra-driver

Install Cassandra

This installs Apache Cassandra:

brew install cassandra

Starting Cassandra

At the end of the install, brew will tell you about two ways to launch Cassandra. The first will launch it when the computer restarts, but this isn't recommended because you may not want to always run Cassandra. Instead use this command:

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

Or even easier:

launchctl start homebrew.mxcl.cassandra

and to stop:

launchctl stop homebrew.mxcl.cassandra

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

launchctl: Couldn't stat("/Users/MNCH/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/2.1.2/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

Finally cqlsh should connect to cassandra:

$> cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh>
cqlsh>

Have fun with Cassandra!

@mars
Copy link

mars commented Jan 6, 2016

This worked for me on OS X 10.10 Yosemite. Thank you @Micka33

Also, Java is required, but no longer included with Mac OS X. Install Java first, or you may end up with a seemingly endless procession of "Java is required" system alerts.

@yuryja
Copy link

yuryja commented Jan 30, 2016

Hi, brew installs Cassandra 2.1.5, how can i install 3.2.1? thanks

@alexhawkins
Copy link

I get the following error on El Capitan when installing 3.2.1. Did not get this error with Yosemite which installed 2.2.2 Anyone have any ideas on how to fix this?

Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

@thillain
Copy link

thillain commented Mar 9, 2016

@alexhawkins Check for the homebrew.mxcl.cassandra.plist inside /usr/local/Cellar/cassandra/. Copy and paste the .plist inside ~/Library/LaunchAgents/

@yoonwaiyan
Copy link

Any idea where is the /conf folder of Cassandra 3.5 installed via Homebrew? The connection seems to be dropping consistently and I have to kill the java and restart by bin/cassandra, would like to configure the host to see if it solves this problem.

@kartik884
Copy link

@alexhawkins : Where you able to solve your issue ?

@kevinjam
Copy link

I have install from homebrew but ain't working Yosemite 10.10.5
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
Here is my home-brew.mxcl.cassandra

@murthybackyard
Copy link

cd /usr/local/etc/cassandra
cp -rf cqlshrc.sample cqlshrc

EDIT below config in cqlshrc,

hostname = 192.168.0.11

save, now run cqlsh

it should work

@dupsykool
Copy link

alexhawkins > Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

Was this resolved?

@beginner
Copy link

I had the same issue, and the problems seems to be Java 9 not compatible for cassandra. After i updated by bash_profile with the Java 1.8 path for JAVA_HOME the problem was gone. HTH.

@msidlo
Copy link

msidlo commented Feb 13, 2018

I had the same problem. It doesn't necessarily has to be Java 9. I was using JDK 8u161 and the outcome was same.
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

I've found an error in logs of Cassandra, java.lang.AbstractMethodError. When I used older version JDK 8u152, it started to work. I've have a great post on stack overflow to install it via brew :)

@lmregus
Copy link

lmregus commented Jun 28, 2018

I see that this is still happening....
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

@jamesaq12wsx
Copy link

jamesaq12wsx commented May 28, 2019

cd /usr/local/etc/cassandra
cp -rf cqlshrc.sample cqlshrc

EDIT below config in cqlshrc,

hostname = 192.168.0.11

save, now run cqlsh

it should work

HI @murthybackyard, I change the hostname and restart cassandra service
But when I use cqlsh to connect, it still show connecting to 127.0.0.1

Did I miss something?

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