CM Server启动脚本(start-scm-server)

  1. sudo su
  2. cd /bin
  3. vi start-scm-server

脚本内容如下:

  1. #!/bin/bash
  2. echo "start cloudera-scm-server-------------------------------------------------"
  3. for i in cfp-acrm-cdh-1
  4. do
  5. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-server start"
  6. done
  7. sleep 5s
  8. echo "cloudera-scm-server status------------------------------------------------"
  9. for i in cfp-acrm-cdh-1
  10. do
  11. echo ------------------- $i --------------
  12. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-server status"
  13. done
  14. exit 0

设置脚本执行权限:

  1. chmod +x start-scm-server

CM Server停止脚本(stop-scm-server)

  1. sudo su
  2. cd /bin
  3. vi stop-scm-server

脚本内容如下:

  1. #!/bin/bash
  2. echo "stop cloudera-scm-server-------------------------------------------------"
  3. for i in cfp-acrm-cdh-1
  4. do
  5. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-server stop"
  6. done
  7. sleep 5s
  8. echo "cloudera-scm-server status------------------------------------------------"
  9. for i in cfp-acrm-cdh-1
  10. do
  11. echo ------------------- $i --------------
  12. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-server status"
  13. done
  14. exit 0

设置脚本执行权限:

  1. chmod +x stop-scm-server

CM Server状态查看脚本(status-scm-server)

  1. sudo su
  2. cd /bin
  3. vi status-scm-server

脚本内容如下:

  1. #!/bin/bash
  2. echo "cloudera-scm-server status------------------------------------------------"
  3. for i in cfp-acrm-cdh-1
  4. do
  5. echo ------------------- $i --------------
  6. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-server status"
  7. done
  8. exit 0

设置脚本执行权限:

  1. chmod +x status-scm-server

分发(选做):

  1. # 使用root账户分发至其他节点
  2. scp -r /bin/*-scm-server root@cfp-acrm-cdh-2:/bin/
  3. scp -r /bin/*-scm-server root@cfp-acrm-cdh-3:/bin/

CM Agent启动脚本(start-scm-agent)

  1. sudo su
  2. cd /bin
  3. vi start-scm-agent

脚本内容如下:

  1. #!/bin/bash
  2. echo "start cloudera-scm-agent-------------------------------------------------"
  3. for i in cfp-acrm-cdh-1 cfp-acrm-cdh-2 cfp-acrm-cdh-3
  4. do
  5. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-agent start"
  6. done
  7. sleep 5s
  8. echo "cloudera-scm-agent status------------------------------------------------"
  9. for i in cfp-acrm-cdh-1 cfp-acrm-cdh-2 cfp-acrm-cdh-3
  10. do
  11. echo ------------------- $i --------------
  12. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-agent status"
  13. done
  14. exit 0

设置脚本执行权限:

  1. chmod +x start-scm-agent

CM Agent停止脚本(stop-scm-agent)

  1. sudo su
  2. cd /bin
  3. vi stop-scm-agent

脚本内容如下:

  1. #!/bin/bash
  2. echo "stop cloudera-scm-agent-------------------------------------------------"
  3. for i in cfp-acrm-cdh-1 cfp-acrm-cdh-2 cfp-acrm-cdh-3
  4. do
  5. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-agent stop"
  6. done
  7. sleep 5s
  8. echo "cloudera-scm-agent status------------------------------------------------"
  9. for i in cfp-acrm-cdh-1 cfp-acrm-cdh-2 cfp-acrm-cdh-3
  10. do
  11. echo ------------------- $i --------------
  12. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-agent status"
  13. done
  14. exit 0

设置脚本执行权限:

  1. chmod +x stop-scm-agent

CM Agent状态查看脚本(status-scm-agent)

  1. sudo su
  2. cd /bin
  3. vi status-scm-agent

脚本内容如下:

  1. #!/bin/bash
  2. echo "cloudera-scm-agent status------------------------------------------------"
  3. for i in cfp-acrm-cdh-1 cfp-acrm-cdh-2 cfp-acrm-cdh-3
  4. do
  5. echo ------------------- $i --------------
  6. ssh $i "source /etc/profile;/opt/cm/cm-5.8.3/etc/init.d/cloudera-scm-agent status"
  7. done
  8. exit 0

设置脚本执行权限:

  1. chmod +x status-scm-agent

分发(选做):

  1. # 使用root账户分发至其他节点
  2. scp -r /bin/*-scm-agent root@cfp-acrm-cdh-2:/bin/
  3. scp -r /bin/*-scm-agent root@cfp-acrm-cdh-3:/bin/