大数据技术之Hbase 脚本(查看、启动、停止服务)


三台虚拟机:hadoop102、hadoop103、hadoop104
用户:alex
cat /etc/profile >> ~/.bashrc
将我们配置的profile变量追加到.bashrc中。

一、查看(xjps)

1、目录

cd ~/.ssh/
cd /usr/local/bin/

2、新建

sudo touch xjps

3、修改权限

sudo chmod 755 xjps
sudo chown -R alex:alex start-cluster.sh

4、内容

#!/bin/bash
user=`whoami`
for((host=102; host<=104; host++)); do
  echo -e "\n================   $user@hadoop$host    ==================="
  ssh $user@hadoop$host 'jps'
done

5、运行

在这里插入图片描述

二、启动服务(start-cluster.sh)

同上目录下新建start-cluster.sh,修改权限

内容

#!/bin/bash
user=`whoami`
echo "===============     正在启动Zookeeper......     ==============="
for((host=102; host<=104; host++)); do
    echo "--------------- hadoop$host Zookeeper...... ----------------"
    ssh $user@hadoop$host '/opt/module/zookeeper-3.4.10/bin/zkServer.sh start'
done

echo "================    正在启动HDFS                ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/start-dfs.sh'

echo "================    正在启动YARN                ==============="
ssh $user@hadoop103 '/opt/module/hadoop-2.7.2/sbin/start-yarn.sh'

echo "================    正在启动HBase               ==============="
ssh $user@hadoop102 '/opt/module/hbase-1.3.1/bin/start-hbase.sh'

三、停止服务(stop-cluster.sh)

内容

#!/bin/bash

user=`whoami`
echo "================     开始停止所有节点服务        ==============="
echo "================    正在停止HBase               ==============="
ssh $user@hadoop102 '/opt/module/hbase-1.3.1/bin/stop-hbase.sh'
echo "================    正在停止YARN                ==============="
ssh $user@hadoop103 '/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh'
echo "================    正在停止HDFS                ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh'

echo "===============     正在停止Zookeeper......     ==============="
for((host=102; host<=104; host++)); do
    echo "--------------- hadoop$host Zookeeper...... ----------------"
    ssh $user@hadoop$host '/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop'
done
©️2020 CSDN 皮肤主题: 1024 设计师:上身试试 返回首页