您的位置:首页 > 其它

muhout 第二天学习笔记

2013-05-03 17:34 369 查看
首先打开 hadoop文件夹 :
在hadoop 的Conf文件夹中的 ,core-site.xml中的
<property>
<name>fs.default.name</name>

<value>hdfs://localhost:9000</value>

</property>
定义了hdfs的端口,但是用浏览器打开 http://127.0.0.1:9000发现是空白页。 这个应该只是hdfs通讯使用的端口。

根据教程:
首先需要配置机器名和hosts
通过以下命令:
[glw@localhost ~]$ vi /etc/sysconfig/network

[glw@localhost ~]$ su

Password:

[root@localhost glw]# vi /etc/sysconfig/network

[root@localhost glw]# vi /etc/hosts

[root@localhost glw]#

重启机器
然后配置ssh:
ssh-keygen
cat .ssh/id_rsa.pub >> .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
ssh glw
修改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>hadoop.tmp.dir</name>

<value>/home/glw/tmp</value>

<description>A base for other temporary directories.</description>

</property>

<property>

<name>fs.default.name</name>

<value>hdfs://glw:9000</value>

</property>

<property>

<name>hadoop.proxyuser.root.hosts</name>

<value>glw</value>

</property>

<property>

<name>hadoop.proxyuser.root.groups</name>

<value>*</value>

</property>

</configuration>

修改 map-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>glw:9001</value>

</property>

</configuration>
启动 hadoop:
查看以下地址:
http://glw:50070/dfshealth.jsp
运行wordcount实例
(1)新建file01和file02,并设置内容;
(2)在hdfs中建立一个input目录: Hadoop fs –mkdir input
(3)将file01和file02拷贝到hdfs中 hadoop fs -copyFromLocal file0* input
(4)执行wordcount hadoop jar hadoop-examples-0.20.2-cdh3u3.jar wordcount input output
(5)查看结果 hadoop fs -cat output/part -r -00000
运行mahout
首先将synthetic_control.data数据写入hdfs
[glw@glw ~]$ hadoop fs -mkdir testdata
[glw@glw ~]$ hadoop fs -copyFromLocal synthetic_control.data testdata/synthetic_control.data

mahout示例程序从 testdata/synthetic_control.data提取数据,并输出到:/user/liuhx/output/data/part-m-00000

[glw@glw ~]$ hadoop jar ./hadoop/mahout-0.5-cdh3u6/mahout-examples-0.5-cdh3u6-job.jar org.apache.mahout.clustering.syntheticcontrol.kmeans.Job
查看图形结果:

[glw@glw ~]$ hadoop jar ./hadoop/mahout-0.5-cdh3u6/mahout-examples-0.5-cdh3u6-job.jar org.apache.mahout.clustering.display.DisplayKMeans
至此mahout安装完成,下一步要做的事:
1.hadoop的eclipse插件安装。
碰到了虚拟机可以ping通但是不能连接上服务的问题,关闭防火墙后依然不行。
网上有资料说是vmware9太新的虚拟网卡导致的问题。使用桥接后问题解决,可能就是该问题。
碰到了client version mismatch的错误,需要重新编译eclipese 插件
1.使用eclipse的导入工程功能。
文件夹路径:...\hadoop-0.20.2-cdh3u6\src\contrib\eclipse-plugin
2.MapReduceTools出现问题,找不到 hadoop-core.jar,将其替换为:hadoop-core-0.20.2-cdh3u6.jar
3.修改工程中的plugin.xml,中的runtime项,注意classpath配置为:hadoop-core-0.20.2-cdh3u6.ja





4.使用plugin.xml中的overview中的export the plugin in a format suitable for deployment using the Export_Wizard,如下图:





5.将org.apache.hadoop.eclipse_0.18.0.jar放入eclipse的plugin文件夹下,重启eclipse,配置hadoop连接,出现了以下问题:





Could not initialize class org.apache.hadoop.mapred.JobConf
估计是由于hadoop core jar包未被打包导致的问题,查看对应的jar包,发现hadoop core jar包存在。目前不能发现问题,去google上看看。没有找到任何相关问题的资料,有印象好像处理过这个问题,但是现在忘记了,从以前的插件中看看,到底出了什么问题。不行的话讲原来插件的hadoop-core替换掉,查看了以前编译好的插件,发现lib包中有很多其他jar包:
commons-cli-1.2.jar
commons-configuration-1.6.jar 没有在cdh3u6中发现!
commons-lang-2.4.jar
jackson-core-asl-1.8.8.jar
jackson-mapper-asl-1.8.8.jar
log4j-1.2.15.jar
将以上的jar放入lib
然后错误变了:
An internal error occurred during: "Connecting to DFS 191.168.2.26".
org/apache/hadoop/thirdparty/guava/common/collect/LinkedListMultimap
在lib中发现了 guava-r09-jarjar.jar,增加到lib包。
终于可以看见文件夹列表了:



总结:
"Could not initialize class" 的错误一般是由于类中引用的包不能被找到导致的问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: