Apache Cassandra is an open-source NoSQL database system with high availability and without compromising performance. It is used by many large companies like Github, NetFlix, Reddit and Instagram. In this described how to install Apache Cassandra on CentOS 8.
You should logged in as root or user with sudo privileges.
Step 1 – Install Java
To install the latest Apache Cassandra version
3.11 requires OpenJDK 8 to be installed on your CentOS system. So first we will install OpenJDK by running following command:
sudo dnf install java-1.8.0-openjdk-devel
Once the process completed, verify the Java installation by typing:
The output should look something like this:
openjdk version "1.8.0_262" OpenJDK Runtime Environment (build 1.8.0_262-b10) OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
Step – 2 Add Repository & Import GPG Key
Next, you need to add repository for the Apache Cassandra and import the GPG key to the system.
Open your text editor and create the following repository file:
sudo nano /etc/yum.repos.d/cassandra.repo
Add the following lines to the file:
[cassandra] name=Apache Cassandra baseurl=https://www.apache.org/dist/cassandra/redhat/311x/ gpgcheck=1 repo_gpgcheck=1 gpgkey=https://www.apache.org/dist/cassandra/KEYS
Save and close the file.
Step 3 – Install Apache Cassandra
You are now ready to install Cassandra on CentOS 8 system.
Finally, run the following command to install Apache Cassandra:
sudo dnf install cassandra
When it will prompt, press y to import the GPG key.
After the completion of installation, start and enable the Apache Cassandra service.
sudo systemctl start cassandra
sudo systemctl enable cassandra
Step 4 – Verify Apache Cassandra Installation
After that, to check the Cassandra installed and running properly, type:
It should show output something like below:
Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0.0.1 69.99 KiB 256 100.0% ce0389a3-b48c-4cc9-b594-abe23e677d33 rack1
That’s it. At this step, Apache Cassandra is installed on your CentOS server.
Step 5 – Configuring Apache Cassandra
The configuration files are located in
/var/lib/cassandra directory holds the Apache Cassandra data files. You can configure the Java start-up options in the
If the database is running on the same host then you don’t need to change anything in the configuration. By default, Cassandra is configured to listen on localhost only.
To make connection with Cassandra using CQL you can use the default command-line tool cqlsh which is shipped with the Cassandra package.
cqlsh requires Python 2 to be in the system’s PATH . If you don’t have Python 2 installed on the server, you can do it with the following commands:
sudo dnf install python2
sudo alternatives --set python /usr/bin/python2
cqlsh to access the CQL shell:
[cqlsh 5.0.1 | Cassandra 3.11.7 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh>
You have learned how to install Apache Cassandra on CentOS 8. To learn more about Cassandra, visit the official Apache Cassandra Documentation page.
If you have a problem or suggestion, please leave a comment below.