{"id":16626,"date":"2019-04-08T13:46:20","date_gmt":"2019-04-08T13:46:20","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=16626"},"modified":"2024-01-24T21:57:06","modified_gmt":"2024-01-24T21:57:06","slug":"how-to-install-cassandra-on-ubuntu-18-04","status":"publish","type":"post","link":"\/ph\/tutorials\/set-up-and-install-cassandra-ubuntu\/","title":{"rendered":"How to Install Cassandra on Ubuntu and Learn The Basic Commands"},"content":{"rendered":"<p>Whenever users hear about database management systems, they likely immediately think about MySQL relational databases. However, such databases can fall short when presented with massive amounts of incoming structured data. That&rsquo;s where NoSQL databases come in.<\/p><p>Cassandra is one of the most popular non-relational databases out there. Such companies use it as Instagram, Uber, Facebook, and Netflix.<\/p><p>In this Cassandra tutorial, we will provide you with a step-by-step guide on how to install the latest version of Apache Cassandra on Ubuntu. We will also explain how the Cassandra database management system works, compare it to other NoSQL databases, and provide some common commands you can use.<\/p><p><strong>A Brief Overview of Installing and Setting up Cassandra on Ubuntu:<\/strong><\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td>Required Knowledge<\/td><td>Basic Ubuntu server management, familiarity with NoSQL databases<\/td><\/tr><tr><td>Privileges Required<\/td><td>Root or sudo user privileges<\/td><\/tr><tr><td>Difficulty<\/td><td>Intermediate to Advanced<\/td><\/tr><tr><td>Main Goal<\/td><td>Installation and basic configuration of Apache Cassandra<\/td><\/tr><\/tbody><\/table><\/figure><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-768x212.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-apache-cassandra\">What Is Apache Cassandra<\/h2><p>Apache Cassandra is an open-source database management system that runs on <strong>Not Only SQL <\/strong>model and uses a partitioned wide column storage data model. It mainly focuses on speed, scalability, and performance.<\/p><p>Cassandra&rsquo;s data model allows it to retrieve information very quickly. Additionally, it can perform thousands of write operations in seconds.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-cassandra-database-works\">How Cassandra Database Works<\/h2><p>Cassandra aims to enable users to work with high amounts of structured data while preventing any failure that might occur. Cassandra works with a <strong>peer-to-peer<\/strong> architecture data model, which means that each instance or node is connected to more nodes making up <strong>clusters<\/strong>. Such massively scalable architecture makes it easy to add additional nodes to suit anyone&rsquo;s needs.<\/p><p>Cassandra allows communication between nodes and performs fault detection to reveal any damaged nodes in a cluster to prevent the risk of failure. If outdated data is detected in one of the nodes, Cassandra replicates data from healthy nodes and repairs the damaged ones.<\/p><p>Here&rsquo;s the complete architecture of how Cassandra works:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/01\/how-does-cassandra-work.png\"><img decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/01\/how-does-cassandra-work-1024x640.png\" alt=\"A graph describing the architecture of how Cassandra works\" class=\"wp-image-76333\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/01\/how-does-cassandra-work.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/01\/how-does-cassandra-work-300x188.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/01\/how-does-cassandra-work-150x94.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/01\/how-does-cassandra-work-768x480.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ul class=\"wp-block-list\">\n<li><strong>Cassandra Node <\/strong>&ndash; it&rsquo;s where all the data is stored.<\/li>\n\n\n\n<li><strong>Replication <\/strong>&ndash; representation of how the replication model works in Cassandra.<\/li>\n\n\n\n<li><strong>Data Center <\/strong>&ndash; group of related nodes.<\/li>\n\n\n\n<li><strong>Cassandra Cluster <\/strong>&ndash; a group of one or more data centers.<\/li>\n\n\n\n<li><strong>Request <\/strong>&ndash; client read-write operation request to Cassandra database.<\/li>\n\n\n\n<li><strong>Client <\/strong>&ndash; user computer or another type of device.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-install-cassandra-on-ubuntu\">How to Install Cassandra on Ubuntu <\/h2><p>Users can easily install Cassandra with the help of the APT packages manager. Keep in mind that in order to install the latest version of Cassandra you will still need to include its package repository first.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-download-and-install-java\">1. Download and Install Java<\/h3><p>First, access your VPS <a href=\"\/ph\/tutorials\/how-to-use-putty-ssh\">via SSH<\/a> and determine if you have Java installed.<\/p><pre class=\"wp-block-preformatted\">java -version<\/pre><p>You might get the following output:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-command-to-check-the-Java-version-in-a-command-prompt.-In-this-case-Java-was-not-installed-on-the-VPS.png\"><img decoding=\"async\" width=\"311\" height=\"39\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-command-to-check-the-Java-version-in-a-command-prompt.-In-this-case-Java-was-not-installed-on-the-VPS.png\" alt=\"A command to check the Java version in a command prompt. In this case, Java was not installed on the VPS\" class=\"wp-image-65916\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-in-a-command-prompt.-In-this-case-Java-was-not-installed-on-the-VPS.png 311w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-in-a-command-prompt.-In-this-case-Java-was-not-installed-on-the-VPS-300x38.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-in-a-command-prompt.-In-this-case-Java-was-not-installed-on-the-VPS-150x19.png 150w\" sizes=\"(max-width: 311px) 100vw, 311px\" \/><\/a><\/figure><\/div><p>This means Java is not yet installed. If that&rsquo;s the case, follow the steps below. Otherwise, proceed to the next step.<\/p><ol class=\"wp-block-list\">\n<li>Refresh the APT command to synchronize all repositories:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt-get update<\/pre><ol class=\"wp-block-list\" start=\"2\">\n<li>Install the newest Java JDK version:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt install default-jdk -y<\/pre><p>    3. Validate the installation with the same <strong>java -version<\/strong> command we&rsquo;ve used before. Now, the output should look like this:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-command-to-check-the-Java-version-after-a-successful-Java-installation-in-a-command-prompt.png\"><img decoding=\"async\" width=\"795\" height=\"85\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-command-to-check-the-Java-version-after-a-successful-Java-installation-in-a-command-prompt.png\" alt=\"A command to check the Java version after a successful Java installation in a command prompt\" class=\"wp-image-65917\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-after-a-successful-Java-installation-in-a-command-prompt.png 795w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-after-a-successful-Java-installation-in-a-command-prompt-300x32.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-after-a-successful-Java-installation-in-a-command-prompt-150x16.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/A-command-to-check-the-Java-version-after-a-successful-Java-installation-in-a-command-prompt-768x82.png 768w\" sizes=\"(max-width: 795px) 100vw, 795px\" \/><\/a><\/figure><\/div><p>\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Sugested Reading<\/h4>\n                    <p>Check out our guide to learn<a href=\"\/ph\/tutorials\/install-java-ubuntu\"> how to install Java on Ubuntu<\/a>.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-2-add-the-gpg-key\">2. Add the GPG Key<\/h3><p>To avoid issues with the repository, add the GPG key and increase the security of the repository. First, install <strong>wget<\/strong> if it&rsquo;s not present on the system:<\/p><pre class=\"wp-block-preformatted\">sudo apt install wget<\/pre><p>Then, add the primary key with the following command:<\/p><pre class=\"wp-block-preformatted\">wget -q -O - https:\/\/www.apache.org\/dist\/cassandra\/KEYS | sudo apt-key add -<\/pre><h3 class=\"wp-block-heading\" id=\"h-3-add-the-cassandra-repository-file\">3. Add the Cassandra Repository File<\/h3><p>Add the Cassandra repository to the system&rsquo;s repository file. To do that, type the following command in the command line:<\/p><pre class=\"wp-block-preformatted\">echo \"deb http:\/\/www.apache.org\/dist\/cassandra\/debian 40x main\" | sudo tee -a \/etc\/apt\/sources.list.d\/cassandra.sources.list deb http:\/\/www.apache.org\/dist\/cassandra\/debian 40x main<\/pre><h3 class=\"wp-block-heading\" id=\"h-4-install-cassandra-on-ubuntu\">4. Install Cassandra on Ubuntu<\/h3><p>Refresh the repositories and then proceed to install Cassandra on Ubuntu:<\/p><pre class=\"wp-block-preformatted\">sudo apt-get update\nsudo apt install cassandra -y<\/pre><h3 class=\"wp-block-heading\" id=\"h-5-enable-and-start-cassandra\">5. Enable and Start Cassandra<\/h3><p>At the end of the installation, enable the Cassandra service to start automatically when the system boots. In addition, start it manually for the first time with the following commands:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl enable cassandra\nsudo systemctl start cassandra<\/pre><h3 class=\"wp-block-heading\" id=\"h-6-verify-the-installation\">6. Verify the Installation<\/h3><p>To check if the installation has been successful, check the status of the service. To do this, run the following command:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl status cassandra<\/pre><p>If successful and the Cassandra service is up and running, the output should look similar to the example below:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/systemctl-command-to-check-Cassandra_s-status.-In-this-case-Cassandra-process-is-already-active-and-running.png\"><img decoding=\"async\" width=\"735\" height=\"189\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/systemctl-command-to-check-Cassandra_s-status.-In-this-case-Cassandra-process-is-already-active-and-running.png\" alt=\"systemctl command to check Cassandra_s status. In this case Cassandra process is already active and running\" class=\"wp-image-65918\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/systemctl-command-to-check-Cassandra_s-status.-In-this-case-Cassandra-process-is-already-active-and-running.png 735w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/systemctl-command-to-check-Cassandra_s-status.-In-this-case-Cassandra-process-is-already-active-and-running-300x77.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/systemctl-command-to-check-Cassandra_s-status.-In-this-case-Cassandra-process-is-already-active-and-running-150x39.png 150w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-7-how-to-configure-cassandra-on-ubuntu\">7. How to Configure Cassandra on Ubuntu<\/h3><p>Cassandra&rsquo;s default configuration applies when Cassandra is used on a single node. However, if Cassandra is used in a cluster or by multiple Cassandra nodes simultaneously, it&rsquo;s handy to make some modifications to the configuration file.<\/p><p>The Cassandra configuration file is called <strong>cassandra.yaml<\/strong> and is located at <strong>\/etc\/cassandra\/<\/strong>. Open it with your preferred text editor and modify some of its settings:<\/p><pre class=\"wp-block-preformatted\">sudo nano \/etc\/cassandra\/cassandra.yaml<\/pre><p>Firstly, change the name of the cluster. Look for the <strong>cluster_name<\/strong> parameter and assign a name:<\/p><pre class=\"wp-block-preformatted\">cluster_name: [cluster_name]<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-cluster-name.png\"><img decoding=\"async\" width=\"630\" height=\"214\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-cluster-name.png\" alt=\"Cassandra configuration file opened with the nano editor. These particular lines indicate settings for the cluster name\" class=\"wp-image-65919\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-cluster-name.png 630w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-cluster-name-300x102.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-cluster-name-150x51.png 150w\" sizes=\"(max-width: 630px) 100vw, 630px\" \/><\/a><\/figure><\/div><p>It&rsquo;s preferrable to change the data storage port. To do this, look for the <strong>storage_port<\/strong> parameter and assign one.<\/p><p>Remember that it must be an available port in the <a href=\"\/ph\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\/\">Ubuntu firewall<\/a> for everything to work correctly. In our case, the port is set as <strong>7000<\/strong>.<\/p><pre class=\"wp-block-preformatted\">storage_port :[port]<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-storage-port.png\"><img decoding=\"async\" width=\"873\" height=\"235\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-storage-port.png\" alt=\"Cassandra configuration file opened with the nano editor. These particular lines indicate settings for the storage port\" class=\"wp-image-65920\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-storage-port.png 873w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-storage-port-300x81.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-storage-port-150x40.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Cassandra-configuration-file-opened-with-the-nano-editor.-These-particular-lines-indicate-settings-for-the-storage-port-768x207.png 768w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><\/a><\/figure><\/div><p>Finally, look for the <strong>seed_provider<\/strong> parameter and add the IP addresses of the nodes that make up the cluster, separated by a comma:<\/p><pre class=\"wp-block-preformatted\">Seeds: [node_ip]:[node_port],[node_ip]:[node_port]...[node_ip]:[node_port]<\/pre><p>Once done, save the file and reload Cassandra.<\/p><pre class=\"wp-block-preformatted\">sudo systemctl reload cassandra<\/pre><p>Now test out the connection with the following command:<\/p><pre class=\"wp-block-preformatted\">nodetool status<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/The-nodetool-status-command-showcasing-the-status-of-Cassandra_s-data-center.-In-this-case-it_s-up-and-running.png\"><img decoding=\"async\" width=\"453\" height=\"157\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/The-nodetool-status-command-showcasing-the-status-of-Cassandra_s-data-center.-In-this-case-it_s-up-and-running.png\" alt=\"The nodetool status command showcasing the status of Cassandra's data center. In this case, it's up and running\" class=\"wp-image-65921\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/The-nodetool-status-command-showcasing-the-status-of-Cassandra_s-data-center.-In-this-case-it_s-up-and-running.png 453w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/The-nodetool-status-command-showcasing-the-status-of-Cassandra_s-data-center.-In-this-case-it_s-up-and-running-300x104.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/The-nodetool-status-command-showcasing-the-status-of-Cassandra_s-data-center.-In-this-case-it_s-up-and-running-150x52.png 150w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/a><\/figure><\/div><p>Great, the cluster is up and running!<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>If you want to use an alternative database management system, check out our tutorial on <a href=\"\/ph\/tutorials\/how-to-install-postgresql-on-ubuntu\/\">how to install PostgreSQL on Ubuntu<\/a>.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-learn-basic-cassandra-query-language-cql-commands\">Learn Basic Cassandra Query Language (CQL) Commands<\/h2><p>The following section will showcase Cassandra&rsquo;s most popular basic CQL commands and provide some practical examples.<\/p><p><strong>cqlsh<\/strong><\/p><p><strong>cqlsh<\/strong>, or <strong>Cassandra query language shell<\/strong>, is used to communicate with Cassandra and initiate Cassandra Query Language. To start cqlsh, use the following command:<\/p><pre class=\"wp-block-preformatted\">root@myawesomevps:\/# cqlsh\nConnected to Test Cluster at 127.0.0.1:9042\n[cqlsh 6.0.0 | Cassandra 4.0.5 | CQL spec 3.4.5 | Native protocol v5]\nUse HELP for help.\ncqlsh&gt;<\/pre><p><strong>HELP<\/strong><\/p><p>The <strong>HELP<\/strong> command lists out descriptions for all possible cqlsh commands:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Help-command-for-Cassandra-Query-Language-window.-It-showcases-all-possible-Cassandra_s-commands.png\"><img decoding=\"async\" width=\"710\" height=\"526\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Help-command-for-Cassandra-Query-Language-window.-It-showcases-all-possible-Cassandra_s-commands.png\" alt=\"Help command for Cassandra Query Language window. It showcases all possible Cassandra's commands\" class=\"wp-image-65922\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Help-command-for-Cassandra-Query-Language-window.-It-showcases-all-possible-Cassandra_s-commands.png 710w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Help-command-for-Cassandra-Query-Language-window.-It-showcases-all-possible-Cassandra_s-commands-300x222.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2019\/04\/Help-command-for-Cassandra-Query-Language-window.-It-showcases-all-possible-Cassandra_s-commands-150x111.png 150w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><\/a><\/figure><\/div><p>For example, the output for <strong>HELP<\/strong> <strong>SHOW<\/strong> would look like this:<\/p><pre class=\"wp-block-preformatted\">cqlsh&gt; HELP SHOW\n\n        SHOW [cqlsh only]\n\nDisplays information about the current cqlsh session. Can be called in the following ways:\n\n        SHOW VERSION\n\nShows the version and build of the connected Cassandra instance, as well as the version of the CQL spec that the connected Cassandra instance understands.\n\n        SHOW HOST\n\nShows where cqlsh is currently connected.\n\n        SHOW SESSION &lt;sessionid&gt;\n\nPretty-prints the requested tracing session.\n\ncqlsh&gt;<\/pre><p><strong>SHOW<\/strong><\/p><p>The<strong> SHOW<\/strong> command displays all the information about the current cqlsh session. You can choose between showing <strong>host<\/strong>, <strong>version<\/strong>, and <strong>session<\/strong> information:<\/p><pre class=\"wp-block-preformatted\">cqlsh&gt; SHOW VERSION\n[cqlsh 6.0.0 | Cassandra 4.0.5 | CQL spec 3.4.5 | Native protocol v5]\n\ncqlsh&gt; SHOW HOST\nConnected to Test Cluster at 127.0.0.1:9042\ncqlsh&gt;<\/pre><p><strong>CREATE KEYSPACE<\/strong><\/p><p>A keyspace specifies data replication. In the following example, we will create a new keyspace and specify the replication factor:<\/p><pre class=\"wp-block-preformatted\">cqlsh&gt; CREATE KEYSPACE testingout\n  WITH REPLICATION = { \n   'class' : 'SimpleStrategy', \n   'replication_factor' : 1 \n  };<\/pre><p><strong>USE<\/strong><\/p><p>The <strong>USE<\/strong> command sets the current working keyspace:<\/p><pre class=\"wp-block-preformatted\">cqlsh&gt; USE testingout;\ncqlsh:testingout&gt;<\/pre><p><strong>CREATE TABLE<\/strong><\/p><p>In order to create a table, users need to use the <strong>CREATE TABLE<\/strong> command. Here they will need to specify <strong>column names<\/strong>, <strong>data types<\/strong>, and <strong>primary key<\/strong>:<\/p><pre class=\"wp-block-preformatted\">cqlsh:testingout&gt; CREATE TABLE tabletest (\n                     name TEXT PRIMARY KEY,\n                     surname TEXT,\n                     phone INT\n                   );<\/pre><p><strong>INSERT<\/strong><\/p><p><strong>INSERT<\/strong> command is used to add an entire row into a table. Mind that missing values will be set to null:<\/p><pre class=\"wp-block-preformatted\">cqlsh:testingout&gt; INSERT INTO tabletest (name, surname, phone) \nVALUES ('John', 'Johnson', 456123789);\ncqlsh:testingout&gt;<\/pre><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-comparing-cassandra-nosql-database-to-relational-databases\">Comparing Cassandra NoSQL Database to Relational Databases<\/h2><p>The following table will list the differences between relational databases such as MySQL and Cassandra:<\/p><figure tabindex=\"0\" class=\"wp-block-table is-style-regular\"><table><tbody><tr><td><\/td><td><strong>Relational databases<\/strong><\/td><td><strong>Cassandra<\/strong><\/td><\/tr><tr><td>Query language<\/td><td>Relational databases use complex and powerful SQL language<\/td><td>Cassandra, and NoSQL databases use elementary query language<\/td><\/tr><tr><td>Community<\/td><td>SQL databases communities are huge<\/td><td>Cassandra and NoSQL communities are still growing<\/td><\/tr><tr><td>Scalability<\/td><td>A relational database is scaled vertically by increasing hardware<\/td><td>Cassandra is scaled horizontally by adding additional servers<\/td><\/tr><tr><td>Data storage<\/td><td>Data structures is stored in tables with fixed rows and columns<\/td><td>Structured data is stored in documents<\/td><\/tr><tr><td>Best use cases<\/td><td>Relational databases are usually meant for general public usage<\/td><td>Cassandra is used in projects that need to handle big data workloads<\/td><\/tr><tr><td>Schema<\/td><td>A relational database schema is fixed<\/td><td>Cassandra schema is flexible<\/td><\/tr><\/tbody><\/table><\/figure><p>Cassandra suits big enterprises the most, as it&rsquo;s specifically designed to handle big data workloads. The fact that it&rsquo;s scaled horizontally also makes it truly versatile. Here&rsquo;s a more comprehensive look at the main technical features of Cassandra:<\/p><ul class=\"wp-block-list\">\n<li><strong>Scalability<\/strong> &ndash; business owners or users can add more resources as the demand increases without much hassle. <\/li>\n\n\n\n<li><strong>Data storage<\/strong> &ndash; Cassandra stores all types of data structures.<\/li>\n\n\n\n<li><strong>Efficiency<\/strong> &ndash; this NoSQL database system was designed to run quickly while using minimal resources.<\/li>\n\n\n\n<li><strong>Data transfer<\/strong> &ndash; Cassandra supports easy replication, which makes it effortless to transfer data between data centers.<\/li>\n\n\n\n<li><strong>No single point of failure<\/strong> &ndash; Cassandra doesn&rsquo;t have a <strong>single point of failure (SPOF)<\/strong>. It makes it invulnerable to any malfunction.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Choosing a suitable database management system can seem challenging, especially if you have high demands for it. A great solution is Apache Cassandra as it&rsquo;s one of the best NoSQL database management systems used by thousands of international companies.<\/p><p>In this tutorial, we have covered the Apache Cassandra installation process for Ubuntu. We&rsquo;ve also gone through the architecture of Cassandra, compared it to a relational database management system, and provided seven popular Cassandra Query Language commands.<\/p><p>We hope that you found this tutorial helpful. If you have any questions, leave them in the comments section down below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whenever users hear about database management systems, they likely immediately think about MySQL relational databases. However, such databases can fall short when presented with massive amounts of incoming structured data. That&rsquo;s where NoSQL databases come in. Cassandra is one of the most popular non-relational databases out there. Such companies use it as Instagram, Uber, Facebook, [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ph\/tutorials\/set-up-and-install-cassandra-ubuntu\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":279,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Install Cassandra Tutorial + Basic Commands","rank_math_description":"Cassandra is a NoSQL open source distributed database. Find out how to install it. Basic commands included.","rank_math_focus_keyword":"install cassandra ubuntu","footnotes":""},"categories":[],"tags":[],"class_list":["post-16626","post","type-post","status-publish","format-standard","hentry"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/set-up-and-install-cassandra-ubuntu","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/set-up-and-install-cassandra-ubuntu","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/set-up-and-install-cassandra-ubuntu\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/set-up-and-install-cassandra-ubuntu\/","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/set-up-and-install-cassandra-ubuntu","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/set-up-and-install-cassandra-ubuntu","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/set-up-and-install-cassandra-ubuntu","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/set-up-and-install-cassandra-ubuntu","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/16626","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/users\/279"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/comments?post=16626"}],"version-history":[{"count":18,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/16626\/revisions"}],"predecessor-version":[{"id":102753,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/16626\/revisions\/102753"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media?parent=16626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/categories?post=16626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/tags?post=16626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}