首页 > 代码库 > Hadoop0.21.0部署安装以及mapreduce测试
Hadoop0.21.0部署安装以及mapreduce测试
鉴于hadoop的需要。。。但是并不限于此。。。有时候闲输入密码麻烦,也可以用这种办法从一个节点通过ssh进入另一个节点。。。
设要使master进入slave是免密码的,则可以在master(ip为192.168.169.9)中如下操作:
命令:ssh-keygen -t rsa 然后一路回车(该命令不需要进入特定目录)
cd进入/root/.ssh/可以看见如下(橙色是新生成的)
id_rsa id_rsa.pub known_hosts
然后用scp命令将id_rsa远程传输到slave(ip为192.168.169.10)节点中:scp id_rsa.pub 192.168.169.10:/root/.ssh/192.168.169.9
则可以在slave的/root/.ssh/目录下看到名为192.168.169.9的文件:
主机名 | IP | 功能 |
namenode | 192.168.169.9 | NameNode,jobtraker |
datanode1 | 192.168.169.10 | DataNode,tasktraker |
datanode2 | 192.168.169.20 | DataNode,tasktraker |
同时在三台机子的/etc/hosts中添加以下内容以修改机器名:
192.168.169.9 namenode
192.168.169.10 datanode1
192.168.169.20 datanode2
修改后注意解析测验下:(datanode测验同理)
-bash-3.1# ping -c 4 namenode
PING namenode (192.168.169.9) 56(84) bytes of data.
64 bytes from namenode (192.168.169.9): icmp_seq=1 ttl=64 time=0.020 ms
64 bytes from namenode (192.168.169.9): icmp_seq=2 ttl=64 time=0.009 ms
64 bytes from namenode (192.168.169.9): icmp_seq=3 ttl=64 time=0.009 ms
64 bytes from namenode (192.168.169.9): icmp_seq=4 ttl=64 time=0.010 ms
--- namenode ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.009/0.012/0.020/0.004 ms
然后修改/etc/sysconfig/network中的域名(因为必须要域名和机器名一样)如图(这里只列出namenode的,datanode的类似,只修改HOSTNAME)
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=namenode
2.ssh免密码认证
具体做法上一篇博文已经讲过。。这里不再赘述,但是要注意,这里需要做到的是:
- master到slave的免密码认证;
- slave到master的免密码认证;
- master到master的免密码认证。
例如我对第一条测验一下:
-bash-3.1# ssh datanode1
Last login: Fri Feb 17 08:32:34 2012 from namenode
-bash-3.1# exit
logout
Connection to datanode1 closed.
-bash-3.1# ssh datanode2
Last login: Fri Feb 17 08:32:42 2012 from namenode
-bash-3.1# exit
logout
Connection to datanode2 closed.
3.安装JDK并配置环境变量,因为我的已经安装过了,所以我只需要配置环境变量了,修改/etc/profile内容如下:(注意修改后要source /etc/profile)
export JAVA_HOME=/usr/java/jdk1.6.0_29
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:/usr/java/jdk1.6.0_29/bin
export CLASSPATH=:/usr/java/jdk1.6.0_29/lib:/usr/java/jdk1.6.0_29/jre/lib
查看下版本:
-bash-3.1# java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
写个具体例子跑一下(test.java):
class test
{
public static void main(String[] args)
{
System.out.println("Hello,World!");
}
}
测试一下:
-bash-3.1# javac test.java
-bash-3.1# java test
Hello,World!
说明成功了。。。。。
4.Hadoop安装配置
下载hadoop-0.21.0.tar.gz压缩包下来之后解压缩到一定目录,然后把它放到个固定的地方,我把它放在了/usr/local/hadoop目录下,进去看下
-bash-3.1# ll
drwxrwxr-x 5 huyajun huyajun 4096 2010-08-17 c++
drwxr-xr-x 8 huyajun huyajun 4096 2010-08-17 common
drwxrwxr-x 2 huyajun huyajun 4096 02-16 15:54 conf
-rw-rw-r-- 1 huyajun huyajun 1289953 2010-08-17 hadoop-common-0.21.0.jar
-rw-rw-r-- 1 huyajun huyajun 622276 2010-08-17 hadoop-common-test-0.21.0.jar
-rw-rw-r-- 1 huyajun huyajun 934881 2010-08-17 hadoop-hdfs-0.21.0.jar
-rw-rw-r-- 1 huyajun huyajun 613332 2010-08-17 hadoop-hdfs-0.21.0-sources.jar
-rw-rw-r-- 1 huyajun huyajun 6956 2010-08-17 hadoop-hdfs-ant-0.21.0.jar
-rw-rw-r-- 1 huyajun huyajun 688026 2010-08-17 hadoop-hdfs-test-0.21.0.jar
-rw-rw-r-- 1 huyajun huyajun 419671 2010-08-17 hadoop-hdfs-test-0.21.0-sources.jar
-rw-rw