远程启动HADOOP+YARN集群Shell脚本

一、创建启动HADOOP+YARN脚本
1、创建脚本
vi start-hadoop.sh 
点击( 此处 )折叠或打开
  1. #!/bin/bash

  2. #start zookeeper
  3. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/zookeeper-3.4.6/bin \; ./zkServer.sh start
  4. /bin/sleep 5
  5. ssh hadoop002 'cd ~/; source .bash_profile;' cd /app/zookeeper-3.4.6/bin \; ./zkServer.sh start
  6. /bin/sleep 5
  7. ssh hadoop003 'cd ~/; source .bash_profile;' cd /app/zookeeper-3.4.6/bin \; ./zkServer.sh start
  8. /bin/sleep 5

  9. #start journalnode
  10. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./hadoop-daemon.sh start journalnode
  11. /bin/sleep 5
  12. ssh hadoop002 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./hadoop-daemon.sh start journalnode
  13. /bin/sleep 5
  14. ssh hadoop003 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./hadoop-daemon.sh start journalnode
  15. /bin/sleep 5

  16. #start hadoop hdfs cluster
  17. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./start-dfs.sh
  18. /bin/sleep 5

  19. #start yarn
  20. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./start-yarn.sh
  21. /bin/sleep 5
  22. ssh hadoop002 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./start-yarn.sh
  23. /bin/sleep 5
2、脚本赋予权限
    chmod 775 start-hadoop.sh

3、执行脚本
    cd /app
    ./start-hadoop.sh
二、创建停止HADOOP+YARN脚本
1、创建脚本
vi stop-hadoop.sh 
点击( 此处 )折叠或打开
  1. #!/bin/bash

  2. #stop yarn
  3. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./stop-yarn.sh
  4. /bin/sleep 5
  5. ssh hadoop002 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./stop-yarn.sh
  6. /bin/sleep 5

  7. #stop hadoop hdfs cluster
  8. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/hadoop-2.6.0-cdh5.7.0/sbin \; ./stop-dfs.sh
  9. /bin/sleep 5

  10. #stop zookeeper
  11. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/zookeeper-3.4.6/bin \; ./zkServer.sh stop
  12. /bin/sleep 5
  13. ssh hadoop002 'cd ~/; source .bash_profile;' cd /app/zookeeper-3.4.6/bin \; ./zkServer.sh stop
  14. /bin/sleep 5
  15. ssh hadoop003 'cd ~/; source .bash_profile;' cd /app/zookeeper-3.4.6/bin \; ./zkServer.sh stop
  16. /bin/sleep 5
2、脚本赋予权限
    chmod 775 stop-hadoop.sh

3、执行脚本
    cd /app
    ./stop-hadoop.sh

三、创建查询HADOOP+YARN状态脚本
1、创建脚本
vi queryJSP.sh
点击( 此处 )折叠或打开
  1. #!/bin/bash

  2. echo "<-------------hadoop1(192.168.137.132)------------>jps"
  3. ssh hadoop001 'cd ~/; source .bash_profile;' cd /app/jdk1.8.0_151/bin \; jps|sort|grep -v Jps

  4. echo "<-------------hadoop2(192.168.137.133)------------>jps"
  5. ssh hadoop002 'cd ~/; source .bash_profile;' cd /app/jdk1.8.0_151/bin \; jps|sort|grep -v Jps

  6. echo "<-------------hadoop3(192.168.137.134)------------>jps"
  7. ssh hadoop003 'cd ~/; source .bash_profile;' cd /app/jdk1.8.0_151/bin \; jps|sort|grep -v Jps
2、脚本赋予权限
    chmod 775 queryJSP.sh

3、执行脚本
    cd /app
    ./queryJSP.sh

---完---

【来自@若泽大数据】

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31511218/viewspace-2151007/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31511218/viewspace-2151007/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值