17

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.

Braiam
  • 67,791
  • 32
  • 179
  • 269
callmekatootie
  • 443
  • 2
  • 5
  • 16

1 Answers1

43

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.

rjurney
  • 105
A.B.
  • 90,397
  • Just want to make sure that it is safe to manually remove it? – callmekatootie Oct 02 '15 at 08:15
  • That's the only way. ;) But you could read this first. – A.B. Oct 02 '15 at 08:17
  • @callmekatootie "tarball downloaded during installation " = manual install so the removal is manual too ;-) The removal part seems correct to me. Just be careful with the commands. (hitting enter just after typing sudo rm -r /var/ would be problematic ;) ) – Rinzwind Oct 02 '15 at 08:55
  • Ok. I noticed that I get warning about group solr no longer has any more members and when I try installing again, I get the message Warning: The home dir /home/solr already exists. Not copying from/etc/skel` - should that also be part of the uninstallation steps? – callmekatootie Oct 04 '15 at 15:13
  • 2
    Both is ok, I have improved the answer. You could remove the home folder sudo rm -r /home/solr – A.B. Oct 04 '15 at 16:11
  • 4
    You are missing this, if you want to re-install it again. sudo update-rc.d -f solr remove and sudo rm -rf /etc/default/solr.in.sh – Suneel Kumar Jun 27 '16 at 12:44
  • 1
    @SuneelKumar thank you brother, you saved my arse. Comment in my delete script includes a link here and "but NOTE THE COMMENT from SuneelKumar". I have edited the answer to reflect these necessary commands :) – rjurney Jun 19 '20 at 22:07
  • Thank you for this. – Paul Danelli Jul 05 '21 at 08:44
  • how to remove installed solr service? – Krunal May 11 '22 at 12:54