#!/bin/bash
# Program:
# uninstall ambari automatic
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH #取得集群的所有主机名,这里需要注意:/etc/hosts配置的IP和主机名只能用制表符,cut默认分割符,其他情况参考注释行
#hostList=$(cat /etc/hosts | tail -n + | cut -d ' ' -f )
hostList=$(cat /etc/hosts | tail -n + | cut -f )
yumReposDir=/etc/yum.repos.d/
alterNativesDir=/etc/alternatives/
pingCount=
logPre=HDP read -p "Please input your master hostname: " master
master=${master:-"master"}
ssh $master "ambari-server stop"
#重置ambari数据库
ssh $master "ambari-server reset" for host in $hostList
do
echo $host
#检测主机的连通性
unPing=$(ping $host -c $pingCount | grep 'Unreachable' | wc -l)
if [ "$unPing" == "$pingCount" ]; then
echo -e "$logPre======>$host is Unreachable,please check '/etc/hosts' file"
continue
fi echo "$logPre======>$host deleting... \n"
#.)删除hdp.repo、HDP.repo、HDP-UTILS.repo和ambari.repo
ssh $host "cd $yumReposDir"
ssh $host "rm -rf $yumReposDir/hdp.repo"
ssh $host "rm -rf $yumReposDir/HDP*"
ssh $host "rm -rf $yumReposDir/ambari.repo" # 删除相关用户
ssh $host "python /usr/lib/ambari-agent/lib/ambari_agent/HostCleanup.py --silent" # 删除HDP相关的安装包
hdppackagelist=$(yum list installed | grep HDP | cut -d ' ' -f )
for package in $hdppackagelist
do
echo "uninstalling $package"
ssh $host "yum remove -y $package"
done
# 删除ambari相关安装包
ambaripackagelist=$(yum list installed | grep ambari | cut -d ' ' -f )
for package in $ambaripackagelist
do
echo "uninstalling $package"
ssh $host "yum remove -y $package"
done # 删除快捷方式
ssh $host "cd $alterNativesDir"
ssh $host "rm -rf hadoop-etc"
ssh $host "rm -rf zookeeper-conf"
ssh $host "rm -rf hbase-conf"
ssh $host "rm -rf hadoop-log"
ssh $host "rm -rf hadoop-lib"
ssh $host "rm -rf hadoop-default"
ssh $host "rm -rf oozie-conf"
ssh $host "rm -rf hcatalog-conf"
ssh $host "rm -rf hive-conf"
ssh $host "rm -rf hadoop-man"
ssh $host "rm -rf sqoop-conf"
ssh $host "rm -rf hadoop-confone" # 删除日志文件
ssh $host "rm -rf /var/log/ambari*"
ssh $host "rm -rf /var/log/hadoop*"
ssh $host "rm -rf /var/log/hbase"
ssh $host "rm -rf /var/log/hive"
ssh $host "rm -rf /var/log/nagios"
ssh $host "rm -rf /var/log/oozie"
ssh $host "rm -rf /var/log/zookeeper"
ssh $host "rm -rf /var/log/falcon"
ssh $host "rm -rf /var/log/flume"
ssh $host "rm -rf /var/log/hive*"
ssh $host "rm -rf /var/log/knox"
ssh $host "rm -rf /var/log/solr"
ssh $host "rm -rf /var/log/hst" # 删除hadoop文件夹,包括HDFS数据
ssh $host "rm -rf /hadoop"
ssh $host "rm -rf /hdfs/hadoop"
ssh $host "rm -rf /hdfs/lost+found"
ssh $host "rm -rf /hdfs/var"
ssh $host "rm -rf /local/opt/hadoop"
ssh $host "rm -rf /tmp/hadoop"
ssh $host "rm -rf /usr/bin/hadoop"
ssh $host "rm -rf /usr/hdp"
ssh $host "rm -rf /var/hadoop" # 删除所有节点上的配置文件夹
ssh $host "rm -rf /etc/ambari-agent"
ssh $host "rm -rf /etc/ambari-metrics-grafana"
ssh $host "rm -rf /etc/ambari-server"
ssh $host "rm -rf /etc/ams-hbase"
ssh $host "rm -rf /etc/falcon"
ssh $host "rm -rf /etc/flume"
ssh $host "rm -rf /etc/hadoop"
ssh $host "rm -rf /etc/hadoop-httpfs"
ssh $host "rm -rf /etc/hbase"
ssh $host "rm -rf /etc/hive"
ssh $host "rm -rf /etc/hive-hcatalog"
ssh $host "rm -rf /etc/hive-webhcat"
ssh $host "rm -rf /etc/hive2"
ssh $host "rm -rf /etc/hst"
ssh $host "rm -rf /etc/knox"
ssh $host "rm -rf /etc/livy"
ssh $host "rm -rf /etc/mahout"
ssh $host "rm -rf /etc/oozie"
ssh $host "rm -rf /etc/phoenix"
ssh $host "rm -rf /etc/pig"
ssh $host "rm -rf /etc/ranger-admin"
ssh $host "rm -rf /etc/ranger-usersync"
ssh $host "rm -rf /etc/spark2"
ssh $host "rm -rf /etc/tez"
ssh $host "rm -rf /etc/tez_hive2"
ssh $host "rm -rf /etc/zookeeper" # 删除所有节点上的PID
ssh $host "rm -rf /var/run/ambari-agent"
ssh $host "rm -rf /var/run/ambari-metrics-grafana"
ssh $host "rm -rf /var/run/ambari-server"
ssh $host "rm -rf /var/run/falcon"
ssh $host "rm -rf /var/run/flume"
ssh $host "rm -rf /var/run/hadoop"
ssh $host "rm -rf /var/run/hadoop-mapreduce"
ssh $host "rm -rf /var/run/hadoop-yarn"
ssh $host "rm -rf /var/run/hbase"
ssh $host "rm -rf /var/run/hive"
ssh $host "rm -rf /var/run/hive-hcatalog"
ssh $host "rm -rf /var/run/hive2"
ssh $host "rm -rf /var/run/hst"
ssh $host "rm -rf /var/run/knox"
ssh $host "rm -rf /var/run/oozie"
ssh $host "rm -rf /var/run/webhcat"
ssh $host "rm -rf /var/run/zookeeper" # 删除所有节点上的库文件
ssh $host "rm -rf /usr/lib/ambari-agent"
ssh $host "rm -rf /usr/lib/ambari-infra-solr-client"
ssh $host "rm -rf /usr/lib/ambari-metrics-hadoop-sink"
ssh $host "rm -rf /usr/lib/ambari-metrics-kafka-sink"
ssh $host "rm -rf /usr/lib/ambari-server-backups"
ssh $host "rm -rf /var/lib/ambari-agent"
ssh $host "rm -rf /var/lib/ambari-metrics-grafana"
ssh $host "rm -rf /var/lib/ambari-server"
ssh $host "rm -rf /usr/lib/ams-hbase"
ssh $host "rm -rf /var/lib/flume"
ssh $host "rm -rf /var/lib/hadoop-hdfs"
ssh $host "rm -rf /var/lib/hadoop-mapreduce"
ssh $host "rm -rf /var/lib/hadoop-yarn"
ssh $host "rm -rf /var/lib/hive"
ssh $host "rm -rf /var/lib/hive2"
ssh $host "rm -rf /var/lib/knox"
ssh $host "rm -rf /var/lib/smartsense"
ssh $host "rm -rf /var/lib/storm"
ssh $host "rm -rf /usr/lib/hadoop"
ssh $host "rm -rf /usr/lib/hbase"
ssh $host "rm -rf /usr/lib/hcatalog"
ssh $host "rm -rf /usr/lib/oozie"
ssh $host "rm -rf /usr/lib/zookeeper"
ssh $host "rm -rf /var/lib/ganglia"
ssh $host "rm -rf /var/lib/oozie"
ssh $host "rm -rf /var/lib/zookeeper"
ssh $host "rm -rf /var/tmp/oozie"
ssh $host "rm -rf /var/nagios" # 删除临时文件
echo "删除临时文件..."
ssh $host "rm -rf /tmp/*" # 删除所有节点上的符号链接
ssh $host "rm -rf accumulo"
ssh $host "rm -rf atlas-start"
ssh $host "rm -rf atlas-stop"
ssh $host "rm -rf beeline"
ssh $host "rm -rf falcon"
ssh $host "rm -rf flume-ng"
ssh $host "rm -rf hbase"
ssh $host "rm -rf hcat"
ssh $host "rm -rf hdfs"
ssh $host "rm -rf hive"
ssh $host "rm -rf hiveserver2"
ssh $host "rm -rf kafka"
ssh $host "rm -rf mahout"
ssh $host "rm -rf /usr/bin/mapred"
ssh $host "rm -rf /usr/bin/oozie"
ssh $host "rm -rf /usr/bin/oozied.sh"
ssh $host "rm -rf /usr/bin/phoenix-psql"
ssh $host "rm -rf /usr/bin/phoenix-queryserver"
ssh $host "rm -rf /usr/bin/phoenix-sqlline"
ssh $host "rm -rf /usr/bin/phoenix-sqlline-thin"
ssh $host "rm -rf /usr/bin/pig"
ssh $host "rm -rf /usr/bin/python-wrap"
ssh $host "rm -rf /usr/bin/ranger-admin"
ssh $host "rm -rf /usr/bin/ranger-admin-start"
ssh $host "rm -rf /usr/bin/ranger-admin-stop"
ssh $host "rm -rf /usr/bin/ranger-kms"
ssh $host "rm -rf /usr/bin/ranger-usersync"
ssh $host "rm -rf /usr/bin/ranger-usersync-start"
ssh $host "rm -rf /usr/bin/ranger-usersync-stop"
ssh $host "rm -rf /usr/bin/slider"
ssh $host "rm -rf /usr/bin/sqoop"
ssh $host "rm -rf /usr/bin/sqoop-codegen"
ssh $host "rm -rf /usr/bin/sqoop-create-hive-table"
ssh $host "rm -rf /usr/bin/sqoop-eval"
ssh $host "rm -rf /usr/bin/sqoop-export"
ssh $host "rm -rf /usr/bin/sqoop-help"
ssh $host "rm -rf /usr/bin/sqoop-import"
ssh $host "rm -rf /usr/bin/sqoop-import-all-tables"
ssh $host "rm -rf /usr/bin/sqoop-job"
ssh $host "rm -rf /usr/bin/sqoop-list-databases"
ssh $host "rm -rf /usr/bin/sqoop-list-tables"
ssh $host "rm -rf /usr/bin/sqoop-merge"
ssh $host "rm -rf /usr/bin/sqoop-metastore"
ssh $host "rm -rf /usr/bin/sqoop-version"
ssh $host "rm -rf /usr/bin/storm"
ssh $host "rm -rf /usr/bin/storm-slider"
ssh $host "rm -rf /usr/bin/worker-lanucher"
ssh $host "rm -rf /usr/bin/yarn"
ssh $host "rm -rf /usr/bin/zookeeper-client"
ssh $host "rm -rf /usr/bin/zookeeper-server"
ssh $host "rm -rf /usr/bin/zookeeper-server-cleanup" # 删除数据库
ssh $host "yum remove -y postgresql"
ssh $host "rm -rf /var/lib/pgsql"
# 删除ambari相关包
# ssh $host "yum remove -y ambari-*"
# ssh $host "rm -rf /var/lib/ambari*" echo "$logPre======>$host is done! \n"
done

ambari 卸载脚本的更多相关文章

  1. virtualbox和vagrant卸载脚本在macbook

    virtualbox和vagrant在macbook版本的安装文件内,都有一个卸载脚本uninstall.tool vagrant2.1.5卸载脚本: #!/usr/bin/env bash #--- ...

  2. ambari删除脚本

    #.删除hdp.repo和hdp-util.repo cd /etc/yum.repos.d/ rm -rf hdp* rm -rf HDP* #rm -rf ambari* #.删除安装包 #用yu ...

  3. 【转载】linux-查询rpm包相关安装、卸载脚本

        测试过程中,有时要测试开发自己打的rpm包,为了确认打包正确,需要查询rpm包相关安装.卸载脚本,可以使用命令:   [root@6 /]#rpm -q --scripts mysql pos ...

  4. ambari卸载集群

    #1.删除hdp.repo和hdp-util.repo cd /etc/yum.repos.d/ rm -rf hdp* rm -rf HDP* #rm -rf ambari* #2.删除安装包 #用 ...

  5. erlang mac os 10.9 卸载脚本

    #!/bin/bash if [ "$(id -u)" != "0" ]; then echo "Insufficient permissions. ...

  6. cloudera manager 5.3完整卸载脚本

    service cloudera-scm-agent stop service cloudera-scm-agent stop umount /var/run/cloudera-scm-agent/p ...

  7. Ubuntu 软件卸载脚本(卸载软件 + 移除配置文件 + 移除依赖项)

    #!/bin/bash function z-apt-uninstall() { if [ ! $1 ] then echo "z-apt-uninstall error: software ...

  8. windows 服务安装脚本拾遗

    转自:http://blog.csdn.net/susubuhui/article/details/7881096 1.安装脚本 echo 请按任意键开始安装客户管理平台的后台服务 echo. pau ...

  9. Linux环境下JDK/Eclipse一键安装脚本

    -------------------------------------------------------------------- author:jiangxin Email:jiangxinn ...

随机推荐

  1. css3 奇技淫巧 - 如何给小汽车换个背景色谈起

    css3 的魅力,不容小觑.曾经被她折服,再度回首,依旧拜倒在她的石榴裙下.相信在未来,她仍然魅力依旧. 站在巨人的肩上学习,不断提升自身实力. 用 CSS 和颜色选择工具更改图片中的颜色,即如何给小 ...

  2. SQL三表左关联查询

    今天在开发的时候遇到了一个需求就是三遍关联查询,表A包含有表B和表C的uid,然后使用left join左关联查询: SELECT c.`uid`, `fromuseruid`, `touseruid ...

  3. 剑指offer例题分享--6

    前言:继续整理例题,快速做完这部分,然后继续用C++去刷数据结构和算法的题. 面试题28: 代码如下: #include<iostream> #include<stdio.h> ...

  4. iOS逆向开发(3):锁定APP的目标类与函数 | reveal | lldb | debugserver | 远程调试

    之前介绍了怎么获取APP的所有类的结构信息,这个有什么用呢?用处大了,比如以这一步为基础,下一步通过注入来做更多研究工作. 注入的最小单位是函数,实际上,编译执行的程序在编译后,类就不复存在了,留下来 ...

  5. Oracle性能优化之查询语句通用原则

    作者早期文章 Oracle优化 索引是表的一个概念部分 , 用来提高检索数据的效率, ORACLE 使用了一个复杂的自平衡 B-tree 结构 . 通常 , 通过索引查询数据比全表扫描要快 . 当 O ...

  6. SpringCloud2.0入门4-springboot-admin监控

    前言 上一节为springboot项目添加springboot-admin监控 学习了基于springboot1.5自己注册到admin的方法.接下来学习结合Eureka使用以及2.0的改变. 1.5 ...

  7. 教你如何在React及Redux项目中进行服务端渲染

    服务端渲染(SSR: Server Side Rendering)在React项目中有着广泛的应用场景 基于React虚拟DOM的特性,在浏览器端和服务端我们可以实现同构(可以使用同一份代码来实现多端 ...

  8. 第8章 CentOS包管理详解

    8.1 Linux上构建C程序的过程 在说明包相关的内容之前,我觉得有必要说一下在Linux上构建一个C程序的过程.我个人并没有学习过C,内容总结自网上,所以可能显得很小白,而且也并非一定正确,只希望 ...

  9. 前端(五)之display 总结与浮动

    前端之浮动布局.清浮动 display 总结 <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...

  10. CoreJava(一)—— Java迭代语句

    本文介绍一些关于迭代语句的一些相关技巧以及Java8中的迭代语句的使用方法. public class TestBreak { public static void main(String[] arg ...