{"id":6449,"date":"2021-05-25T17:56:37","date_gmt":"2021-05-25T17:56:37","guid":{"rendered":"https:\/\/linuxways.net\/?p=6449"},"modified":"2021-05-25T17:56:37","modified_gmt":"2021-05-25T17:56:37","slug":"how-to-install-apache-cassandra-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-apache-cassandra-on-ubuntu-20-04\/","title":{"rendered":"How to Install Apache Cassandra on Ubuntu 20.04"},"content":{"rendered":"<p>Apache Cassandra is an open-source non-relational database that delivers high performance, linear scalability, and continuous availability. All these features make Cassandra an ideal platform for mission-critical data. In today\u2019s post, we will be describing how to install Apache Cassandra on Ubuntu OS.<\/p>\n<p><strong>Note<\/strong>: The procedure shown here has been tested on <strong>Ubuntu 20.04 LTS (Focal Fossa).<\/strong><\/p>\n<h2>Step 1: Install java<\/h2>\n<p>Apache Cassandra requires java to be running on the machine. Use these commands to install java on your system:<\/p>\n<pre>$ sudo apt update<\/pre>\n<pre>$ sudo apt install openjdk-8-jdk<\/pre>\n<p>To verify if Java is installed, issue this command in Terminal:<\/p>\n<pre>$ java -version<\/pre>\n<h2><img loading=\"lazy\" decoding=\"async\" width=\"751\" height=\"95\" class=\"wp-image-6451\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-116.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-116.png 751w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-116-300x38.png 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/h2>\n<h2>Step 2: Install Apache Cassandra<\/h2>\n<p>Before proceeding towards the installation of Apache Cassandra, you will first need to install <strong>the apt-transport-https<\/strong> package. You can install it using this command:<\/p>\n<pre>$ sudo apt install apt-transport-https<\/pre>\n<p>Enter the password for sudo. When prompted for continuation, press <strong>y<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"702\" height=\"401\" class=\"wp-image-6452\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-117.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-117.png 702w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-117-300x171.png 300w\" sizes=\"auto, (max-width: 702px) 100vw, 702px\" \/><\/p>\n<p>Now import and add the GPG key using this command in the Terminal:<\/p>\n<pre>$ wget -q -O - https:\/\/www.apache.org\/dist\/cassandra\/KEYS | sudo apt-key add -<\/pre>\n<p>If the key is added successfully, you will see <strong>OK<\/strong> in the output.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"89\" class=\"wp-image-6453\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-118.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-118.png 683w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-118-300x39.png 300w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/p>\n<p>Now add the Apache Cassandra repository to apt list of sources using this command in the Terminal:<\/p>\n<pre>$ sudo sh -c 'echo \"deb http:\/\/www.apache.org\/dist\/cassandra\/debian 311x main\" &gt; \/etc\/apt\/sources.list.d\/cassandra.list'<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"70\" class=\"wp-image-6454\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-119.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-119.png 688w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-119-300x31.png 300w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/p>\n<p>Update the apt list of sources using the command below in the Terminal:<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>Now that the repository has been added, you can install Apache Cassandra using this command in the Terminal:<\/p>\n<pre>$ sudo apt install Cassandra<\/pre>\n<p>Enter the password for sudo. When prompted for continuation, press<strong> y<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"574\" class=\"wp-image-6455\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-120.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-120.png 791w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-120-300x218.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-120-768x557.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><\/p>\n<p>After the installation of Apache Cassandra, its service starts automatically. To verify it, use the command below:<\/p>\n<pre>$ sudo systemctl status Cassandra<\/pre>\n<p>Also, you can verify the status using the below command:<\/p>\n<pre>$ sudo nodetool status<\/pre>\n<p>You\u2019ll see something similar to the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"995\" height=\"185\" class=\"wp-image-6456\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-121.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-121.png 995w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-121-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-121-768x143.png 768w\" sizes=\"auto, (max-width: 995px) 100vw, 995px\" \/><\/p>\n<p>Now the Apache Cassandra has been successfully installed. To login to Apache Cassandra, you can use the <strong>cqlsh<\/strong> command-line tool as follows:<\/p>\n<pre>$ cqlsh<\/pre>\n<p>You will see something similar to the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"871\" height=\"135\" class=\"wp-image-6457\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-122.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-122.png 871w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-122-300x46.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-122-768x119.png 768w\" sizes=\"auto, (max-width: 871px) 100vw, 871px\" \/><\/p>\n<h2>Rename Apache Cassandra Cluster<\/h2>\n<p>In the previous output, you can see the cluster name is &#8220;Test Cluster&#8221;. To change the default cluster name, log in to Cassandra using the cqlsh command-line tool as follows:<\/p>\n<pre>$ cqlsh<\/pre>\n<p>Then issue the command below in the Terminal to rename the Apache Cassandra Cluster to let\u2019s say \u201cLinuxways_cluster\u201d:<\/p>\n<pre>$ UPDATE system.local SET cluster_name = \u2018Linuxways_cluster' WHERE KEY = 'local';<\/pre>\n<p>Make sure to change the <strong>Linuxways_cluster<\/strong> with your own desired name.<\/p>\n<p>Now to exit the cqlsh tool, type <em>exit<\/em>, and press <strong>Enter<\/strong>:<\/p>\n<pre>$ exit<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"871\" height=\"135\" class=\"wp-image-6458\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-123.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-123.png 871w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-123-300x46.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-123-768x119.png 768w\" sizes=\"auto, (max-width: 871px) 100vw, 871px\" \/><\/p>\n<p>Then edit the cassandra.yaml configuration file using the command below in the Terminal:<\/p>\n<pre>$ sudo nano \/etc\/cassandra\/cassandra.yaml<\/pre>\n<p>Now in the cassandra.yaml configuration file, search for the cluster_name.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"267\" class=\"wp-image-6459\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-124.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-124.png 767w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-124-300x104.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>Once you find it, change its name to your desired value. Then save and exit the file. <img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"247\" class=\"wp-image-6460\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-125.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-125.png 729w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-125-300x102.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n<p>Now to verify if the cluster name has been changed successfully, use the command below:<\/p>\n<pre>$ cqlsh<\/pre>\n<p>The output below verifies that the cluster name has been changed successfully to <strong>Linuxways_cluster<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"713\" height=\"88\" class=\"wp-image-6461\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-126.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-126.png 713w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-126-300x37.png 300w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/p>\n<h2>Uninstall Apache Cassandra<\/h2>\n<p>In case you need to remove Apache Cassandra from your machine, you can do this using the following steps:<\/p>\n<p>Stop the service of Cassandra using the command below:<\/p>\n<pre>$ sudo service cassandra stop<\/pre>\n<p>Then remove the library and log directories using these commands:<\/p>\n<pre>$ sudo rm -r \/var\/lib\/cassandra<\/pre>\n<pre>$ sudo rm -r \/var\/log\/Cassandra<\/pre>\n<p>After that, uninstall Apache Cassandra using the command below:<\/p>\n<pre>$ sudo apt purge cassandra<\/pre>\n<p>This was all about installing Apache Cassandra on Ubuntu 20.04 LTS. To learn more about Apache Cassandra, visit its <a href=\"https:\/\/cassandra.apache.org\/doc\/latest\/getting_started\/index.html\">official documentation<\/a> site.<\/p>","protected":false},"excerpt":{"rendered":"<p>Apache Cassandra is an open-source non-relational database that delivers high performance, linear scalability, and continuous availability. All these features make Cassandra an ideal platform for mission-critical data. In&hellip;<\/p>","protected":false},"author":1,"featured_media":6538,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[333],"class_list":["post-6449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-apache-cassandra"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=6449"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6449\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/6538"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}