Hadoop生态圈相关组件服务启动关闭和查看脚本
Posted EsmeZhao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hadoop生态圈相关组件服务启动关闭和查看脚本相关的知识,希望对你有一定的参考价值。
目录
1.查看进程
[root@master ~]# cd /usr/bin/
[root@master bin]# vi jps.sh
切换到/usr/bin目录下,创建脚本文件jps.sh,并输入以下内容:
#!/bin/bash
for i in master slave1 slave2
do
echo "**********$i**********"
ssh $i "/export/servers/jdk/bin/jps"
done
注意:master slave1 slave2 为主机名
/export/servers/jdk/bin/jps 为jps命令的绝对路径
[root@master bin]# chmod 777 jps.sh
[root@master bin]# ll jps.sh
-rwxrwxrwx. 1 root root 124 Dec 13 16:00 jps.sh
更改jps.sh脚本权限为777,并查看权限。
运行jps命令脚本结果如下。
[root@master bin]# jps.sh
**********master**********
3971 Jps
**********slave1**********
3264 Jps
**********slave2**********
3385 Jps
[root@master bin]#
2.hadoop集群
切换到/usr/bin目录下,创建脚本文件ha.sh,并输入以下内容:
#!/bin/bash
case $1 in
"start")
echo "**********启动集群**********"
ssh master "/export/servers/hadoop-2.6.4/sbin/start-dfs.sh"
ssh slave2 "/export/servers/hadoop-2.6.4/sbin/start-yarn.sh"
;;
"stop")
echo "**********关闭集群**********"
ssh slave2 "/export/servers/hadoop-2.6.4/sbin/stop-yarn.sh"
ssh master "/export/servers/hadoop-2.6.4/sbin/stop-dfs.sh"
;;
esac
注意:master slave1 slave2 为主机名
/export/servers/hadoop-2.6.4 为hadoop组件安装目录
更改ha.sh脚本权限为777,参考jps.sh脚本设置。
启动hadoop集群示例,并查看进程
[root@master bin]# ha.sh start
**********启动集群**********
Starting namenodes on [master]
master: starting namenode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-namenode-master.out
slave2: starting datanode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-datanode-slave2.out
slave1: starting datanode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-datanode-slave1.out
Starting secondary namenodes [slave1]
slave1: starting secondarynamenode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-secondarynamenode-slave1.out
starting yarn daemons
starting resourcemanager, logging to /export/servers/hadoop-2.6.4/logs/yarn-root-resourcemanager-slave2.out
slave1: starting nodemanager, logging to /export/servers/hadoop-2.6.4/logs/yarn-root-nodemanager-slave1.out
slave2: starting nodemanager, logging to /export/servers/hadoop-2.6.4/logs/yarn-root-nodemanager-slave2.out
[root@master bin]# jps.sh
**********master**********
4166 NameNode
4396 Jps
**********slave1**********
3383 DataNode
3564 NodeManager
3486 SecondaryNameNode
3694 Jps
**********slave2**********
4048 Jps
3505 DataNode
3731 NodeManager
3628 ResourceManager
[root@master bin]#
关闭hadoop集群示例,并查看进程
[root@master bin]# ha.sh stop
**********关闭集群**********
stopping yarn daemons
stopping resourcemanager
slave2: stopping nodemanager
slave1: stopping nodemanager
no proxyserver to stop
Stopping namenodes on [master]
master: stopping namenode
slave2: stopping datanode
slave1: stopping datanode
Stopping secondary namenodes [slave1]
slave1: stopping secondarynamenode
[root@master bin]# jps.sh
**********master**********
4710 Jps
**********slave1**********
3853 Jps
**********slave2**********
4278 Jps
[root@master bin]#
3.zookeeper
切换到/usr/bin目录下,创建脚本文件zk.sh,并输入以下内容:
#!/bin/bash
case $1 in
"start")
for i in master slave1 slave2
do
echo "**********$i**********"
ssh $i "/export/servers/zookeeper/bin/zkServer.sh start"
done
;;
"stop")
for i in master slave1 slave2
do
echo "**********$i**********"
ssh $i "/export/servers/zookeeper/bin/zkServer.sh stop"
done
;;
"status")
for i in master slave1 slave2
do
echo "**********$i**********"
ssh $i "/export/servers/zookeeper/bin/zkServer.sh status"
done
;;
注意:master slave1 slave2 为主机名
/export/servers/zookeeper为zookeeper组件安装目录
更改zk.sh脚本权限为777,参考jps.sh脚本设置。
启动、查看和关闭zookeeper服务示例。
[root@master bin]# zk.sh start
**********master**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
**********slave1**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
**********slave2**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@master bin]# zk.sh status
**********master**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
**********slave1**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader
**********slave2**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
[root@master bin]# zk.sh stop
**********master**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
**********slave1**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
**********slave2**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@master bin]#
4.hbase
切换到/usr/bin目录下,创建脚本文件hb.sh,并输入以下内容:
#!/bin/bash
case $1 in
"start")
echo "**********启动hbase**********"
ssh master "/export/servers/hbase/bin/start-hbase.sh"
;;
"stop")
echo "**********关闭hbase**********"
ssh master "/export/servers/hbase/bin/stop-hbase.sh"
;;
esac
注意:master 为主机名
/export/servers/hbase 为hbase组件安装目录
更改hb.sh脚本权限为777,参考jps.sh脚本设置。
启动和关闭hbase服务,并查看进程。(启动hbase服务之前,需启动hadoop集群和zookeeper)
[root@master bin]# ha.sh start
**********启动集群**********
Starting namenodes on [master]
master: starting namenode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-namenode-master.out
slave1: starting datanode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-datanode-slave1.out
slave2: starting datanode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-datanode-slave2.out
Starting secondary namenodes [slave1]
slave1: starting secondarynamenode, logging to /export/servers/hadoop-2.6.4/logs/hadoop-root-secondarynamenode-slave1.out
starting yarn daemons
starting resourcemanager, logging to /export/servers/hadoop-2.6.4/logs/yarn-root-resourcemanager-slave2.out
slave1: starting nodemanager, logging to /export/servers/hadoop-2.6.4/logs/yarn-root-nodemanager-slave1.out
slave2: starting nodemanager, logging to /export/servers/hadoop-2.6.4/logs/yarn-root-nodemanager-slave2.out
[root@master bin]# zk.sh start
**********master**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
**********slave1**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
**********slave2**********
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@master bin]# hb.sh start
**********启动hbase**********
starting master, logging to /export/servers/hbase/bin/../logs/hbase-root-master-master.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave1: starting regionserver, logging to /export/servers/hbase/bin/../logs/hbase-root-regionserver-slave1.out
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave2: starting regionserver, logging to /export/servers/hbase/bin/../logs/hbase-root-regionserver-slave2.out
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
master: starting regionserver, logging to /export/servers/hbase/bin/../logs/hbase-root-regionserver-master.out
master: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
master: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
master: master running as process 2198. Stop it first.
slave1: starting master, logging to /export/servers/hbase/bin/../logs/hbase-root-master-slave1.out
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave2: starting master, logging to /export/servers/hbase/bin/../logs/hbase-root-master-slave2.out
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
[root@master bin]# jps.sh
**********master**********
2049 QuorumPeerMain
2674 Jps
2198 HMaster
2311 HRegionServer
1789 NameNode
**********slave1**********
1856 QuorumPeerMain
2049 HMaster
1954 HRegionServer
1699 NodeManager
1621 SecondaryNameNode
1516 DataNode
2334 Jps
**********slave2**********
1649 ResourceManager
2097 QuorumPeerMain
1524 DataNode
1753 NodeManager
2618 Jps
2283 HMaster
2188 HRegionServer
[root@master bin]# hb.sh stop
**********关闭hbase**********
stopping hbase.................
[root@master bin]#
5.kafka
切换到/usr/bin目录下,创建脚本文件kk.sh,并输入以下内容:
#!/bin/bash
case $1 in
"start")
for i in master slave1 slave2
do
echo "**********$1 $i**********"
ssh $i "/export/servers/kafka/bin/kafka-server-start.sh -daemon /export/servers/kafka/config/server.properties"
done
;;
"stop")
for i in master slave1 slave2
do
echo "**********$1 $i**********"
ssh $i "/export/servers/kafka/bin/kafka-server-stop.sh"
done
;;
esac
注意:master slave1 slave2 为主机名
/export/servers/kafka 为kafka组件安装目录
更改kk.sh脚本权限为777,参考jps.sh脚本设置。
启动和关闭kafka服务,并查看进程。
[root@master bin]# kk.sh start
**********start master**********
**********start slave1**********
**********start slave2**********
[root@master bin]# jps.sh
**********master**********
3797 Kafka
3830 Jps
**********slave1**********
3206 Jps
3177 Kafka
**********slave2**********
3568 Jps
3539 Kafka
[root@master bin]# kk.sh stop
**********stop master**********
No kafka server to stop
**********stop slave1**********
No kafka server to stop
**********stop slave2**********
No kafka server to stop
[root@master bin]# jps.sh
**********master**********
3891 Jps
**********slave1**********
3268 Jps
**********slave2**********
3634 Jps
[root@master bin]#
以上是关于Hadoop生态圈相关组件服务启动关闭和查看脚本的主要内容,如果未能解决你的问题,请参考以下文章