1.删除组件

yum remove -y hive*
yum remove -y hdfs*
yum remove -y yarn*
yum remove -y mapreduce2*
yum remove -y tez*
yum remove -y hbase*
yum remove -y pig*
yum remove -y sqoop*
yum remove -y oozie*
yum remove -y zookeeper*
yum remove -y falcon*
yum remove -y storm*
yum remove -y flume*
yum remove -y accumulo*
yum remove -y Ambari Infra*
yum remove -y Ambari Metrics*
yum remove -y Atlas*
yum remove -y Kafka*
yum remove -y Knox*
yum remove -y Log Search*
yum remove -y Ranger*
yum remove -y Ranger KMS*
yum remove -y SmartSense*
yum remove -y Zeppelin Notebook*
yum remove -y Druid*
yum remove -y Mahout*
yum remove -y Slider*
yum remove -y atlas*
yum remove -y atlas-metadata*
yum remove -y ranger*
yum remove -y bigtop*
yum remove -y spark2*
yum remove -y ranger*
yum remove -y slider*
yum remove -y ranger*
yum remove -y spark*

2.删除ambari-server和ambari-agent

ambari-server stop
ambari-agent stop
yum erase ambari-server –y
yum erase ambari-agent -y

3.检查组件是否删除干净

删除查询出来的组件

yum list installed | grep ambari  
yum list installed | grep hdp

4.删除用户

userdel accumulo
userdel admin
userdel ambari-qa
userdel ams
userdel atlas
userdel falcon
userdel flume
userdel hadoop
userdel hbase
userdel hcat
userdel hdfs
userdel hive
userdel kafka
userdel kms
userdel knox
userdel mapred
userdel nagios
userdel oozie
userdel postgres
userdel puppet
userdel ranger
userdel rrdcached
userdel spark
userdel sqoop
userdel storm
userdel tez
userdel yarn
userdel yarn-ats
userdel zeppelin
userdel zookeeper

5.删除所有节点上的存储库

rm -rf /etc/yum.repos.d/ambari.repo /etc/yum.repos.d/HDP.repo /etc/yum.repos.d/libtirpc.repo
yum clean all

6.删除日志目录

rm -rf /var/log/ambari* /var/log/hadoop /var/log/hbase /var/log/hive /var/log/oozie /var/log/sqoop /var/log/zookeeper /var/log/flume /var/log/storm /var/log/hive-hcatalog /var/log/falcon /var/log/webhcat /var/log/hadoop-hdfs /var/log/hadoop-yarn /var/log/hadoop-mapreduce /var/log/spark /var/log/spark2 /var/log/ranger /var/log/atlas /var/log/kafka /var/log/knox /var/log/livy2 /var/log/zeppelin /var/log/accumulo /var/log/hst /var/log/solr /var/log/falcon

7.删除配置目录

rm -rf /etc/ambari* /etc/zookeeper/ /etc/ranger* /etc/rc.d/init.d/ranger* /etc/hadoop /etc/hadoop-httpfs /etc/hbase/ /etc/hive /etc/zookeeper/ /etc/flume /etc/hive-hcatalog /etc/hive-webhcat /etc/phoenix /etc/ambari-metrics-collector /etc/ambari-metrics-monitor /etc/kafka /etc/oozie /etc/storm /etc/tez* /etc/falcon /etc/slider /etc/pig /etc/storm-slider-client /etc/ams-hbase /etc/atlas /etc/hive_llap /etc/hst /etc/knox /etc/livy2 /etc/spark2 /etc/sqoop /etc/zeppelin /etc/rc.d/init.d/ambari*

8.删除pid目录

rm -rf /var/run/accumulo
rm -rf /var/run/ambari-agent
rm -rf /var/run/ambari-infra-solr
rm -rf /var/run/ambari-logsearch-*
rm -rf /var/run/ambari-metrics-*
rm -rf /var/run/ambari-server
rm -rf /var/run/ams-hbase
rm -rf /var/run/atlas
rm -rf /var/run/falcon
rm -rf /var/run/flume
rm -rf /var/run/ganglia
rm -rf /var/run/hadoop
rm -rf /var/run/hadoop-mapreduce
rm -rf /var/run/hadoop-yarn
rm -rf /var/run/hbase
rm -rf /var/run/hive
rm -rf /var/run/hive-hcatalog
rm -rf /var/run/hive2
rm -rf /var/run/hst
rm -rf /var/run/kafka/
rm -rf /var/run/knox/
rm -rf /var/run/livy2/
rm -rf /var/run/nagios
rm -rf /var/run/oozie
rm -rf /var/run/ranger*
rm -rf /var/run/smartsense-activity-*
rm -rf /var/run/spark
rm -rf /var/run/spark2
rm -rf /var/run/sqoop
rm -rf /var/run/webhcat
rm -rf /var/run/zookeeper

9.删除lib库目录

rm -rf /var/lib/ambari*
rm -rf /var/lib/ams-hbase
rm -rf /var/lib/flume
rm -rf /var/lib/hadoop-hdfs
rm -rf /var/lib/hadoop-mapreduce
rm -rf /var/lib/hadoop-yarn
rm -rf /var/lib/hive
rm -rf /var/lib/hive2*
rm -rf /var/lib/knox
rm -rf /var/lib/oozie
rm -rf /var/lib/ranger
rm -rf /var/lib/storm
rm -rf /var/lib/smartsense
rm -rf /var/lib/spark2
rm -rf /var/lib/slider
rm -rf /var/lib/zookeeper
rm -rf /usr/lib/ambari*
rm -rf /usr/lib/ams-hbase
rm -rf /usr/lib/storm
rm -rf /usr/lib/hadoop
rm -rf /usr/lib/hbase
rm -rf /usr/lib/hcatalog
rm -rf /usr/lib/hive
rm -rf /usr/lib/sqoop
rm -rf /usr/lib/zookeeper
rm -rf /usr/lib/flume

10.删除/var/tmp目录

rm -rf /var/tmp/oozie 
rm -rf /var/tmp/sqoop

11.删除/tmp下目录

rm -rf /tmp/ambari*
rm -rf /tmp/hadoop-hdfs
rm -rf /tmp/hadoop-yarn
rm -rf /tmp/hadoop-hive
rm -rf /tmp/hadoop-nagios
rm -rf /tmp/hadoop-hcat
rm -rf /tmp/hadoop-ambari-qa
rm -rf /tmp/hbase-atlas
rm -rf /tmp/hbase-hbase
rm -rf /tmp/hbase-root
rm -rf /tmp/hive
rm -rf /tmp/hsperfdata_accumulo
rm -rf /tmp/hsperfdata_ambari-qa
rm -rf /tmp/hsperfdata_ams
rm -rf /tmp/hsperfdata_atlas
rm -rf /tmp/hsperfdata_hbase
rm -rf /tmp/hsperfdata_hcat
rm -rf /tmp/hsperfdata_hdfs
rm -rf /tmp/hsperfdata_hive
rm -rf /tmp/hsperfdata_kafka
rm -rf /tmp/hsperfdata_knox
rm -rf /tmp/hsperfdata_logsearch
rm -rf /tmp/hsperfdata_mapred
rm -rf /tmp/hsperfdata_nagios
rm -rf /tmp/hsperfdata_oozie
rm -rf /tmp/hsperfdata_yarn
rm -rf /tmp/hsperfdata_yarn-ats
rm -rf /tmp/hsperfdata_zookeeper
rm -rf /tmp/sqoop-ambari-qa
rm -rf /tmp/hcat
rm -rf /tmp/hadoop-hdfs

12.删除ambari相关包

rm -rf /var/lib/ambari*
rm -rf /var/log/ambari*
rm -rf /etc/ambari*

13.删除具体数据目录

rm -rf /hadoop/*
rm -rf /usr/hdp/
rm -rf /kafka-logs/
rm -rf /hadoop/zookeeper
rm -rf /hadoop/hdfs
rm -rf /kafka-logs

14.查看剩余残留

find / -name *hcat* | xargs rm -rf
find / -name hdfs* | xargs rm -rf
find / -name *hdp*| xargs rm -rf
find / -name *hive* | xargs rm -rf
find / -name *hiveserver2* | xargs rm -rf
find / -name *kafka* | xargs rm -rf
find / -name *mahout* | xargs rm -rf
find / -name *mapred*| xargs rm -rf