文章内容输出来源:拉勾教育Java高薪训练营;
服务器: 阿里云Centos7.4
hadoop版本: hadoop-2.7.2
下载地址:https://archive.apache.org/dist/hadoop/common/hadoop-2.7.2
节点 | teacher1 | teacher2 | teacher3 |
---|---|---|---|
HDFS | NameNode,DataNode | DataNode | DataNode,secondarynamenode |
YARN | NodeManager | ResourceManager,NodeManager | NodeManager |
vi /etc/hosts
39.107.96.104 teacher1
172.17.50.3 teacher2
172.17.50.4 teacher3
172.17.50.2 teacher1
39.107.72.162 teacher2
172.17.50.4 teacher3
172.17.50.2 teacher1
172.17.50.3 teacher2
39.107.67.194 teacher3
MHA集群的各节点直接需要基于ssh互相通信,先将主从的服务器之间免密ssh互通
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@teacher1
ssh-copy-id -i ~/.ssh/id_rsa.pub root@teacher2
ssh-copy-id -i ~/.ssh/id_rsa.pub root@teacher3
cd ~/software/
tar -zxvf hadoop-2.7.2.tar.gz -C /home/teacher/opt/module/
vi /etc/profile
export HADOOP_HOME=/home/teacher/opt/module/hadoop-2.7.2
export PATH=$PATH:$HADOOP_HOME/bin
source /etc/profile
hadoop version
1.配置hadoop-env.sh
vi hadoop-env.sh
//文件末尾
export JAVA_HOME=/opt/module/jdk1.8.0_231
2.核心配置文件:core-site.xml(hdfs的核心配置文件)
vi core-site.xml
<property>
<name>fs.defaultFSname>
<value>hdfs://teacher1:9000value>
property>
<property>
<name>hadoop.tmp.dirname>
<value>/home/teacher/opt/module/hadoop-2.7.2/data/tmpvalue>
property>
3.hdfs配置文件 hdfs-site.xml
vi hdfs-site.xml
<property>
<name>dfs.replicationname>
<value>3value>
property>
辅助namenode工作
<property>
<name>dfs.namenode.secondary.http-addressname>
<value>teacher3:50090value>
property>
<property>
<name>dfs.name.dirname>
<value>/home/teacher/data/hadoop/name/value>
property>
<property>
<name>dfs.data.dirname>
<value>/home/teacher/data/hadoop/data/value>
property>
4.yarn配置文件
vi yarn-env.sh
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
<property>
<name>yarn.resourcemanager.hostnamename>
<value>teacher2value>
property>
<property>
<name>yarn.nodemanager.resource.memory-mbname>
<value>3072value>
property>
5.mapreduce配置文件
cp mapred-site.xml.template mapred-site.xml
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
6.配置集群中从节点信息
vim slaves
teacher1
teacher2
teacher3
7.分发文件,将teacher1中hadoop目录下的软件拷贝到其他机器
scp -r hadoop-2.7.2 teacher3:/home/teacher/opt/module/
如果果集群是第一次启动,需要格式化NameNode
hadoop namenode -format
分别启动/停止hdfs组件
hadoop-daemon.sh start|stop namenode|datanode|secondarynamenod
启动/停止yarn.
yarn-daemon.sh start|stop resourcemanager|nodemanager
(1)整体启动/停止hdfs(在namenode节点启动)
start-dfs.sh
stop-dfs.sh
(2)整体启动/停止yarn (在resourcemanager节点启动)
start-yarn.sh
stop-yarn.sh
Web端查看SecondaryNameNode:
http://teacher3:50090/status.html
Yarn的web页面查看地址:http://teacher2:8088/
工作几年,一直都没有去体系化的学习,很多东西没有复杂的工作场景经验,去年综合几家机构,最后还是决定报了拉勾的高薪训练营,在这里也是实实在在的学习到了很多,学完掌握程度也比之前深了很多,而且还有定期的内推,多了更多的机会,真的对我有了很大的帮助提升。