遠端啟動HADOOP+YARN叢集Shell指令碼

loveheping發表於2018-02-10
一、建立啟動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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章