{"id":6589,"date":"2017-03-29T20:29:43","date_gmt":"2017-03-29T12:29:43","guid":{"rendered":"http:\/\/rmohan.com\/?p=6589"},"modified":"2017-03-29T20:30:48","modified_gmt":"2017-03-29T12:30:48","slug":"apache-cassandra","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6589","title":{"rendered":"Apache Cassandra Centos 7"},"content":{"rendered":"<p>Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster.<br \/>\nCassandra or Apache Cassandra is a distributed database system which manages large amounts of structured data across different commodity servers by providing highly available service with no point of failure.<br \/>\nNoSQL refers to a database with a data model other than the tabular relations used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL.<br \/>\nThe Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance.<\/p>\n<p>Cassandra is one the popular and robust distributed database management system. It is known for providing high availability with no single point of failure.<br \/>\nIt has one of the awesome feature that is asynchronous replication between multiple nodes without requiring master nodes.<br \/>\nCassandra is a reliable, clusterable, highly-scalable database capable of handling large quantities of data on commodity hardware.<br \/>\nIf you have big data needs, and are looking for a proven open source solution that has received battle testing from many large companies, then Cassandra may be exactly what you\u2019re looking for.<\/p>\n<p>If you have a CentOS 7 server, this guide will get you up and running with a single Cassandra node.<br \/>\nIt will use pre-packaged Cassandra distributions built for CentOS, making installation and upgrades a snap.<br \/>\nYou can then build it out by performing additional installations on other servers, then clustering the resulting instances for higher scalability and reliability.<\/p>\n<p>This article will guide you on how to install Apache Cassandra on CentOS 7 Server.<\/p>\n<p>CentOS 7 Cassandra systemd service file<\/p>\n<p># \/usr\/lib\/systemd\/system\/cassandra.service<\/p>\n<p>[Unit]<br \/>\nDescription=Cassandra<br \/>\nAfter=network.target<\/p>\n<p>[Service]<br \/>\nPIDFile=\/var\/run\/cassandra\/cassandra.pid<br \/>\nUser=cassandra<br \/>\nGroup=cassandra<br \/>\nExecStart=\/usr\/sbin\/cassandra -f -p \/var\/run\/cassandra\/cassandra.pid<br \/>\nStandardOutput=journal<br \/>\nStandardError=journal<br \/>\nLimitNOFILE=100000<br \/>\nLimitMEMLOCK=infinity<br \/>\nLimitNPROC=32768<br \/>\nLimitAS=infinity<br \/>\nRestart=always<\/p>\n<p>[Install]<br \/>\nWantedBy=multi-user.target<\/p>\n<p>How To Install Cassandra on CentOS 7<\/p>\n<p>Step 1: Install Java<\/p>\n<p>First, you\u2019ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.<\/p>\n<p>yum -y update<\/p>\n<p>At this point, installing lsyncd is as simple as running just one command:<\/p>\n<p>yum -y install java<\/p>\n<p>tar -zxvf jdk-8u121-linux-x64.tar.gz<\/p>\n<p>mv jdk-8u121-linux-x64.tar.gz \/root\/software\/<\/p>\n<p>vi \/etc\/profile.d\/java.sh<br \/>\n# Uncomment the following line to set the JAVA_HOME variable a<br \/>\n#JAVA_HOME=\/usr\/lib\/jvm\/jre<br \/>\nexport JAVA_HOME=\/usr\/java\/jdk1.8.0_121<br \/>\nexport JRE_HOME=\/usr\/java\/jdk1.8.0_121\/jre<br \/>\nexport PATH=$PATH:\/usr\/java\/jdk1.8.0_121\/bin<br \/>\nexport CLASSPATH=.\/:\/usr\/java\/jdk1.8.0_121\/lib:\/usr\/java\/jdk1.8.0_121\/jre\/lib<\/p>\n<p>source \/etc\/profile.d\/java.sh<br \/>\nexport<br \/>\nalternatives &#8211;config java<br \/>\nalternatives &#8211;install \/usr\/bin\/java java \/usr\/java\/jdk1.8.0_121\/bin\/java 5<br \/>\nalternatives &#8211;config java<\/p>\n<p>Step #2: Add the DataStax Community Repository<\/p>\n<p>vim \/etc\/yum.repos.d\/datastax.repo<\/p>\n<p>Add the following information to the file you\u2019ve created, using i to insert:<\/p>\n<p>[datastax]<br \/>\nname = DataStax Repo for Apache Cassandra<br \/>\nbaseurl = http:\/\/rpm.datastax.com\/community<br \/>\nenabled = 1<br \/>\ngpgcheck = 0<\/p>\n<p>Step #3: Install Apache Cassandra 2<\/p>\n<p>At this point, installing Cassandra is as simple as running just one command:<\/p>\n<p>yum -y install dsc20<\/p>\n<p>Step #4: Get Cassandra Running<\/p>\n<p>Start-Up Cassandra<\/p>\n<p>systemctl start cassandra<\/p>\n<p>Check Cassandra Service Status<\/p>\n<p>systemctl status cassandra<\/p>\n<p>Enable Cassandra to Start at Boot<\/p>\n<p>systemctl enable cassandra<\/p>\n<p>Enter the Cassandra Command Line<\/p>\n<p>cqlsh<\/p>\n<p>With Cassandra installed, we must now start the daemon via systemd.<br \/>\n\/etc\/init.d\/cassandra start<\/p>\n<p>The systemd unit is now created. Use \u201csystemctl start cassandra\u201d to launch the new unit.<\/p>\n<p>systemctl enable cassandra.service<\/p>\n<p>While the database should be running, it is not yet configured to launch on boot. Let\u2019s tell systemd that Cassandra should automatically launch whenever your system boots.<\/p>\n<p>[root@cassandra ~] systemctl status cassandra<\/p>\n<p>cassandra.service &#8211; SYSV: Starts and stops Cassandra<br \/>\nLoaded: loaded (\/etc\/rc.d\/init.d\/cassandra)<br \/>\nActive: active (exited) since Thu 2016-09-15 04:36:47 UTC; 14s ago<br \/>\nDocs: man:systemd-sysv-generator(8)<br \/>\nProcess: 9413 ExecStart=\/etc\/rc.d\/init.d\/cassandra start (code=exited, status=0\/SUCCESS)<\/p>\n<p>Let\u2019s ensure that Cassandra is running using this command.<\/p>\n<p>[root@cassandra ~] cqlsh<\/p>\n<p>Connected to Test Cluster at localhost:9160.<br \/>\n[cqlsh 4.1.1 | Cassandra 2.0.17 | CQL spec 3.1.1 | Thrift protocol 19.39.0]<br \/>\nUse HELP for help.<br \/>\ncqlsh&gt;<\/p>\n<p>assandra ships with a powerful command line utility, cqlsh. Launch it to perform various vital tasks with your database.<\/p>\n<p>[root@rmohan.com ~] nodetool status<\/p>\n<p>Datacenter: rmohan<br \/>\n=======================<br \/>\nStatus=Up\/Down<br \/>\n|\/ State=Normal\/Leaving\/Joining\/Moving<br \/>\n&#8212; Address Load Tokens Owns (effective) Host ID Rack<br \/>\nUN 127.0.0.1 46.21 KB 256 100.0% 7dd2b7d9-404e-4a77-a36d-cc8f55168c0d rack1<br \/>\n[root@rmohan.com ~]#<\/p>\n<p>Restart Cassandra<\/p>\n<p>systemctl restart cassandra<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. Cassandra or Apache Cassandra is a distributed database system which manages large amounts of structured data across different commodity servers by providing highly available service with no point of failure. NoSQL refers to a database with [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[83],"tags":[84],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6589"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6589"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6589\/revisions"}],"predecessor-version":[{"id":6591,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6589\/revisions\/6591"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}