本文针对 rpm 包安装的 Ambari 集群,应用文件存储的路径比较分散,找起来比较麻烦。特记录一下,以便以后查看,以节约时间。

卸载前确保集群所有服务进程已经停止

查看集群安装的组件方法

Ambari 组件查找

[root@node01 ~]# rpm -qa|grep ambari
ambari-metrics-hadoop-sink-2.6.2.2-1.x86_64
ambari-server-2.6.2.2-1.x86_64
ambari-agent-2.6.2.2-1.x86_64
ambari-metrics-monitor-2.6.2.2-1.x86_64
ambari-metrics-grafana-2.6.2.2-1.x86_64
ambari-metrics-collector-2.6.2.2-1.x86_64

HST 组件查找

[root@node01 ~]# rpm -qa|grep smartsense
smartsense-hst-1.4.5.2.6.2.2-1.x86_64

Hadoop 组件查找

[root@node01 ~]# rpm -qa|grep hadoop
hadoop_2_6_5_0_292-yarn-2.7.3.2.6.5.0-292.x86_64
hadoop_2_6_5_0_292-client-2.7.3.2.6.5.0-292.x86_64
ambari-metrics-hadoop-sink-2.6.2.2-1.x86_64
hadoop_2_6_5_0_292-2.7.3.2.6.5.0-292.x86_64
hadoop_2_6_5_0_292-mapreduce-2.7.3.2.6.5.0-292.x86_64
hadoop_2_6_5_0_292-libhdfs-2.7.3.2.6.5.0-292.x86_64
hadoop_2_6_5_0_292-hdfs-2.7.3.2.6.5.0-292.x86_64

Hadoop 集群依赖组件查找

[root@node01 ~]# rpm -qa|grep ranger
ranger_2_6_5_0_292-yarn-plugin-0.7.0.2.6.5.0-292.x86_64
ranger_2_6_5_0_292-hdfs-plugin-0.7.0.2.6.5.0-292.x86_64
[root@node01 ~]# rpm -qa|grep spark
spark_2_6_5_0_292-yarn-shuffle-1.6.3.2.6.5.0-292.noarch
spark2_2_6_5_0_292-yarn-shuffle-2.3.0.2.6.5.0-292.noarch

Zookeeper 组件查找

[root@node01 ~]# rpm -qa|grep zookeeper
zookeeper_2_6_5_0_292-3.4.6.2.6.5.0-292.noarch
zookeeper_2_6_5_0_292-server-3.4.6.2.6.5.0-292.noarch

HDP 依赖组件查找

[root@node01 ~]# rpm -qa|grep hdp
hdp-select-2.6.5.0-292.noarch
[root@node01 ~]# rpm -qa|grep bigtop
bigtop-jsvc-1.0.15-292.x86_64

** 测试环境是比较简单的一个集群,大部分组件没有安装。根据自己的安装组件情况去查找安装包

卸载应用(以 Ambari-server为例,其它应用参考这个方法)

卸载应用前,先确定应用的安装路径

[root@node01 ~]# rpm -ql ambari-server-2.6.2.2-1.x86_64|awk 'BEGIN{FS="/"} {OFS="/";print "",$2,$3,$4}'|uniq  
/etc/ambari-server/conf
/etc/init.d/ambari-server
/etc/init/ambari-server.conf
/usr/lib/ambari-server
/usr/sbin/ambari-server.py
/usr/sbin/ambari_server_main.py
/var/lib/ambari-server
/var/log/ambari-server
/var/run/ambari-server

卸载应用

[root@node01 ~]# rpm -e ambari-server-2.6.2.2-1.x86_64
** 有些应用卸载时需要与依赖应用一起卸载
** 删除安装路径下的相关文件及目录,大部分在卸载的时候已经自动删除
** 找到并删除残留文件及目录
** 全部卸载完成后删除集群数据文件

删除 Ambari 自动创建的用户及用户组

userdel -r zookeeper
userdel -r ams
userdel -r ambari-qa
userdel -r hdfs
userdel -r yarn
userdel -r mapred
userdel -r activity_analyzer
groupdel hdfs
groupdel hadoop
groupdel zookeeper
groupdel yarn
groupdel mapred

以下是我的测试环境卸载操作

卸载安装的应用

rpm -e ambari-server-2.6.2.2-1.x86_64 ambari-metrics-grafana-2.6.2.2-1.x86_64 ambari-metrics-collector-2.6.2.2-1.x86_64
rpm -e ambari-metrics-monitor-2.6.2.2-1.x86_64 ambari-agent-2.6.2.2-1.x86_64 ambari-metrics-hadoop-sink-2.6.2.2-1.x86_64
rpm -e smartsense-hst-1.4.5.2.6.2.2-1.x86_64
rpm -e hadoop_2_6_5_0_292-hdfs-2.7.3.2.6.5.0-292.x86_64 hadoop_2_6_5_0_292-2.7.3.2.6.5.0-292.x86_64 hadoop_2_6_5_0_292-mapreduce-2.7.3.2.6.5.0-292.x86_64 hadoop_2_6_5_0_292-libhdfs-2.7.3.2.6.5.0-292.x86_64 hadoop_2_6_5_0_292-yarn-2.7.3.2.6.5.0-292.x86_64 hadoop_2_6_5_0_292-client-2.7.3.2.6.5.0-292.x86_64
rpm -e ranger_2_6_5_0_292-hdfs-plugin-0.7.0.2.6.5.0-292.x86_64  ranger_2_6_5_0_292-yarn-plugin-0.7.0.2.6.5.0-292.x86_64
rpm -e hdp-select-2.6.5.0-292.noarch
rpm -e spark_2_6_5_0_292-yarn-shuffle-1.6.3.2.6.5.0-292.noarch spark2_2_6_5_0_292-yarn-shuffle-2.3.0.2.6.5.0-292.noarch
rpm -e bigtop-jsvc-1.0.15-292.x86_64
rpm -e zookeeper_2_6_5_0_292 zookeeper_2_6_5_0_292-server

查看卸载结果

rpm -qa|egrep "ambari|hadoop|hdfs|yarn|ranger|hdp|spark|bigtop|smartsense|zookeeper|mapre"

删除安装文件、数据文件、日志文件及临时文件

rm -fr /var/log/hadoop-* /var/log/ambari-* /var/log/zookeeper/ 
rm -fr /var/run/hadoop-* /var/run/ambari-* /var/run/zookeeper/
rm -fr /var/lib/ambari-* /var/lib/zookeeper/ /var/lib/hadoop-*
rm -fr /var/log/smartsense-activity
rm -fr /var/run/smartsense-activity*
rm -fr /var/log/hst
rm -fr /usr/hdp/
rm -fr /etc/hst/
rm -fr /etc/zookeeper/
rm -fr /etc/hadoop/
rm -fr /etc/ambari-*
rm -fr /etc/ams-hbase/
rm -fr /etc/smartsense-activity/
rm -fr /usr/lib/ambari-*
rm -fr /usr/lib/flume
rm -fr /usr/lib/storm
rm -fr /tmp/hadoop-hdfs/
rm -fr /tmp/hadoop-yarn
rm -fr /data/disk{1,2,3,4,5,6}/hadoop/*
rm -fr /data/disk{1,2,3,4,5,6}/hbase
rm -fr /data/disk1/ambari-metrics-collector
rm -fr /data/disk1/logs/* 
rm -fr /data/disk1/pids/*

删除 Ambari 自动创建的用户及用户组

userdel -r zookeeper
userdel -r ams
userdel -r ambari-qa
userdel -r hdfs
userdel -r yarn
userdel -r mapred
userdel -r activity_analyzer
groupdel hdfs
groupdel hadoop
groupdel zookeeper
groupdel yarn
groupdel mapred

卸载完成

特别说明:如果 Ambari 集成了 Kerberos 做安全管理认证,卸载 Kerberos 的时候只卸载 krb5-server、krb5-workstation 两个应用就可以了。千万不要卸载 krb5-libs、krb5-devel,你会哭的;卸载了这两个依赖包之后,所有与网络相关的远程操作均不可用,如:ssh\scp\wget\curl\yum\rpm -ivh\rsync等,socket不受影响。只有重装 krb5-lib\krb5-devel,远程不可用的情况有两个方法安装:(1)挂载U盘,拷贝rpm安装包至服务器安装;(2)如果删除krb5-lib依赖之后你的控制台还没退出,恭喜你不用去机房,;自己写个socket服务,通过socket服务传输rpm安装包安装