
If you're looking for a powerful open-source distributed database system, but don't want to spend hours configuring and installing it, then Cassandra is the right solution for you.
Cassandra is a powerful open-source distributed database system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Instead, data is partitioned and spread over several servers using a key-value store.
First, to run Cassandra on your system, you must install Java OpenJDK. OpenJDK is a free and open-source implementation of the Java Platform. Installation instructions are listed below.
Run the dnf install command to install the java-1.8.0-openjdk package. As of this writing, the latest version of Java OpenJDK is 1.8.xxx. The installation of Java OpenJDK might take some time to complete.
Once the installation completes, verify the installed version of Java OpenJDK in your system using the java -version command.
Cassandra is written in Java, but you'll need to install python as well since the cqlsh tool is written in python. Cqlsh is a command-line interface for Cassandra; you'll need to install python to run Cassandra.
Run the dnf install command to install the python36 package in your system. As of this writing, the latest version of python is 3.6.8.
Once the installation completes, verify the installed version in your system using the python3 --version command.
Run the alternatives --config command below to select the default Python interpreter. Cassandra requires python v3 or later. So you should select the latest one from the list and at least v3. Select the number corresponding to the latest python version and press Enter. In this demo, it's option 2.
Now you have the required components installed in your system, and you are ready to install Apache Cassandra.
The base Rocky Linux repository does not have a Cassandra package, so you need to add its repository to your system first.
Create a new file named cassandra.repo under the /etc/yum.repos.d directory using the nano text editor.
Populate the cassandra.repo file with the following contents. The baseurl specifies where the RPMs are located(https://downloads.apache.org/cassandra/redhat/40x/). The 40x here means the latest version of Apache Cassandra 4.0.3 is downloaded from this location. You can always choose the latest version available in its official repository.
Save and exit the file by pressing Ctrl+O, Enter, and Ctrl+X. Run the dnf update command to update your system's package management index with the newly added repository.
Run the dnf repolist Cassandra command to check if the new repo is properly set up. You will see the new Cassandra repo is enabled in the output.
Finally, install the cassandra package using the dnf install command.
Start the Cassandra service.
Enable the Cassandra service to start on system reboot.
Check the status of Cassandra's service.
Securing your Cassandra cluster is as important as installing it. Suppose you have several Cassandra nodes on the same network. You should secure the cluster at the beginning to prevent attackers from accessing your database.
Run the firewall-cmd command below to create a new firewall zone named cassandra-cluster for Cassandra. You should create a new zone to associate with the Cassandra cluster to prevent conflict with other services in the system. The --permanent flag defines the new firewalls are permanent. The --new-zone flag defines the new firewall zone.
Reload the firewalld service.
Add your server network CIDR into the new zone so that your client and server can communicate with each other.
Run the following commands to allow access to the default ports for Cassandra on the new cassandra-cluster zone.
Finally, reload the firewalld rules. At this point, your Cassandra cluster is secured and can only access from your-CIDR-here/24.
Now that you have a new Cassandra cluster, you can test if it's up and running properly.
Run the nodetool status command to check your Cassandra cluster status. This command will return all nodes' information, including the IP address, the load average of each node, data center name, version, and health statistics about each node in the cluster.
You can also use the cqlsh command to interact with your Cassandra cluster.
For example, if you want to change the default name cluster(Test Cluster), you can use the update command to change it. Replace Vultr Cluster with your desired value.
Quit cqlsh shell.
Next time you use the cqlsh command, it will use the new cluster name( Vultr Cluster). This output confirms that you have successfully installed Cassandra on your system.
To learn more about Cassandra, please visit its official website.
0 Comments
Be the first to comment and share your perspective with the community.