Hadoop 2.7.2版本完全分布式搭建

主机配置

主机 IP 角色
hadoop01 10.1.24.1 namenode,datanode,nodeManager
hadoop02 10.1.24.2 namenode2,datanode,nodeManager
hadoop03 10.1.24.3 resourceManager,datanode,nodeManager,历史服务器

环境配置

安装JDK

这里安装的是1.8.0_211版本。

配置三台主机免密

这里三台都要配置,自己到自己的免密也要配置。

安装hadoop

下载安装包

mkdir /home/hadoop
cd /home/hadoop
wget http://archive.apache.org/dist/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
tar -zxvf hadoop-2.7.2.tar.gz
cd hadoop-2.7.2

设置环境变量

vim /etc/profile
# 在最后面增加如下两行代码
export HADOOP_HOME=/home/hadoop/hadoop-2.7.2
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# 保存退出
source /etc/profile

修改运行文件的JAVA_HOME

每个节点都需要修改
vim etc/hadopp/hadoop-env.sh
然后修改export JAVA_HOME=${JAVA_HOME}export JAVA_HOME=/home/java/jdk1.8.0_211

vim etc/hadopp/yarn-env.sh
然后将# export JAVA_HOME=/home/y/libexec/jdk1.6.0export JAVA_HOME=/home/java/jdk1.8.0_211

vim etc/hadoop/mapred-env.sh
然后将# export JAVA_HOME=/home/y/libexec/jdk1.6.0export JAVA_HOME=/home/java/jdk1.8.0_211

修改配置文件

core-site.xml
<configuration>
    
    <property>
        <name>fs.defaultFSname>
        <value>hdfs://hadoop01:9000value>
    property>

    
    <property>
        <name>hadoop.tmp.dirname>
        <value>/home/hadoop/hadoop-2.7.2/data/tmpvalue>
    property>
configuration>
hdfs-site.xml
<configuration>
    
    <property>
        <name>dfs.replicationname>
        <value>3value>
    property>
    
    
    <property>
        <name>dfs.namenode.secondary.http-addressname>
        <value>hadoop02:50090value>
    property>
configuration>
yarn-site.xml
<configuration>

    
    <property>
        <name>yarn.nodemanager.aux-servicesname>
        <value>mapreduce_shufflevalue>
    property>

    
    <property>
        <name>yarn.resourcemanager.hostnamename>
        <value>hadoop03value>
    property>
    
    
    <property>
        <name>yarn.log-aggregation-enablename>
        <value>hadoop03value>
    property>
    
    
    <property>
        <name>yarn.log-aggregation.retain-secondsname>
        <value>604800value>
    property>
configuration>
mapred-site.xml

cp mapred-site.xml.template mapred-site.xml

<configuration>
    
    <property>
        <name>mapreduce.framework.namename>
        <value>yarnvalue>
    property>
    
    
    <property>
        <name>mapreduce.jobhistory.addressname>
        <value>hadoop03:10020value>
    property>
    
    
    <property>
        <name>mapreduce.jobhistory.webapp.addressname>
        <value>hadoop03:19888value>
    property>
configuration>
slaves
hadoop01
hadoop02
hadoop03

启动

逐节点启动

# 启动namenode
hadoop-daemon.sh start namenode
# 启动datanode
hadoop-daemon.sh start datanode
# 启动secondarynamenode
hadoop-daemon.sh start secondarynamenode
# 启动历史服务器
mr-jobhistory-daemon.sh start historyserver

脚本启动

启动hdfs服务:start-dfs.sh
启动yarn服务(需要在resourceManager节点启动,这里就是hadoop03节点)start-yarn.sh
启动历史服务器(在hadoop03节点):mr-jobhistory-daemon.sh start historyserver

你可能感兴趣的:(hadoop)