集群搭建(3)

配置集群

(1)核心配置文件

配置core-site.xml

[atguigu@hadoop102 ~]$ cd $HADOOP_HOME/etc/hadoop

[atguigu@hadoop102 hadoop]$ vim core-site.xml

文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

 

<configuration>

    <!-- 指定NameNode的地址 -->

    <property>

        <name>fs.defaultFS</name>

        <value>hdfs://hadoop102:8020</value>

    </property>

 

    <!-- 指定hadoop数据的存储目录 -->

    <property>

        <name>hadoop.tmp.dir</name>

        <value>/opt/module/hadoop-3.1.3/data</value>

    </property>

 

    <!-- 配置HDFS网页登录使用的静态用户为atguigu -->

    <property>

        <name>hadoop.http.staticuser.user</name>

        <value>atguigu</value>

    </property>

</configuration>

(2)HDFS配置文件

配置hdfs-site.xml

[atguigu@hadoop102 hadoop]$ vim hdfs-site.xml

文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

 

<configuration>

    <!-- nn web端访问地址-->

    <property>

        <name>dfs.namenode.http-address</name>

        <value>hadoop102:9870</value>

    </property>

    <!-- 2nn web端访问地址-->

    <property>

        <name>dfs.namenode.secondary.http-address</name>

        <value>hadoop104:9868</value>

    </property>

</configuration>

(3)YARN配置文件

配置yarn-site.xml

[atguigu@hadoop102 hadoop]$ vim yarn-site.xml

文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

 

<configuration>

    <!-- 指定MR走shuffle -->

    <property>

        <name>yarn.nodemanager.aux-services</name>

        <value>mapreduce_shuffle</value>

    </property>

 

    <!-- 指定ResourceManager的地址-->

    <property>

        <name>yarn.resourcemanager.hostname</name>

        <value>hadoop103</value>

    </property>

 

    <!-- 环境变量的继承 -->

    <property>

        <name>yarn.nodemanager.env-whitelist</name>

        <value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value>

    </property>

</configuration>

(4)MapReduce配置文件

配置mapred-site.xml

[atguigu@hadoop102 hadoop]$ vim mapred-site.xml

文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

 

<configuration>

    <!-- 指定MapReduce程序运行在Yarn上 -->

    <property>

        <name>mapreduce.framework.name</name>

        <value>yarn</value>

    </property>

</configuration>

在集群上分发配置好的Hadoop配置文件

[atguigu@hadoop102 hadoop]$ xsync /opt/module/hadoop-3.1.3/etc/hadoop/

去103和104上查看文件分发情况

[atguigu@hadoop103 ~]$ cat /opt/module/hadoop-3.1.3/etc/hadoop/core-site.xml

[atguigu@hadoop104 ~]$ cat /opt/module/hadoop-3.1.3/etc/hadoop/core-site.xml

posted @ 2022-09-26 23:26  灰幕  阅读(32)  评论(0)    收藏  举报