首先说一下配置环境:三台电脑
192.168.30.149 Hadoop149 namenode和jobtracker ###因为149机器稍微好一点
192.168.30.150 hadoop150 datanode和TaskTracker 192.168.30.148 hadoop150 datanode和TaskTracker
配置ssh无需密码登陆:
$ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa $ cat~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
我的master在149可以吧149的.pub文件拷贝到150和148上 然后执行<pre name="code" class="plain">cat~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
<span style="color:#ff0000;">如果存在问题有可能是文件权限问题!</span>
我用的hadoop版本是hadoop-0.20.2 下载地址:
</pre><p>google吧 过两天弄个网盘都放在上面再写到这里。</p><p></p><p>下载后:编辑几个文件:</p><p>在/root/hadoop-0.20.2/conf中(这里注意的是几台电脑的hadoop文件路径必须相同):加入如下一句话</p><p></p><p> [root@localhostconf]# vim <span style="color: rgb(255, 0, 0); ">hadoop-env.sh </span> </p><p></p><pre name="code" class="plain"> exportJAVA_HOME=/usr/java/jdk1.7.0_01 ###设置变量
[root@localhostconf]# vim core-site.xml
<?xmlversion="1.0"?> <?xml-stylesheettype="text/xsl" href="configuration.xsl"?> <!-- Put site-specificproperty overrides in this file. --> <configuration> <property> <name>fs.default.name</name> <value>hdfs://192.168.30.149:9000</value> ###具体的意义之后会讲解 </property> </configuration>
[root@localhostconf]# vim mapred-site.xml
<?xmlversion="1.0"?> <?xml-stylesheettype="text/xsl" href="configuration.xsl"?> <!-- Putsite-specific property overrides in this file. --> <configuration> <property> <name>mapred.job.tracker</name> <value>hdfs://192.168.30.149:9004</value> </property> </configuration>
[root@localhostconf]# vim hdfs-site.xml
<?xmlversion="1.0"?> <?xml-stylesheettype="text/xsl" href="configuration.xsl"?> <!-- Putsite-specific property overrides in this file. --> <configuration> <property> <name>dfs.replication</name> <value>2</value> </property> </configuration><span style="font-family: Arial, Verdana, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); "> </span>
[root@localhostconf]# vim masters
hadoop149
[root@localhostconf]# vim slaves
hadoop150 hadoop148
一共编辑了5个文件,具体意义代表什么,之后会讲到
这里注意要被指/etc/hosts文件,如下(192.168.30.149):
[root@localhostconf]# vim /etc/hosts