centos系統(tǒng)下的hadoop分布式文件系統(tǒng)(hdfs)配置詳解
在centos環(huán)境中部署hadoop hdfs,需要正確配置四個(gè)核心配置文件,它們位于Hadoop安裝目錄下的etc/hadoop文件夾中。以下詳細(xì)介紹每個(gè)配置文件及其關(guān)鍵參數(shù):
-
core-site.xml: 定義系統(tǒng)級參數(shù),例如HDFS的URL和Hadoop的臨時(shí)目錄。
示例配置:
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://localhost:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/local/hadoop/tmp</value> </property> <property> <name>hadoop.proxyuser.root.hosts</name> <value>*</value> </property> <property> <name>hadoop.proxyuser.root.groups</name> <value>*</value> </property> </configuration>
-
hdfs-site.xml: 配置HDFS特有的參數(shù),例如NameNode和DataNode的地址、副本數(shù)量以及文件訪問權(quán)限等。
示例配置:
<configuration> <property> <name>dfs.http.address</name> <value>localhost:9870</value> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>localhost:9870</value> </property> <property> <name>mapreduce.jobhistory.address</name> <value>localhost:10020</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>localhost:19888</value> </property> </configuration>
-
mapred-site.xml: 配置MapReduce框架的參數(shù)。
示例配置:
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
-
yarn-site.xml: 配置YARN(Yet Another Resource Negotiator,Hadoop集群資源管理器)的參數(shù)。
示例配置:
<configuration> <property> <name>yarn.Resourcemanager.address</name> <value>localhost:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>localhost:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>localhost:8031</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> <property> <name>yarn.nodemanager.vmem-check-enabled</name> <value>false</value> </property> <property> <name>yarn.nodemanager.disk-health-checker.max-disk-utilization-percentage</name> <value>99</value> </property> <property> <name>yarn.application.classpath</name> <value>/usr/lib/hadoop/client-0.20/lib/*</value> </property> </configuration>
在實(shí)際配置過程中,需要根據(jù)集群環(huán)境和具體需求調(diào)整這些參數(shù)的值。例如,fs.defaultFS 指定 NameNode 的地址,dfs.replication 設(shè)置文件副本數(shù)量等。 務(wù)必仔細(xì)檢查每個(gè)參數(shù)的含義,確保配置正確,以避免HDFS運(yùn)行出現(xiàn)問題。