Removing all traces of Cassandra or DSE packages

After a failed attempt to provision a node or a cluster, you must remove all traces of Cassandra or DSE packages from the affected nodes.

If a provisioning task failed, the following script can be used to remove all packages from the node.

Procedure

  1. Log into each node.
  2. Run the following BASH script on each node using sudo.
    
    #!/bin/bash
    
    # Stop services
    /etc/init.d/cassandra stop
    /etc/init.d/dse stop
    /etc/init.d/datastax-agent stop
    
    # Remove packages
    PACKAGES=(dsc dsc1.1 dsc12 cassandra apache-cassandra1 dsc-demos \
    dse-libspark \
    dse dse-libhadoop-native dse-libhadoop dse-libcassandra dse-hive dse-libhive dse-pig \
    dse-libpig dse-demos dse-libsqoop dse-libtomcat dse-liblog4j dse-libsolr dse-libmahout dse-full)
    DEB_PACKAGES=(python-cql python-thrift-basic)
    RPM_PACKAGES=(python26-cql python26-thrift)
    if [ `which dpkg` ]; then
    PLIST=(${PACKAGES[@]} ${DEB_PACKAGES[@]})
    dpkg -P ${PLIST[*]}
    rm -rf /etc/apt/sources.list.d/datastax.list
    else
    PLIST=(${PACKAGES[@]} ${RPM_PACKAGES[@]})
    yum -y remove ${PLIST[*]}
    rm -rf  /etc/yum.repos.d/datastax.repo
    fi
    
    # Cleanup log and configuration files
    rm -rf /var/lib/cassandra/* /var/log/{cassandra,hadoop,hive,pig}/* /etc/{cassandra,dse}/* \
    /usr/share/{dse,dse-demos} /etc/default/{dse,cassandra}
    
    • copy, paste, and run the script from the command line
    • save the script to a local file and copy to each node to run from the command line