Apache Cassandra is an open-source NoSQL database with high availability and scalability. This guide explains how to install and start Cassandra on macOS using Homebrew.
1. Installing Cassandra
This assumes that Homebrew is already installed. If not, please refer to the official Homebrew website to install it.
Open a terminal and run the following command to install Cassandra:
brew install cassandra
This command installs Cassandra itself along with command-line tools for interacting with Cassandra (such as cqlsh).
2. Starting the Cassandra Server
Once the installation is complete, start the Cassandra server with the following command. Using Homebrew’s services command allows you to start and manage Cassandra as a background service.
brew services start cassandra
To verify that Cassandra has started successfully, use the following command:
brew services list
If the status of cassandra shows started, it was successful.
3. Starting CQLSH (Cassandra Query Language Shell)
Once Cassandra is running, you can use cqlsh to connect to the Cassandra cluster and execute CQL (Cassandra Query Language) commands.
cqlsh
If the connection is successful, a cqlsh> prompt will appear.
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 6.0.0 | Cassandra 4.0.6 | CQL spec 3.4.5 | Native protocol v12]
Use HELP for help.
cqlsh>
With this, the basic Cassandra development environment is set up on macOS.
Appendix: Stopping and Restarting Cassandra
- Stop:
brew services stop cassandra - Restart:
brew services restart cassandra