hadoop配置文件
对于hadoop初学者而言,配置文件是最烦人的,为此,以下是本人配置hadoop的经验和总结,希望对你有所帮助
进入目录/home/zyq/software/hadoop-3.1.3/etc/hadoop(每个人的安装Hadoop的目录可能不一样,按照自己的安装目录来)
1.配置core-site.xml
vim core-site.xml
文件配置如下:
<configuration>
<!– 指定NameNode的地址 –>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop102:9000</value>
</property>
<!– 指定hadoop数据的存储目录 –>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/zyq/software/hadoop-3.1.3/data</value>
</property>
<property>
<name>hadoop.http.staticuser.user</name>
<value>root</value>
</property>
<!– 处理beeline连接的问题 –>
<property>
<name>hadoop.proxyuser.zyq.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.zyq.groups</name>
<value>*</value>
</property>
</configuration>
2.配置hdfs-site.xml
vim hdfs-site.xml
文件配置如下:
<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-site.xml
vim yarn-site.xml
文件配置如下:
<configuration>
<!– Site specific YARN configuration properties –>
<!– 指定MR走shuffle –>
<property>
<name>yarn.nodemanage.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!– 指定ResourceManager的地址–>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>hadoop103</value>
</property>
<!– 环境变量的继承 –>
<property>
<name>yarn.nodemanage.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>
<!– 开启日志聚集功能 –>
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<!– 设置日志聚集服务器地址 –>
<property>
<name>yarn.log.server.url</name>
<value>http://hadoop102:19888/jobhistory/logs</value>
</property>
<!– 设置日志保留时间为7天 –>
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
</property>
<property>
<name>yarn.application.classpath</name>
<value>/home/zyq/software/hadoop-3.1.3/etc/hadoop:/home/zyq/software/hadoop-3.1.3/share/hadoop/common/lib/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/common/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/hdfs:/home/zyq/software/hadoop-3.1.3/share/hadoop/hdfs/lib/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/hdfs/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/mapreduce/lib/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/mapreduce/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/yarn:/home/zyq/software/hadoop-3.1.3/share/hadoop/yarn/lib/*:/home/zyq/software/hadoop-3.1.3/share/hadoop/yarn/*</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
4.MapReduce配置文件(配置mapred-site.xml)
vim mapred-site.xml
文件内容如下:
<configuration>
<!–指定MapReduce 程序运行在Yarn上 –>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>