Ubuntu – How to uninstall Solr

14.04solruninstall

I used this DigitalOcean article to install Solr 5.3.1 in my system.

It worked fine. Now I wish to uninstall it. How do I carry that out?

All the existing articles seem to specify using apt-get but I can't find any solr-* packages to remove.

I also checked the tarball downloaded during installation and could not make out how to uninstall it or if it has an uninstall script just like the install script.

Best Answer

I have found the following definitions in install_solr_service.sh

  • SOLR_EXTRACT_DIR=/opt
  • SOLR_SERVICE=solr
  • SOLR_VAR_DIR=/var/$SOLR_SERVICE –>>>– /var/solr
  • SOLR_USER=solr
  • SOLR_INSTALL_DIR=$SOLR_EXTRACT_DIR/$SOLR_DIR –>>>– /opt/solr-5.3.1
  • SOLR_DIR=${SOLR_INSTALL_FILE%.tgz}
  • SOLR_INSTALL_FILE=${SOLR_ARCHIVE##*/}
  • SOLR_ARCHIVE=$1 –>>>– solr-5.3.1.tgz
  • ln -s $SOLR_INSTALL_DIR $SOLR_EXTRACT_DIR/$SOLR_SERVICE
  • cp $SOLR_INSTALL_DIR/bin/init.d/solr /etc/init.d/$SOLR_SERVICE

therefore

sudo service solr stop
sudo rm -r /var/solr
sudo rm -r /opt/solr-5.3.1
sudo rm -r /opt/solr
sudo rm /etc/init.d/solr
sudo deluser --remove-home solr
sudo deluser --group solr
sudo update-rc.d -f solr remove
sudo rm -rf /etc/default/solr.in.sh

and check the commands above twice before executing. One wrong space and you can reinstall your system.