Register the Apache Cassandra repository, install Cassandra services, and verify that the installation is successful.

Prerequisites

Verify that you have Python 2.7.5 or later, that all Cassandra hosts are NTP configured, and that Java 1.8.x is installed and configured. For more information, see Prepare Hosts for Cassandra Installation.

Procedure

  1. To register the Apache Cassandra repository, create the /etc/yum.repos.d/cassandra.repo file with the following content:
    [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
  2. Install Cassandra by running the following command.

    # yum install cassandra

  3. If a Cassandra PID directory does not exist at /var/run/cassandra, run the following command to create it.

    # mkdir -p /var/run/cassandra; chown -R cassandra:cassandra /var/run/cassandra

  4. If you are configuring a Cassandra cluster, configure all nodes to use GossipingPropertyFileSnitch.

    It is a best practice to use GossipingPropertyFileSnitch for production environments. The GossipingPropertyFileSnitch uses rack and data center information for the local node defined in the /etc/cassandra/default.conf/cassandra-rackdc.properties file and propagates this information to other nodes by using the gossip protocol.

    To configure a node to use GossipingPropertyFileSnitch, edit the cassandra-rackdc.properties and the /etc/cassandra/conf/cassandra.yaml files.

    1. Define data center and rack that include this node. By default, the following values are set:
      dc=DC1
      rack=RAC1
      Note:

      Data center and rack names are case-sensitive.

    2. To save bandwidth, add the prefer_local=true option. This option tells the Apache Cassandra platform to use the local IP address when the communication is not across different data centers.
    3. In the /etc/cassandra/conf/cassandra.yaml file, locate the endpoint_snitch line and change the value to GossipingPropertyFileSnitch.
  5. Enable the Cassandra service.

    # systemctl enable cassandra

  6. If you are configuring a Cassandra cluster, set the cluster name.

    You set a Cassandra cluster name by editing the cluster_name option in the /etc/cassandra/conf/cassandra.yaml file. By default, the cluster_name is Test Cluster.

  7. Start the Cassandra service.

    # systemctl start cassandra

  8. Check the Cassandra service status.

    # systemctl status cassandra