Hadoop集群基本配置
1、解压缩
tar -xvzf hadoop-0.20.2.tar.gz
2、配置Hadoop环境变量
修改vi ~/.bashrc,在文件最后面加上如下配置:
export HADOOP_HOME=/usr/local/hadoop-0.20.2 export PATH=$PATH:$HADOOP_HOME/bin 3、配置master和slaves文件修改 vim /usr/local/hadoop-0.20.2/conf/masters 文件,内容如下所示:
hadoop-1修改 vim /usr/local/hadoop-0.20.2/conf/slaves 文件,内容如下所示:
hadoop-2 hadoop-3 hadoop-44、配置hadoop-env.sh文件
配置文件 vim /usr/local/hadoop-0.20.2/conf/hadoop-env.sh ,只需要修改Java_HOME配置,如下所示:
export JAVA_HOME=/home/jdk1.6.0_31
其它选项,可以根据需要进行配置。
5、配置conf/core-site.xml文件
配置文件vim /usr/local/hadoop-0.20.2/conf/core-site.xml的内容,如下所示:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Do not modify this file directly. Instead, copy entries that you --> <!-- wish to modify from this file into core-site.xml and change them --> <!-- there. If core-site.xml does not already exist, create it. --> <configuration> <property> <name>fs.default.name</name> <value>hdfs://hadoop-1:9000/</value> <description></description> </property> <property> <name>dfs.replication</name> <value>3</value> </property> <property> <name>fs.inmemory.size.mb</name> <value>10</value> <description>Larger amount of memory allocated for the in-memory file-system used to merge map-outputs at the reduce s.</description> </property> <property> <name>io.sort.factor</name> <value>10</value> <description>More streams merged at once while sorting files.</description> </property> <property> <name>io.sort.mb</name> <value>10</value> <description>Higher memory-limit while sorting data.</description> </property> <property> <name>io.file.buffer.size</name> <value>131072</value> <description>Size of read/write buffer used in SequenceFiles.</description> </property> <property> <name>hadoop.tmp.dir</name> <value>/home/hadoop/storage1/tmp/hadoop-${user.name}</value> <description></description> </property> </configuration>
上面配置内容,是与HDFS的基本属性相关的,一般在系统运行过程中比较固定的配置,都放到这里面。如果需要根据实际应用的变化,可以配置到hdfs-site.xml文件中,下面会解释。