1.1、系统版本:linux-CentOS
1.2、jdk安装软件:jdk-6u39-linux-i586-rpm.bin(安装与配置请参考其它章节)
1.3、hadoop:1.0.4
2、集群搭建
2.1、以下为所用到的结点
192.168.253.133 master (hostname)
192.168.253.135 slave1
192.168.253.136 slave2
2.2、配置主机名以及各个结点之间可以通过ssh匿名连接
2.2.1、修改主机名
编辑192.168.253.133 /etc/sysconfig/network 修改HOSTNAME=master
编辑192.168.253.133 /etc/hosts
192.168.253.133 master
192.168.253.135 slave1
192.168.253.136 slave2
编辑192.168.253.135 /etc/sysconfig/network 修改HOSTNAME=slave1
编辑192.168.253.135 /etc/hosts
192.168.253.133 master
192.168.253.135 slave1
192.168.253.136 slave2
编辑192.168.253.136 /etc/sysconfig/network 修改HOSTNAME=slave2
编辑192.168.253.136 /etc/hosts
192.168.253.133 master
192.168.253.135 slave1
192.168.253.136 slave2
注:在修改hosts文件时尽量删除原来的127.0.0.1这些信息
2.2.2、配置三台机器可以ssh匿名连接
2.2.2.1、三台机器要求必须含有相同的用户名,因为是测试环境所以在此以root用户为例在master下执行以下命令
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
测试:
$ssh localhost
第一次ssh会有提示信息:
The authenticity of host ‘master (10.64.56.76)’ can’t be established.
RSA key fingerprint is 03:e0:30:cb:6e:13:a8:70:c9:7e:cf:ff:33:2a:67:30.
Are you sure you want to continue connecting (yes/no)?
输入 yes 来继续。这会把该服务器添加到你的已知主机的列表中
发现链接成功,并且无需密码。
2.2.2.2 复制authorized_keys到slave1和slave2
2.3、jdk配置
在三台机器上同时配置conf/hadoop-env.sh export JAVA_HOME=/usr/java/jdk1.6.0_39
2.4、hadoop配置文件
2.4.1、core-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://master:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/root/hadoopfs/tmp</value>
</property>
</configuration>
2.4.2、hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>
2.4.3、mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>master:9001</value>
</property>
</configuration>
2.4.4、masters
master
2.4.5、slaves
slave1
slave2
注:每个机器上的配置都应该和上边的信息一致
3、常见问题
3.1、在slave的datanode的日志报如下错误
Call to master/192.168.253.133:9000 failed on local exception: java.net.NoRouteToHostException: No route to host
直接关闭防火墙及可注:三台机器上的防火墙都要关闭;关闭命令如下
service iptables stop
3.2、could only be replicated to 0nodes, instead of 1
原因:当hadoop刚刚start-all时,datanode和namenode还没有进行连接,这个时候如果执行上传文件命令,会导致此命令,稍等一会问题就会解决,如果问题得不到解决,删除tmp/hadoop-你的用户名 文件重新格式化后启动。
注:因为我在配置的时候已经改变了tmp的位置此问题不会遇到
1522

被折叠的 条评论
为什么被折叠?



