最近学习了一下Hadoop,在这分享一下自己的经验。
我先是在Windows 7,Vista, XP下用CYGWin进行配置的,但是由于问题不断,所以转战到Ubuntu9.10。
下面讲解在Ubuntu9.10下的配置过程。
1.配置SSH
sudo apt-get install openssh-server
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh localhost
成功之后进入第二步。
2.将Hadoop压缩包解压到主文件夹下,然后我们就来配置了。
2.1单机模式(Stand-alone Mode )
$ mkdir input
$ cp conf/*.xml input
$ bin/hadoop jar hadoop-*-examples.jar grep input output 'dfs[a-z.]+'
$ cat output/*
2.2伪分布式模式(Pseudo-Distributed Mode)
关键部分到了,你的jdk都应该安装和配置好,这里就不说了。
由于我给项目组里提交的是英文说明文档,所以就不翻译成中文了。
记住,bin/start-all.sh之后,运行程序完了之后,就bin/stop-all.sh,我的机子如果不这样,重启或者关机就会没反应。
1.In the file conf/hadoop-env.sh -> Set the JAVA_HOME
2.In the file conf/core-site.xml, configure it as below:
fs.default.name
hdfs://localhost:9000
3.In the file conf/hdfs-site.xml, configure it as below:
dfs.name.dir
/home/yourname/hadoopfs/name
dfs.data.dir
/home/yourname/hadoopfs/data
dfs.replication
1
4.In the file conf/mapred-site.xml, configure it as below:
mapred.job.tracker
localhost:9001
5.Format a new DFS:
$ bin/hadoop namenode -format
6.Start the Daemon process:
$ bin/start-all.sh
7.Experiment:
$ bin/hadoop fs -mkdir input
$ bin/hadoop fs -put conf/*.xml input
$ bin/hadoop jar hadoop-*-examples.jar grep input output 'dfs[a-z.]+'
$ bin/hadoop fs -cat output/*
$ bin/stop-all.sh
恩,它自带有个WordCount的例子。
http://localhost:50070
http://localhost:50030
这两个地址是查看Namenode和Datanode的。
3集群分布式(Fully-Distributed Mode)
首先配置多台机子SSH免密码登录,见SSH免密码登录
注意:每台机器保证都有相同的用户名,可以新建用户,新建的步骤在这就不说了,属于Linux的东西;或者你在装其他机器时就使用相同的登机用户名。
把主机按照下面步骤配置之后,把conf里面的文件都拷贝一份至Slave机器。
在下面步骤中的第六条,英文表达可能不清楚,意思就是记得修改/etc/hosts,/etc/hosts文件中的主机名一定要是机器名。
再次提醒,记得配置完后各个机器拷贝一份。
1.In the file conf/core-site.xml, configure it as below:
fs.default.name
hdfs://[Master's IPV4]:9000
2.In the file conf/hdfs-site.xml, configure it as below:
dfs.name.dir
/home/yourname/hadoopfs/name
dfs.data.dir
/home/yourname/hadoopfs/data
dfs.replication
1
3.In the file conf/mapred-site.xml, configure it as below:
mapred.job.tracker
[Master's IPV4]:9001
4.Modify the files of conf/Masters and conf/Slaves, add computer's IPV4 into these files.
5.Disable IPV6 (Search on the Internet)
6.In the file etc/Hosts of the Slave Computers, the Master's name must be the computer's name(for example, wang@wang-desktop, hadoop@clock-PC).
7.Use Eclipse 3.3
至此完结,写的比较笼统,也希望大家能给出好的意见。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com