Removing all Cassandra or DataStax Enterprise files after failed provisioning

After a failed attempt to provision a node or a cluster, you must remove all traces of Cassandra or DataStax Enterprise packages from the affected nodes before retrying provisioning.

After a failed attempt to provision a node or a cluster, you must remove all traces of Cassandra or DataStax Enterprise packages from the affected nodes. Use the following script to remove all packages from the node.

  1. Log into each node and run the following BASH script on each node using sudo.
  2. 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.
    
    #!/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}