集群的启动
- 启动HDFS
- 启动namenode
$ /opt/modules/cdh/hadoop-2.5.0-cdh5.3.6/sbin/hadoop-daemon.sh start namenode
2.启动datanode
$ /opt/modules/cdh/hadoop-2.5.0-cdh5.3.6/sbin/hadoop-daemon.sh start datanode
- 启动secondarynamenode
$ /opt/modules/cdh/hadoop-2.5.0-cdh5.3.6/sbin/hadoop-daemon.sh start secondarynamenode
- 启动YARN
- 启动resourcemanager
$ /opt/modules/cdh/hadoop-2.5.0-cdh5.3.6/sbin/yarn-daemon.sh start resourcemanager
- 启动nodemanager
$ /opt/modules/cdh/hadoop-2.5.0-cdh5.3.6/sbin/yarn-daemon.sh start nodemanager
- 启动HistoryServer
$ /opt/modules/cdh/hadoop-2.5.0-cdh5.3.6/sbin/mr-jobhistory-daemon.sh start
一键启动/关闭脚本的编写
将脚本放在家目录上,
#!bin/bash
echo '====================正在开启集群服务===================='
echo '====================正在开启namenode节点===================='
ssh darrenzhang@hadoop-senior01.darrenzhang.com '/opt/modules/CDH/hadoop-2.5.0-cdh5.3.6/sbin/hadoop-daemon.sh start namenode'
echo '====================正在开启datanode节点===================='
for i in darrenzhang@hadoop-senior01.darrenzhang.com darrenzhang@hadoop-senior02.darrenzhang.com darrenzhang@hadoop-senior03.darrenzhang.com
do
ssh $i '/opt/modules/CDH/hadoop-2.5.0-cdh5.3.6/sbin/hadoop-daemon.sh start datanode'
done
echo '====================正在开启secondarynamenode节点================'
ssh darrenzhang@hadoop-senior01.darrenzhang.com '/opt/modules/CDH/hadoop-2.5.0-cdh5.3.6/sbin/hadoop-daemon.sh start secondarynamenode'
echo '====================正在开启resourcemanager节点================='
ssh darrenzhang@hadoop-senior02.darrenzhang.com '/opt/modules/CDH/hadoop-2.5.0-cdh5.3.6/sbin/yarn-daemon.sh start resourcemanager'
echo '====================正在开启nodemanager节点================='
for i in darrenzhang@hadoop-senior01.darrenzhang.com darrenzhang@hadoop-senior02.darrenzhang.com darrenzhang@hadoop-senior03.darrenzhang.com
do
ssh $i '/opt/modules/CDH/hadoop-2.5.0-cdh5.3.6/sbin/yarn-daemon.sh start nodemanager'
done
echo '====================正在开启HistoryServer服务==================='
ssh darrenzhang@hadoop-senior01.darrenzhang.com '/opt/modules/CDH/hadoop-2.5.0-cdh5.3.6/sbin/mr-jobhistory-daemon.sh start historyserver'
但是现在还不能直接执行这个脚本,因为执行这些脚本依赖环境变量。没有配置JAVA_HOME,这些脚本不能够执行。JAVA_HOME 变量去哪里配置?
- 有shell
粗略来讲,你手动使用CRT登录某个Linux系统时,是有shell的 - 无shell
当你使用ssh访问某个系统的时候,是无shell的
也就是说当你使用ssh访问某个系统的时候,是无法加载系统环境变量的,只能加载用户变量。在哪里配置用户变量呢?
在家目录下执行
ls -a
在.bashrc中配置用户JAVA_HOME环境变量
可以将系统的环境变量一起追加到.bashrc文件中,对集群中所有的机器执行以下操作:
cat /etc/profile >> ~/.bashrc