ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 远程启动HADOOP+YARN集群Shell脚本

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

原创 Linux操作系统 作者:loveheping 时间:2018-02-10 14:44:42 0 删除 编辑
一、创建启动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博客 ” ,链接:https://blog.itpub.net/31511218/viewspace-2151007/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2017-12-13

  • 博文量
    41
  • 访问量
    80859