Installing Cassandra
Apache Cassandra can be installed on a number of Linux distributions:
- AlmaLinux
- Amazon Linux Amazon Machine Images (AMIs)
- Debian
- RedHat Enterprise Linux (RHEL)
- SUSE Enterprise Linux
- Ubuntu
This is not an exhaustive list of operating system platforms, nor is it prescriptive. However, users are well-advised to conduct exhaustive tests if using a less-popular distribution of Linux. Deploying on older Linux versions is not recommended unless you have previous experience with the older distribution in a production environment.
Prerequisites
Install the latest version of Java 11 or Java 17, from one of the following locations:
Oracle Java Standard Edition 11 Archived Version
- Oracle Java Standard Edition 17
- OpenJDK 11
- OpenJDK 17 1.
- Command
- Result
$ java -version
openjdk version "11.0.20" 2023-07-18OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
cqlsh, install the latest version of Python 3.7+.python --version.Choosing an installation method
There are three methods of installing Cassandra that are common:- Docker image
- Tarball binary file
- Package installation (RPM, YUM)
dockerinstalled on Linux. Pull the appropriate image from the Docker Hub and start Cassandra with adocker runcommand.rootpermissions and can be installed on any Linux distribution.rootpermissions, and are most appropriate for production installs. Install the RPM build on CentOS and RHEL-based distributions if you want to install Cassandra using YUM. Install the Debian build on Ubuntu and other Debian-based distributions if you want to install Cassandra using APT.Install with Docker
- Pull the docker image. For the latest image, use:
docker pull cassandra:latest
docker pull command will get the latest version of the official Docker Apache Cassandra image available from the Dockerhub.
docker runcommand:
docker run --name cass_cluster cassandra:latest
--name option will be the name of the Cassandra cluster created. This example uses the name cass_cluster.
cqlshto interact with the Cassandra node created:
docker exec -it cass_cluster cqlsh
Install tarball file
1.
- Command
- Result
$ java -version
openjdk version "11.0.20" 2023-07-18OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
- Apache Cassandra Download site. For example, to download Cassandra 4.0:
$ curl -OL http://apache.mirror.digitalpacific.com.au/cassandra/4.0.0/apache-cassandra-4.0.0-bin.tar.gz
- here. For example, to verify the hash of the downloaded file using GPG:
- Command
- Result
$ gpg --print-md SHA256 apache-cassandra-4.0.0-bin.tar.gz
apache-cassandra-4.0.0-bin.tar.gz: 28757DDE 589F7041 0F9A6A95 C39EE7E6 CDE63440 E2B06B91 AE6B2006 14FA364D
Compare the signature with the SHA256 file from the Downloads site:
- Command
- Result
$ curl -L https://downloads.apache.org/cassandra/4.0.0/apache-cassandra-4.0.0-bin.tar.gz.sha256
28757dde589f70410f9a6a95c39ee7e6cde63440e2b06b91ae6b200614fa364d
- Unpack the tarball:
$ tar xzvf apache-cassandra-4.0.0-bin.tar.gz
apache-cassandra-4.0.0/ directory. This is the tarball installation location.
- Located in the tarball installation location are the directories for the scripts, binaries, utilities, configuration, data and log files:
<tarball_installation>/ bin/ (1) conf/ (2) data/ (3) doc/ interface/ javadoc/ lib/ logs/ (4) pylib/ tools/ (5)
- Start Cassandra:
$ cd apache-cassandra-4.0.0/ && bin/cassandra
- Monitor the progress of the startup with:
- Command
- Result
$ tail -f logs/system.log
system.log:
+
INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
- Check the status of Cassandra:
$ bin/nodetool status
UN which stands for “Up/Normal”.
Alternatively, connect to the database with:
$ bin/cqlsh
Install as Debian package
1.
- Command
- Result
$ java -version
openjdk version "11.0.20" 2023-07-18OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
cassandra.sources.list.40x(with an “x” as the suffix). For older releases use:
311xfor C* 3.11 series30xfor {30_version}22xfor {22_version}21xfor {21_version}40x): +$ echo "deb https://debian.cassandra.apache.org 42x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.listdeb https://debian.cassandra.apache.org 42x main
- Add the Apache Cassandra repository keys to the list of trusted keys on the server:
- Command
- Result
$ curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 266k 100 266k 0 0 320k 0 --:--:-- --:--:-- --:--:-- 320kOK
- Update the package index from sources:
$ sudo apt-get update
- Install Cassandra with APT:
$ sudo apt-get install cassandra
- Monitor the progress of the startup with:
- Command
- Result
$ tail -f logs/system.log
system.log:
+
INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
- Check the status of Cassandra:
$ nodetool status
UN which stands for “Up/Normal”.
Alternatively, connect to the database with:
$ cqlsh
Install as RPM package
1.
- Command
- Result
$ java -version
openjdk version "11.0.20" 2023-07-18OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
/etc/yum.repos.d/cassandra.repo(as therootuser).40x(with an “x” as the suffix). For older releases use:
311xfor C* 3.11 series30xfor {30_version}22xfor {22_version}21xfor {21_version}40x): +[cassandra]name=Apache Cassandrabaseurl=https://redhat.cassandra.apache.org/42x/gpgcheck=1repo_gpgcheck=1gpgkey=https://downloads.apache.org/cassandra/KEYS
- Update the package index from sources:
$ sudo yum update
- Install Cassandra with YUM:
$ sudo yum install cassandra
- Start the Cassandra service:
$ sudo service cassandra start
- Monitor the progress of the startup with:
- Command
- Result
$ tail -f logs/system.log
system.log:
+
INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
- Check the status of Cassandra:
$ nodetool status
UN which stands for “Up/Normal”.
Alternatively, connect to the database with:
$ cqlsh
Further installation info
Troubleshooting section.
