Support Questions

Find answers, ask questions, and share your expertise

How to remove an old HDP version

avatar
Contributor

How are you supposed to remove an old version of HDP once you have successfully upgraded to a new version?

The old version is still listed as installed and the "Deregister" button is disabled because "it is installed".

It would be easy to delete the /usr/hdp/[old version] folder but all the packages would still be considered installed by the OS. On the other hand trying to remove the old packages manually on each node is cumbersome and risky.

Leaving behing GBs of data and lots of packages will easily buildup as you upgrade to new versions over the years.

1 ACCEPTED SOLUTION

avatar

There's an API to remove older versions from the hosts. Take a look at https://issues.apache.org/jira/browse/AMBARI-18435

E.g.,

curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/requests' -u admin:admin -H "X-Requested-By: ambari" -X POST -d'{"RequestInfo":{"context":"remove_previous_stacks", "action" : "remove_previous_stacks", "parameters" : {"version":"2.5.0.0-1245"}}, "Requests/resource_filters": [{"hosts":"c6403.ambari.apache.org, c6402.ambari.apache.org"}]}' 

That removes all versions older than "2.5.0.0-1245"; the version mentioned in request remains intact. We also have checks that prevent removing the current version and the operation is idempotent.

That will not remove the version from Ambari's database, but will free up space.

View solution in original post

11 REPLIES 11

avatar
New Contributor

Hi,

I've used:

yumdb search from_repo HDP-2.6-repo-1* | grep -v from_repo | grep -e . | sort > ~/pkg_to_remove_HDP-2.6-repo-1.lst && yum remove $(cat ~/pkg_to_remove_HDP-2.6-repo-1.lst | tr '\n' ' ' )

Just replace the 'HDP-2.6-repo-1' with the repository name of the version you're want to remove (ie: found /etc/yum.repos.d/ambari-hdp* files).

This method store a file in home directory with the list of packages removed, just in case you need to re-install something.

avatar
New Contributor

Not really safe at the end...

While this worked perfectly on client nodes, there seems to be dependencies with more recent versions and there is a risk you remove them if you don't watch carefully before hitting the "Y" key!