shell脚本 启动关闭 hadoop2.6.5集群

启动集群的脚本

#/bin/bash
for node in node002 node003 node004
do
	ssh $node "source /etc/profile; zkServer.sh start;"
done

start-dfs.sh

ssh node003 "source /etc/profile; start-yarn.sh;"
ssh node004 "source /etc/profile; yarn-daemon.sh start resourcemanager;"

echo "--------------------node001----------------------"
jps

for node in node002 node003 node004
do
	echo "----------------$node------------------------"
	ssh $node "source /etc/profile; jps;"
done

启动集群时打印的日志信息:

[root@node001 ~]# ./st.sh
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
19/03/14 20:05:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [node001 node002]
node001: starting namenode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-namenode-node001.out
node002: starting namenode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-namenode-node002.out
node003: starting datanode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-datanode-node003.out
node004: starting datanode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-datanode-node004.out
node002: starting datanode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-datanode-node002.out
Starting journal nodes [node001 node002]
node001: starting journalnode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-journalnode-node001.out
node002: starting journalnode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-journalnode-node002.out
19/03/14 20:06:05 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting ZK Failover Controllers on NN hosts [node001 node002]
node001: starting zkfc, logging to /opt/hadoop-2.6.5/logs/hadoop-root-zkfc-node001.out
node002: starting zkfc, logging to /opt/hadoop-2.6.5/logs/hadoop-root-zkfc-node002.out
starting yarn daemons
starting resourcemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-resourcemanager-node003.out
node004: starting nodemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-nodemanager-node004.out
node003: starting nodemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-nodemanager-node003.out
node002: starting nodemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-nodemanager-node002.out
starting resourcemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-resourcemanager-node004.out
------------------------node001-----------------------------
1237 NameNode
1567 DFSZKFailoverController
1620 Jps
1422 JournalNode
---------------------node002-------------------------------
1546 NodeManager
1462 DFSZKFailoverController
1592 Jps
1163 QuorumPeerMain
1344 JournalNode
1212 NameNode
1273 DataNode
---------------------node003-------------------------------
1151 QuorumPeerMain
1474 Jps
1207 DataNode
1329 ResourceManager
1423 NodeManager
---------------------node004-------------------------------
1380 ResourceManager
1519 Jps
1316 NodeManager
1165 QuorumPeerMain
1215 DataNode
[root@node001 ~]# 

关闭集群的脚本:

#!/bin/bash

ssh node003 "source /etc/profile; stop-yarn.sh"
ssh node004 "source /etc/profile; yarn-daemon.sh stop resourcemanager"
stop-dfs.sh

for node in node002 node003 node004
do
  ssh $node "source /etc/profile; zkServer.sh stop"
done

echo "-------------------node1-------------------"
jps

for node in node002 node003 node004
do
  echo "-------------------$node-------------------"
  ssh $node "source /etc/profile; jps"
done

关闭集群时打印的日志信息:

[root@node001 ~]# ./stop-cluster.sh 
stopping yarn daemons
stopping resourcemanager
node003: stopping nodemanager
node002: stopping nodemanager
node004: stopping nodemanager
no proxyserver to stop
stopping resourcemanager
19/03/14 23:55:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Stopping namenodes on [node001 node002]
node001: stopping namenode
node002: stopping namenode
node004: stopping datanode
node002: stopping datanode
node003: stopping datanode
Stopping journal nodes [node001 node002]
node001: stopping journalnode
node002: stopping journalnode
19/03/14 23:55:41 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Stopping ZK Failover Controllers on NN hosts [node001 node002]
node001: stopping zkfc
node002: stopping zkfc
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
-------------------node1-------------------
2527 Jps
-------------------node002-------------------
2415 Jps
-------------------node003-------------------
3740 Jps
-------------------node004-------------------
1885 Jps

你可能感兴趣的:(大数据学习)