IT星球论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 562|回复: 1

Ambari自动化卸载shell脚本

[复制链接]

1997

主题

1

好友

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

优秀会员 助人为乐 辛勤工作 技术精英 多才多艺 优秀班竹 灌水天才 星球管理 宣传大使 灌水之王 财富勋章 版主勋章 动漫勋章 勤奋会员 论坛精英 PS高手 心 8 闪游皮肤 双鱼座 8★8➹ 志愿者 乖

发表于 2015-11-30 18:19:08 |显示全部楼层
Ambari自动化卸载shell脚本
  1. #!/bin/bash
  2. # Program:
  3. #    uninstall ambari automatic
  4. # History:
  5. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  6. export PATH

  7. #取得集群的所有主机名,这里需要注意:/etc/hosts配置的IP和主机名只能用一个空格分割
  8. hostList=$(cat /etc/hosts | tail -n +3 | cut -d ' ' -f 2)
  9. yumReposDir=/etc/yum.repos.d/
  10. alterNativesDir=/etc/alternatives/
  11. pingCount=5
  12. logPre=TDP

  13. read -p "Please input your master hostname: " master
  14. master=${master:-"master"}
  15. ssh $master "ambari-server stop"
  16. #重置ambari数据库
  17. ssh $master "ambari-server reset"

  18. for host in $hostList
  19. do
  20.     #echo $host
  21.     #检测主机的连通性
  22.     unPing=$(ping $host -c $pingCount | grep 'Unreachable' | wc -l)
  23.     if [ "$unPing" == "$pingCount" ]; then
  24.         echo -e "$logPre======>$host is Unreachable,please check '/etc/hosts' file"
  25.         continue
  26.     fi

  27.     echo "$logPre======>$host deleting... \n"
  28.     #1.)删除hdp.repo、HDP.repo、HDP-UTILS.repo和ambari.repo
  29.     ssh $host "cd $yumReposDir"
  30.     ssh $host "rm -rf $yumReposDir/hdp.repo"
  31.     ssh $host "rm -rf $yumReposDir/HDP*"
  32.     ssh $host "rm -rf $yumReposDir/ambari.repo"
  33.    
  34.     #删除HDP相关的安装包
  35.     ssh $host "yum remove -y  sqoop.noarch"
  36.     ssh $host "yum remove -y  lzo-devel.x86_64"
  37.     ssh $host "yum remove -y  hadoop-libhdfs.x86_64"
  38.     ssh $host "yum remove -y  rrdtool.x86_64"
  39.     ssh $host "yum remove -y  HBase.noarch"
  40.     ssh $host "yum remove -y  pig.noarch"
  41.     ssh $host "yum remove -y  lzo.x86_64"
  42.     ssh $host "yum remove -y  ambari-log4j.noarch"
  43.     ssh $host "yum remove -y  oozie.noarch"
  44.     ssh $host "yum remove -y  oozie-client.noarch"
  45.     ssh $host "yum remove -y  gweb.noarch"
  46.     ssh $host "yum remove -y  snappy-devel.x86_64"
  47.     ssh $host "yum remove -y  hcatalog.noarch"
  48.     ssh $host "yum remove -y  Python-rrdtool.x86_64"
  49.     ssh $host "yum remove -y  nagiOS.x86_64"
  50.     ssh $host "yum remove -y  webhcat-tar-pig.noarch"
  51.     ssh $host "yum remove -y  snappy.x86_64"
  52.     ssh $host "yum remove -y  libconfuse.x86_64"
  53.     ssh $host "yum remove -y  webhcat-tar-hive.noarch"
  54.     ssh $host "yum remove -y  ganglia-gmetad.x86_64"
  55.     ssh $host "yum remove -y  extjs.noarch"
  56.     ssh $host "yum remove -y  hive.noarch"
  57.     ssh $host "yum remove -y  hadoop-lzo.x86_64"
  58.     ssh $host "yum remove -y  hadoop-lzo-native.x86_64"
  59.     ssh $host "yum remove -y  hadoop-native.x86_64"
  60.     ssh $host "yum remove -y  hadoop-pipes.x86_64"
  61.     ssh $host "yum remove -y  nagios-plugins.x86_64"
  62.     ssh $host "yum remove -y  hadoop.x86_64"
  63.     ssh $host "yum remove -y  zookeeper.noarch"   
  64.     ssh $host "yum remove -y  hadoop-sbin.x86_64"
  65.     ssh $host "yum remove -y  ganglia-gmond.x86_64"
  66.     ssh $host "yum remove -y  libganglia.x86_64"
  67.     ssh $host "yum remove -y  perl-rrdtool.x86_64"
  68.     ssh $host "yum remove -y  epel-release.noarch"
  69.     ssh $host "yum remove -y  compat-readline5*"
  70.     ssh $host "yum remove -y  fping.x86_64"
  71.     ssh $host "yum remove -y  perl-Crypt-DES.x86_64"
  72.     ssh $host "yum remove -y  exim.x86_64"
  73.     ssh $host "yum remove -y ganglia-web.noarch"
  74.     ssh $host "yum remove -y perl-Digest-HMAC.noarch"
  75.     ssh $host "yum remove -y perl-Digest-SHA1.x86_64"
  76.     ssh $host "yum remove -y bigtop-jsvc.x86_64"
  77.    
  78.     #删除快捷方式
  79.     ssh $host "cd $alterNativesDir"
  80.     ssh $host "rm -rf hadoop-etc"
  81.     ssh $host "rm -rf zookeeper-conf"
  82.     ssh $host "rm -rf hbase-conf"
  83.     ssh $host "rm -rf hadoop-log"
  84.     ssh $host "rm -rf hadoop-lib"
  85.     ssh $host "rm -rf hadoop-default"
  86.     ssh $host "rm -rf oozie-conf"
  87.     ssh $host "rm -rf hcatalog-conf"
  88.     ssh $host "rm -rf hive-conf"
  89.     ssh $host "rm -rf hadoop-man"
  90.     ssh $host "rm -rf sqoop-conf"
  91.     ssh $host "rm -rf hadoop-confone"

  92.     #删除用户
  93.     ssh $host "userdel -rf nagios"
  94.     ssh $host "userdel -rf hive"
  95.     ssh $host "userdel -rf ambari-qa"
  96.     ssh $host "userdel -rf hbase"
  97.     ssh $host "userdel -rf oozie"
  98.     ssh $host "userdel -rf hcat"
  99.     ssh $host "userdel -rf mapred"
  100.     ssh $host "userdel -rf hdfs"
  101.     ssh $host "userdel -rf rrdcached"
  102.     ssh $host "userdel -rf zookeeper"
  103.     ssh $host "userdel -rf sqoop"
  104.     ssh $host "userdel -rf puppet"
  105.     ssh $host "userdel -rf flume"
  106.     ssh $host "userdel -rf tez"
  107.     ssh $host "userdel -rf yarn"

  108.     #删除文件夹
  109.     ssh $host "rm -rf /hadoop"
  110.     ssh $host "rm -rf /etc/hadoop"
  111.     ssh $host "rm -rf /etc/hbase"
  112.     ssh $host "rm -rf /etc/hcatalog"
  113.     ssh $host "rm -rf /etc/hive"
  114.     ssh $host "rm -rf /etc/ganglia"
  115.     ssh $host "rm -rf /etc/nagios"
  116.     ssh $host "rm -rf /etc/oozie"
  117.     ssh $host "rm -rf /etc/sqoop"
  118.     ssh $host "rm -rf /etc/zookeeper"
  119.     ssh $host "rm -rf /var/run/hadoop"
  120.     ssh $host "rm -rf /var/run/hbase"
  121.     ssh $host "rm -rf /var/run/hive"
  122.     ssh $host "rm -rf /var/run/ganglia"
  123.     ssh $host "rm -rf /var/run/nagios"
  124.     ssh $host "rm -rf /var/run/oozie"
  125.     ssh $host "rm -rf /var/run/zookeeper"
  126.     ssh $host "rm -rf /var/log/hadoop"
  127.     ssh $host "rm -rf /var/log/hbase"
  128.     ssh $host "rm -rf /var/log/hive"
  129.     ssh $host "rm -rf /var/log/nagios"
  130.     ssh $host "rm -rf /var/log/oozie"
  131.     ssh $host "rm -rf /var/log/zookeeper"
  132.     ssh $host "rm -rf /usr/lib/hadoop"
  133.     ssh $host "rm -rf /usr/lib/hbase"
  134.     ssh $host "rm -rf /usr/lib/hcatalog"
  135.     ssh $host "rm -rf /usr/lib/hive"
  136.     ssh $host "rm -rf /usr/lib/oozie"
  137.     ssh $host "rm -rf /usr/lib/sqoop"
  138.     ssh $host "rm -rf /usr/lib/zookeeper"
  139.     ssh $host "rm -rf /var/lib/hive"
  140.     ssh $host "rm -rf /var/lib/ganglia"
  141.     ssh $host "rm -rf /var/lib/oozie"
  142.     ssh $host "rm -rf /var/lib/zookeeper"
  143.     ssh $host "rm -rf /var/tmp/oozie"
  144.     ssh $host "rm -rf /tmp/hive"
  145.     ssh $host "rm -rf /tmp/nagios"
  146.     ssh $host "rm -rf /tmp/ambari-qa"
  147.     ssh $host "rm -rf /tmp/sqoop-ambari-qa"
  148.     ssh $host "rm -rf /var/nagios"
  149.     ssh $host "rm -rf /hadoop/oozie"
  150.     ssh $host "rm -rf /hadoop/zookeeper"
  151.     ssh $host "rm -rf /hadoop/mapred"
  152.     ssh $host "rm -rf /hadoop/hdfs"
  153.     ssh $host "rm -rf /tmp/hadoop-hive"
  154.     ssh $host "rm -rf /tmp/hadoop-nagios"
  155.     ssh $host "rm -rf /tmp/hadoop-hcat"
  156.     ssh $host "rm -rf /tmp/hadoop-ambari-qa"
  157.     ssh $host "rm -rf /tmp/hsperfdata_hbase"
  158.     ssh $host "rm -rf /tmp/hsperfdata_hive"
  159.     ssh $host "rm -rf /tmp/hsperfdata_nagios"
  160.     ssh $host "rm -rf /tmp/hsperfdata_oozie"
  161.     ssh $host "rm -rf /tmp/hsperfdata_zookeeper"
  162.     ssh $host "rm -rf /tmp/hsperfdata_mapred"
  163.     ssh $host "rm -rf /tmp/hsperfdata_hdfs"
  164.     ssh $host "rm -rf /tmp/hsperfdata_hcat"
  165.     ssh $host "rm -rf /tmp/hsperfdata_ambari-qa"

  166.     #删除ambari相关包
  167.     ssh $host "yum remove -y ambari-*"
  168.     ssh $host "yum remove -y PostgreSQL"
  169.     ssh $host "rm -rf /var/lib/ambari*"
  170.     ssh $host "rm -rf /var/log/ambari*"
  171.     ssh $host "rm -rf /etc/ambari*"

  172.     echo "$logPre======>$host is done! \n"
  173. done
复制代码
Ambari自动化卸载shell脚本
该会员没有填写今日想说内容.

0

主题

0

好友

14

积分

IT工程师

Rank: 1

升级  28%

发表于 2016-2-15 14:24:42 |显示全部楼层
Ambari自动化卸载shell脚本???
Linux相关的学习网站
http://www.unix-cd.com/
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

回顶部