Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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!

@guiyang

This comment has been minimized.

Copy link

guiyang commented Oct 14, 2015

Thanks a lot.

@jeanphilippedaly

This comment has been minimized.

Copy link

jeanphilippedaly commented Oct 17, 2015

I have trouble, where is the the file inside my mac for change directory and after start this with command line: "cassandra -f" it ok ;)

@BenBrostoff

This comment has been minimized.

Copy link

BenBrostoff commented Nov 27, 2015

Not sure if this is a configuration issue on my end, but I get the following here:

brew install cassandra
==> Downloading http://www.apache.org/dyn/closer.cgi?path=/cassandr
==> Best Mirror http://apache.mirrors.ionfish.org/cassandra/2.1.2/a

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "cassandra"
Download failed: http://apache.mirrors.ionfish.org/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz
draft-kings-fun [weak_defense] :> brew install cassandra
==> Downloading http://www.apache.org/dyn/closer.cgi?path=/cassandr
==> Best Mirror http://mirror.metrocast.net/apache/cassandra/2.1.2/

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "cassandra"
Download failed: http://mirror.metrocast.net/apache/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz

I had success following the instructions here, albeit changing the tar source. I posted a gist here.

@vlamug

This comment has been minimized.

Copy link

vlamug commented Dec 29, 2015

Thank you for this guide.

@manoj2589

This comment has been minimized.

Copy link

manoj2589 commented Feb 8, 2016

Thank you. This helped a lot.

@rtconner

This comment has been minimized.

Copy link

rtconner commented May 26, 2016

Sorry to be an idiot .. but .. what the heck do I do with that "Cassandra file locations" section? Do I just create empty folders and files? Do I copy some files of some sort from somewhere? Those things don't exist on my computer after install. How do I set them up?

Update: Turns out for some reason homebrew did not fully install Cassandra. I updated homebrew and installed it again and this folder was created automatically.

@MrWooJ

This comment has been minimized.

Copy link

MrWooJ commented Jun 15, 2016

Thank you Sir 👍

@diansheng

This comment has been minimized.

Copy link

diansheng commented Jun 17, 2016

Thanks for the documentation from which i learn the 2nd way to install cassandra. But I am a bit confused what is the difference from simply download the tar file and uncompress it? That approach looks simpler and easier to understand.

@tjonganthony

This comment has been minimized.

Copy link

tjonganthony commented Aug 30, 2016

I got stuck when running cqlsh. No error, no warning or anything. It just hangs there without actually running anything or quitting from cqlsh.

@banDedo

This comment has been minimized.

Copy link

banDedo commented Jan 20, 2017

I had to also run this from the command line to get this to work:

$ sudo ifconfig lo0 alias 127.0.0.2 up
$ sudo ifconfig lo0 alias 127.0.0.3 up
@withoutclass

This comment has been minimized.

Copy link

withoutclass commented Mar 15, 2017

The latest version of a piece of software installed by Homebrew is always going to exist at /usr/local/opt/SOFTWARE_NAME.

You could generify this guide by subbing this location in for the LaunchAgents path. This also removes the need to <version number> in a path if the plist wasn't moved to LaunchAgents.

@mxgit1090

This comment has been minimized.

Copy link

mxgit1090 commented Apr 5, 2017

Is it OK if I use

brew services start cassandra

instead of

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

?

@zealotous

This comment has been minimized.

Copy link

zealotous commented Apr 5, 2017

@mxgit1090 according to https://github.com/Homebrew/homebrew-services, brew services is the frontend to macOS's launchctl.

@srinikandula

This comment has been minimized.

Copy link

srinikandula commented May 13, 2017

You may need to be using the below commands for start and stop

start: brew services start cassandra
stop: brew services stop cassandra

@abhsrivastava

This comment has been minimized.

Copy link

abhsrivastava commented May 15, 2017

Can any of you access the cassandra instance remotely? for me, everything is fine locally, but I cannot access the cassandra instance from a remote machine.

@malhal

This comment has been minimized.

Copy link

malhal commented Aug 10, 2017

Homebrew URL has changed to:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@amreladawy

This comment has been minimized.

Copy link

amreladawy commented Aug 11, 2017

Thanks a lot.

@bkota-nisum-com

This comment has been minimized.

Copy link

bkota-nisum-com commented Nov 2, 2017

Thank you

@rdanieli

This comment has been minimized.

Copy link

rdanieli commented Jan 2, 2018

Thanks a lot.

@mtamadon

This comment has been minimized.

Copy link

mtamadon commented Jan 4, 2018

Thanks alot

@prateekm21

This comment has been minimized.

Copy link

prateekm21 commented Jan 30, 2018

start / stop service with brew services is easy

brew services {start|stop} cassandra

@icalrn

This comment has been minimized.

Copy link

icalrn commented Mar 3, 2018

This really helps, thank you!

@AhnMo

This comment has been minimized.

Copy link

AhnMo commented Mar 7, 2018

As undefined_variable commented, Java 8, instead of 9, worked just fine. Thanks everyone for trying to help.

From https://stackoverflow.com/questions/46944788/cant-start-cassandra-single-node-cluster-on-centos7/46969714#46969714

I wasted my time with this issue...

@danieljue

This comment has been minimized.

Copy link

danieljue commented Mar 28, 2018

On a Mac you may have problems with cql requiring the python library 'six', which has a protected installation on the Mac since ~2015 up to at least High Sierra.
The problem and it's work-around over the years is all documented here:
pypa/pip#3165

For cql, use this:
sudo pip install cql --upgrade --ignore-installed six

@ramialbatal

This comment has been minimized.

Copy link

ramialbatal commented May 22, 2018

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?

@ruejo2013

This comment has been minimized.

Copy link

ruejo2013 commented Apr 7, 2019

Thanks alot, this was very helpful

@jamesaq12wsx

This comment has been minimized.

Copy link

jamesaq12wsx commented May 28, 2019

Hi everyone,
I got error when I connect run
cqlsh
it shows
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")})
What should I do to make this work

System macOS 10.14.5

@thasleembasha

This comment has been minimized.

Copy link

thasleembasha commented Jun 10, 2019

Hello Everyone,

Even I am facing the same issue as mentioned by jamesaq12wsx.
Please help!

@BamdadNouri

This comment has been minimized.

Copy link

BamdadNouri commented Jun 22, 2019

Hi everyone,
I got error when I connect run
cqlsh
it shows
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")})
What should I do to make this work

System macOS 10.14.5

I'm having the same problem and there's no solution for it available over the internet!
Any help would be appreciated.

@gatageek

This comment has been minimized.

Copy link

gatageek commented Jun 24, 2019

Hello jamesaq12wsx, thasleembasha and BamdadNouri, I'm running Mohave 10.14.5 and I installed Cassandra 3.11.4 and I was facing the exact same issue that you were. Whenever I tried to run the cqlsh command I would get back the same error than you. So I tried running the command cassandra first and then I would get back: Cassandra 3.0 and later require Java 8u40 or later.

After doing my research I found that my JDK version was 6.1,(you can run the command $ ls /Library/Java/JavaVirtualMachines/) in my case was 1.6, so I went to
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and downloaded/installed the JDK 8.2.11 (I choose this version cause, when i check on System Preferences/JAVA/Update tab, my JRE version is the same 8.2.11).

So after I did that, then I went to the terminal, and initiated cqlsh and everything worked as expected, I really hope this helps.

Thanks,

@nosyarlin

This comment has been minimized.

Copy link

nosyarlin commented Jul 27, 2019

Hello jamesaq12wsx, thasleembasha and BamdadNouri, I was facing the exact same problem for much of today. I am running Mojave 10.14.5 as well with JDK 1.8. The problem went away after I ran the command cassandra. I have no idea what it did but it solved my problem.

@VishwasShashidhar

This comment has been minimized.

Copy link

VishwasShashidhar commented Jul 31, 2019

Thanks a lot!

@anandafit

This comment has been minimized.

Copy link

anandafit commented Sep 24, 2019

Hello jamesaq12wsx, thasleembasha and BamdadNouri, I'm running Mohave 10.14.5 and I installed Cassandra 3.11.4 and I was facing the exact same issue that you were. Whenever I tried to run the cqlsh command I would get back the same error than you. So I tried running the command cassandra first and then I would get back: Cassandra 3.0 and later require Java 8u40 or later.

After doing my research I found that my JDK version was 6.1,(you can run the command $ ls /Library/Java/JavaVirtualMachines/) in my case was 1.6, so I went to
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and downloaded/installed the JDK 8.2.11 (I choose this version cause, when i check on System Preferences/JAVA/Update tab, my JRE version is the same 8.2.11).

So after I did that, then I went to the terminal, and initiated cqlsh and everything worked as expected, I really hope this helps.

Thanks,

I got the same issue with java 11. Then changed java version to 1.8 and ran the cassandra f. then the cqlsh word as normal.
cqlsh Connected to Test Cluster at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh>
it seems like again there is an issue with java 11 here.

@MahdiurRahman

This comment has been minimized.

Copy link

MahdiurRahman commented Oct 29, 2019

Hello jamesaq12wsx, thasleembasha and BamdadNouri, I was facing the exact same problem for much of today. I am running Mojave 10.14.5 as well with JDK 1.8. The problem went away after I ran the command cassandra. I have no idea what it did but it solved my problem.

LMAO this is hilarious. Also this worked for me. Might also try running
cassandra -f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.