May 24, 2013 Installing Cassandra on Mac OS X I've recently posted some more tips on using Cassandra on Mac OSX: Cassandra on Mac If you don't already have homebrew then install it from here. Thank you for using our Mac software library. Unfortunately, there is no direct download for the Mac version of Cassandra's Journey - The Legacy of Nostradamus. To download the application, proceed to the developer's site via the link below. FDMLib cannot ensure the security of software that is hosted on external sites. Here is a simple, straightforward guide to start Cassandra on your local machine. Also we will create a sample keyspace as well as add data to our database. Now that you have Cassandra running. 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.
Caution!
Version Number might change!! The versions of all softwares mentioned here, including Cassandra will change as newer versions are launched.
Install Homebrew
Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:
Install Python
Mac OS X has a copy of Python preinstalled, but this makes sure you get the newest version.
Two Ways to Install Cassandra
A] Using Homebrew (This led to connection refused and compilatoin errors during cassandra and cqlsh startups for me)B] Using Binaries
A] Using Homebrew
Install cql
To use cqlsh, the Cassandra query language shell, you need to install cql:
Install Cassandra
This installs Apache 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:
Or even easier:
and to stop:
On Mavericks, Homebrew failed to move the plist file into LaunchAgents. Which gives this error message:
To fix this just issue the following command. Then, try using the
launchctl load
command again:Cassandra file locations
Properties: /usr/local/etc/cassandra
Logs: /usr/local/var/log/cassandra
Data: /usr/local/var/lib/cassandra/data
Logs: /usr/local/var/log/cassandra
Data: /usr/local/var/lib/cassandra/data
Finally cqlsh should connect to cassandra:
B] Using Binaries
Here, we use Apache Cassandra as well as it's own bundled
cqlsh
tool instead of an external one.We install Cassandra 3.5 as a standalone, single node cluster. A single node cluster is an easy way to get started learning Cassandra on your laptop.These installation steps show how to install a local copy of Cassandra. The benefits of a local copy are that you do not need root or sudo to install Cassandra, updating versions is quick and easy, and you can control how/when to install updates.
Install the Oracle JDK
Ensure that you have at least Java JDK version 7 installed.
Install Cassandra
Create data directories for Cassandra
In this step we need to create several directories that are used by Cassandra. Each directory is used by the following configuration variable in
conf/cassandra.yaml
:- data_file_directories: ~/opt/cassandra/data/data
- commitlog_directory: ~/opt/cassandra/data/commitlog
- saved_caches_directory: ~/opt/cassandra/data/saved_caches
The
logs
directory is used by logback which is configured via the conf/logback.xml
file.Add Cassandra to your PATH
Update your PATH to include Cassandra.
open -a TextEdit ~/.bash_profile
Paste the following into your .bash_profile
file.Source your
.bash_profile
file.source .bash_profile
Start the Cassandra server
We’re going to run Cassandra in the foreground during development. Cassandra will output a lot of information to the terminal when we start the server. However, this information can be useful during development in case there is a problem with the server.
cassandra -f
Press Ctrl + C
when you are ready to stop the server.Use Apache's bundled cqlsh
One can also use a symlink, but I created an alias in my .zshrc file to point to Cassandra's own
cqlsh
tool instead of an external one:Now type and hit return:
You should see this:
Thanks!
References
A combination of below posts and my own workarounds was used to create this.
- [Download Apache Cassandra] (http://cassandra.apache.org/download/) (This is different from the Datastax distro)
- [Install Cassandra 2.1 on Mac OS X] (http://exponential.io/blog/2015/01/28/install-cassandra-2_1-on-mac-os-x/)
- [This Gist] (https://gist.github.com/Micka33/89897e1490240a56c036)
If you don't already have homebrew then install it from here.
Then it as simple as:
brew install cassandra
This doesn't install the python driver for the cqlsh command line tool. To do this install it first install python if you haven't got it already:
brew install python
This should have also installed pip - the python package manager - so you can then install the cql python module:
pip install cql
Now try and start cqlsh
You might get this:
Python CQL driver not installed, or not on PYTHONPATH.
You might try 'easy_install cql'.
One second didn't I just install the cql module?
This could be because the Python in your path is the Mac OS X version. Not the version you installed with home brew that has cql. I fixed this by adding /usr/local/bin to the start of my PATH as that is where the brew Python executable lives:
export PATH=/usr/local/bin/:$PATH
Unless you've started cassandra the next time you try cqlsh you'll get:
Cassandra Download Mac Os High Sierra
cqlshConnection error: Could not connect to localhost:9160
Now if you do a brew info on cassandra:
brew info cassandra
To have launchd start cassandra at login:
ln -sfv /usr/local/opt/cassandra/*.plist ~/Library/LaunchAgents
Then to load cassandra now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist
Unless you are going to use cassandra a lot I wouldn't set it to load on startup as it does use a reasonable amount of memory. Instead to just start it off:
launchctl load /usr/local/opt/cassandra/homebrew.mxcl.cassandra.plist
Finally cqlsh should connect to cassandra:
cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 3.0.2 | Cassandra 1.2.5 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
Cassandra Download Mac Os High Sierra
Use HELP for help.
cqlsh>
Or if you prefer the older cassandra-cli interface to cassandra:
cassandra-cli
Connected to: 'Test Cluster' on 127.0.0.1/9160
Welcome to Cassandra CLI version 1.2.5
Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.
Download Mac
[default@unknown