经过一上午的努力,终于以伪分布式模式运行了C++版的MapReduce.下面逐一介绍这一过程
一、先决条件
1. 在Linux系统上已安装好Hadoop 1.0.X版本(本人系统为CentOS5.5(64位系统),hadoop版本为1.0.3,其它系统有可能不同)
2. 了解hadoop基本概念
二、步骤(如果已具备该步骤下的条件可以跳过该步骤)
1.修改$HADOOP_INSTALL/conf目录下的三个文件core-site.xml, hdfs-site.xml, mapred-site.xml分别如下:
-
- <?xml version="1.0"?>
- <!-- core-site.xml -->
- <configuration>
- <property>
- <name>fs.default.name</name>
- <value>hdfs://localhost/</value>
- </property>
- </configuration>
- <?xml version="1.0"?>
- <!-- hdfs-site.xml -->
- <configuration>
- <property>
- <name>dfs.replication</name>
- <value>1</value><!--only one copy-->
- </property>
- </configuration>
- <?xml version="1.0"?>
- <!-- mapred-site.xml -->
- <configuration>
- <property>
- <name>mapred.job.tracker</name>
- <value>localhost:8021</value>
- </property>
- </configuration>
2.配置SSH(即无密码访问本机,在CentOS5下比较麻烦)【遇到的困难1】
1). 确认系统已经安装好OpenSSH的server 和client
安装步骤这里不再讲述,不是本文的重点。
2). 确认本机sshd的配置文件(需要root权限)
$ vi /etc/ssh/sshd_config
找到以下内容,并去掉注释符”#“
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
3). 如果修改了配置文件需要重启sshd服务 (需要root权限)
$ /sbin/service sshd restart
4). ssh登陆系统 后执行测试命令:
$ ssh localhost
回车会提示你输入密码,因为此时还没有生成证书
5).生成证书公私钥的步骤:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
6).测试登陆 ssh localhost:
$ ssh localhost
正常情况下会登陆成功,显示一些成功登陆信息,如果失败请看下面的 一般调试步骤
7).若登录失败,很有可能是authorized_keys的权限问题,添加权限
$ chmod 600 ~/.ssh/authorized_keys
8).测试登陆 ssh localhost:(一般来说会成功!)
