{"id":2742,"date":"2018-01-18T20:44:17","date_gmt":"2018-01-18T17:44:17","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-install-cassandra-database-on-centos-7\/"},"modified":"2018-01-18T20:44:17","modified_gmt":"2018-01-18T17:44:17","slug":"how-to-install-cassandra-distributed-database-on-centos-7","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-cassandra-distributed-database-on-centos-7\/","title":{"rendered":"How to Install Cassandra Distributed Database on CentOS 7"},"content":{"rendered":"<div><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/01\/how-to-install-cassandra-distributed-database-on-centos-7.gif\" class=\"ff-og-image-inserted\" alt=\"\" title=\"\"><\/div>\n<p>Cassandra is a free and open source distributed database management system that can be used to handle large amounts of data across many servers. It is reliable, clusterable and specialy designed to handle very large amounts of structured data. Cassandra also supports replication and multi-data center replication for redundancy, failover, and disaster recovery.<\/p>\n<p>In this tutorial, we will learn how to install and configure Cassandra on CentOS 7.<\/p>\n<h2 id=\"prerequisite\">Prerequisite<\/h2>\n<ul>\n<li>A server running CentOS 7.<\/li>\n<li>A non-root user with sudo privileges setup on your server.<\/li>\n<\/ul>\n<h2 id=\"getting-started\">Getting Started<\/h2>\n<p>Before starting, update your system with the latest version with the following command:<\/p>\n<p class=\"command\">sudo yum update -y<\/p>\n<p>Cassandra is written in Java, so you will need to install Java to your system. You can install Java by just running the following command:<\/p>\n<p class=\"command\">sudo yum install java -y<\/p>\n<p>After installing Java, you can verify the version of the Java with the following command:<\/p>\n<p class=\"command\">sudo java -version<\/p>\n<p>You should see the Java version in the following output:<\/p>\n<pre>openjdk version \"1.8.0_151\"&#13;\nOpenJDK Runtime Environment (build 1.8.0_151-b12)&#13;\nOpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)&#13;\n<\/pre>\n<h2 id=\"install-cassandra\">Install Cassandra<\/h2>\n<p>By default, Cassandra is not available in CentOS 7 default repository. So you will need to add the official Apache Software Foundation repositories to your system. You can do this by creating cassandra.repo file inside \/etc\/yum.repos.d directory:<\/p>\n<p class=\"command\">sudo nano \/etc\/yum.repos.d\/cassandra.repo<\/p>\n<p>Add the following line:<\/p>\n<pre>[cassandra]&#13;\nname = DataStax Repo for Apache Cassandra&#13;\nbaseurl = http:\/\/rpm.datastax.com\/community&#13;\nenabled = 1&#13;\ngpgcheck = 0&#13;\n<\/pre>\n<p>Save and close the file when you are finished, then update the repository with the following command:<\/p>\n<p class=\"command\">sudo yum update -y<\/p>\n<p>Next, install Cassandra using the following command:<\/p>\n<p class=\"command\">sudo yum install dsc20 -y<\/p>\n<p>After installing Cassandra, start the Cassandra service and enable it to start on boot time with the following command:<\/p>\n<p class=\"command\">sudo systemctl start cassandra<br \/>sudo systemctl enable cassandra<\/p>\n<p>You can also check the status of the Cassandra service using the following command:<\/p>\n<p class=\"command\">sudo systemctl status cassandra<\/p>\n<p>If everything is fine, you should see the following output:<\/p>\n<pre>? cassandra.service - SYSV: Starts and stops Cassandra&#13; Loaded: loaded (\/etc\/rc.d\/init.d\/cassandra; bad; vendor preset: disabled)&#13; Active: active (exited) since Sun 2017-12-17 17:53:58 IST; 12s ago&#13; Docs: man:systemd-sysv-generator(8)&#13; Process: 15323 ExecStart=\/etc\/rc.d\/init.d\/cassandra start (code=exited, status=0\/SUCCESS)&#13;\n&#13;\nDec 17 17:53:55 centOS-7 systemd[1]: Starting SYSV: Starts and stops Cassandra...&#13;\nDec 17 17:53:56 centOS-7 su[15332]: (to cassandra) root on none&#13;\nDec 17 17:53:58 centOS-7 cassandra[15323]: Starting Cassandra: OK&#13;\nDec 17 17:53:58 centOS-7 systemd[1]: Started SYSV: Starts and stops Cassandra.&#13;\n&#13;\n<\/pre>\n<h2 id=\"connect-and-check-cassandra-cluster\">Connect and Check Cassandra Cluster<\/h2>\n<p>Cassandra is now up and running. It&#8217;s time to verify and connect Cassandra Cluster.<\/p>\n<p>You can verify the Cassandra Cluster status with the following command:<\/p>\n<p class=\"command\">sudo nodetool status<\/p>\n<p>If everything is fine, you should see the following output:<\/p>\n<pre>Datacenter: datacenter1&#13;\n=======================&#13;\nStatus=Up\/Down&#13;\n|\/ State=Normal\/Leaving\/Joining\/Moving&#13;\n-- Address Load Tokens Owns (effective) Host ID Rack&#13;\nUN 127.0.0.1 65.15 KB 256 100.0% 516af85e-2e6a-454a-b27f-6eacafa6b978 rack1&#13;\n<\/pre>\n<p>Next, connect the Cassandra Cluster using the cqlsh command as shown below:<\/p>\n<p class=\"command\">cqlsh<\/p>\n<p>You should see the following output:<\/p>\n<pre>Connected to Test Cluster at localhost:9160.&#13;\n[cqlsh 4.1.1 | Cassandra 2.0.17 | CQL spec 3.1.1 | Thrift protocol 19.39.0]&#13;\nUse HELP for help.&#13;\ncqlsh&gt; &#13;\n<\/pre>\n<p>Next, exit from the Cassandra command line interface with the following command:<\/p>\n<p class=\"command\">cqlsh&gt; exit<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Cassandra is a free and open source distributed database management system that can be used to handle large amounts of data across many servers. It is reliable, clusterable and specialy designed to handle very large amounts of structured data. Cassandra also supports replication and multi-data center replication for redundancy, failover, and disaster recovery. In this &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2742","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=2742"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2742\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=2742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=2742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=2742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}