What is Cassandra ?
Apache Cassandra is a free and open-source, distributed, wide column store, NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure.
How To Install Cassandra On CentOs 7.x ?
Apache Cassandra requires OpenJDK to be installed on the system.
To install openjdk, run below command on your system.
[root@tecgeek ~]# yum install java-1.8.0-openjdk
You can verify your Java installation by running the following command.
[root@tecgeek ~]# java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
[root@tecgeek ~]#
Now Next step is to start Cassandra installation, But prior to that we'll create Apache Cassandra Repository.
[root@tecgeek ~]# vim /etc/yum.repos.d/cassandra.repo
Copy following content into this file.
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS
Once this is ready, then start installation of Cassandra using yum.
[root@tecgeek ~]# yum install cassandra
To enable and start the service
[root@tecgeek ~]# systemctl enable cassandra
[root@tecgeek ~]# systemctl start cassandra
Verify Cassandra running status :
[root@tecgeek ~]# nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 103.68 KiB 256 100.0% 12345he7-323d-443-43b2-5dc46b45a721 rack1
[root@tecgeek ~]#
So far we have seen installation steps of Cassandra, Now lets move on next to the configuration part......
How to configure Cassandra ?
There are three important file/folder directive of Cassandra as follow
/var/lib/cassandra/ [Directory] : Apache Cassandra Data Store Directory
/etc/cassandra/ [Directory] : Configuration Files gets store here
/etc/default/cassandra [File] : Java-Startup option can be configured here
To connect with Cassandra database you have to CQL (Cassandra Query Language) command line utility ie cqlsh
[root@tecgeek ~]# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
Renaming Cassandra Cluster :
By Default name of Cassandra cluster is Test you can get this change by following below steps. In below example I'll check my cluster name from Test to Tecgeek.
1. Login to Cassandra with cqlsh and run below query.
[root@tecgeek ~]# cqlsh
cqlsh>UPDATE system.local SET cluster_name = 'Tecgeek' WHERE KEY = 'local';
cqlsh>
2. Edit cassandra.yaml ie /etc/cassandra/default.conf/cassandra.yaml to enter your cluster name.
cluster_name: 'Tecgeek'
3. Run below command to clear system cache.
[root@tecgeek ~]# nodetool flush system
4. Restart Cassandra Service.
[root@tecgeek ~]# systemctl restart cassandra
Comentários