HBase启动脚本(start-hbase)

  1. cd /usr/local/bin
  2. sudo vi start-hbase

脚本内容如下:

  1. #!/bin/bash
  2. HBASE_HOME=/home/vagrant/modules/hbase-1.2.5
  3. echo "start hbase-------------------------------------------------"
  4. for i in bigdata-node1
  5. do
  6. ssh $i "source /etc/profile;${HBASE_HOME}/bin/start-hbase.sh"
  7. done
  8. sleep 10s
  9. jpsx
  10. exit 0

设置脚本执行权限:

  1. sudo chmod +x start-hbase
  2. sudo chown vagrant:vagrant start-hbase

HBase停止脚本(stop-hbase)

  1. cd /usr/local/bin
  2. sudo vi stop-hbase

脚本内容如下:

  1. #!/bin/bash
  2. HBASE_HOME=/home/vagrant/modules/hbase-1.2.5
  3. echo "stop hbase-------------------------------------------------"
  4. for i in bigdata-node1
  5. do
  6. ssh $i "source /etc/profile;${HBASE_HOME}/bin/stop-hbase.sh"
  7. done
  8. sleep 10s
  9. jpsx
  10. exit 0

设置脚本执行权限:

  1. sudo chmod +x stop-hbase
  2. sudo chown vagrant:vagrant stop-hbase

分发(选做):

  1. # 使用root账户分发至其他节点
  2. sudo scp -r /usr/local/bin/*-hbase root@bigdata-node2:/usr/local/bin/
  3. sudo scp -r /usr/local/bin/*-hbase root@bigdata-node3:/usr/local/bin/