一、安装依赖

安装oracleJDK

[root@xiangys0134-docker-01 tmp]# java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

二、安装Hadoop

[root@xiangys0134-docker-01 tmp]# tar -zxvf hadoop-3.2.0.tar.gz -C /usr/local/
[root@xiangys0134-docker-01 tmp]# cd /usr/local/hadoop-3.2.0/
[root@xiangys0134-docker-01 hadoop-3.2.0]# vim etc/hadoop/hadoop-env.sh
添加
JAVA_HOME=/usr/local/java/jdk

三、配置Hadoop

[root@xiangys0134-docker-01 hadoop-3.2.0]# vim etc/hadoop/core-site.xml //添加如下内容
<configuration>
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
    </property>

    <property>
        <name>hadoop.tmp.dir</name>
        <value>/home/hadoop/grid/disk</value>
    </property>
</configuration>

[root@xiangys0134-docker-01 hadoop-3.2.0]# vim etc/hadoop/hdfs-site.xml //添加如下内容
<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
</configuration>

四、配置ssh

//配置用户免密登陆
[root@xiangys0134-docker-01 hadoop-3.2.0]# useradd hadoop
[root@xiangys0134-docker-01 hadoop-3.2.0]# passwd hadoop

[root@xiangys0134-docker-01 hadoop-3.2.0]# vim /etc/hosts       //指定hosts
添加如下内容:
192.168.10.45 hadoop_master

[root@xiangys0134-docker-01 hadoop-3.2.0]# su hadoop    //切换到hadoop下

//配置普通用户hadoop公钥私钥
[hadoop@xiangys0134-docker-01 hadoop-3.2.0]ssh-keygen -t rsa
[hadoop@xiangys0134-docker-01 hadoop-3.2.0] cd ~/.ssh/
[hadoop@xiangys0134-docker-01 .ssh]cat id_rsa.pub>authorized_keys
[hadoop@xiangys0134-docker-01 .ssh] chmod 600 authorized_keys
[hadoop@xiangys0134-docker-01 .ssh]$ ssh localhost  //测试ssh连接成功

五、启动 Hadoop

5.1初始化文件系统
//授权hadoop用户具体所有权限
[root@xiangys0134-docker-01 local]# chown -R hadoop. hadoop-3.2.0/

[root@xiangys0134-docker-01 local]# su hadoop
[hadoop@xiangys0134-docker-01 local]cd /usr/local/hadoop-3.2.0/
[hadoop@xiangys0134-docker-01 hadoop-3.2.0] bin/hdfs namenode -format
5.2启动NN和DN
[hadoop@xiangys0134-docker-01 hadoop-3.2.0]$ sbin/start-dfs.sh

[hadoop@xiangys0134-docker-01 hadoop-3.2.0]$ jps        //查看hadoop运行状况
4083 DataNode
4469 Jps
3961 NameNode
4271 SecondaryNameNode

六、测试

[hadoop@xiangys0134-docker-01 hadoop-3.2.0]$ bin/hdfs dfs -mkdir /user      //创建user目录

[hadoop@xiangys0134-docker-01 hadoop-3.2.0]$ ./bin/hdfs dfs -put /tmp/php-beast-master.zip /user    //上传文件至/user目录

[hadoop@xiangys0134-docker-01 hadoop-3.2.0]$ ./bin/hdfs dfs -get /user/php-beast-master.zip ~/      //下载文件至家目录

七、YARN配置在单节点

YARN由两部分组成ResourceManager守护程序和NodeManager守护程序

[hadoop@xiangys0134-docker-01 hadoop-3.2.0]vim etc/hadoop/mapred-site.xml
<configuration>
    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
</configuration>

[hadoop@xiangys0134-docker-01 hadoop-3.2.0] vim etc/hadoop/yarn-site.xml
<configuration>
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
</configuration>

八、启动YARN

[hadoop@xiangys0134-docker-01 hadoop-3.2.0]$ sbin/start-yarn.sh

最后修改日期: 2023年12月14日

作者

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。