nutch安装
安装软件准备
安装环境:centos 6.5
nutch:v2.2.1
hbase:v0.94.18
本篇重点讲述nutch的安装和nutch与hbase的集成,hbase的安装请参考其他资料;
安装步骤:
- 安装ant:因编译nutch源码,需要ant工具,下载apache-ant 设置 系统变量
写道[hadoop@master nutch]$ vim /etc/profile添加:ANT_HOME=/usr/local/ant 变量,并将AN_HOMT添加到PATH
- 下载nutch安装包:http://nutch.apache.org/downloads.html,下载目前最新的apache-nutch-2.2.1-src.tar.gz
Java代码
- [hadoop@master nutch]$ wget -P /usr/local/ http://www.apache.org/dyn/closer.cgi/nutch/2.2.1/apache-nutch-2.2.1-src.tar.gz
Java代码- [hadoop@master local]$ chmod 777 apache-nutch-2.2.1-src.tar.gz
- [hadoop@master local]$ tar zxvf apache-nutch-2.2.1-src.tar.gz
- [hadoop@master local]$ mv apache-nutch-2.2.1 nutch
- [hadoop@master local]$ cd nutch/
- 修改nutch的conf/nutch-site.xml文件,添加如下代码:
Java代码
- <property>
- <name>storage.data.store.class</name>
- <value>org.apache.gora.hbase.store.HBaseStore</value>
- <description>Default class for storing data</description>
- </property>
- <property>
- <name>http.agent.name</name>
- <value>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36</value>
- </property>
- 修改ivy/ivy.xml文件,找到:
Java代码
- <dependency org="org.apache.gora" name="gora-hbase" rev="0.3"
- conf="*->default" />
- 修改conf/gola.properies:
Java代码
- gora.datastore.default=org.apache.gora.hbase.store.HBaseStore
- ant编译nutch:切换到nutch目录:
Java代码
- [hadoop@master local]$ cd nutch
- [hadoop@master nutch]$ ant
- 修改nutch配置文件:在编译nutch源文件前,为了支持hbase存储,需要修改相应的配置:
Java代码
- #拷贝hbase的配置文件到nutch
- cp /usr/local/hbase/conf/hbase-site.xml /usr/local/nutch/conf/
Java代码- java.lang.IllegalArgumentException: Not a host:port pair
Java代码- java.lang.NoSuchMethodError:org.apache.hadoop.hbase.HColumnDescriptor.setMaxVersions(I)V
Java代码- http://central.maven.org/maven2/org/apache/hbase/hbase/0.92.2/hbase-0.92.2.jar
- 设置抓取网址: 编译后切换到目录:
Java代码
- [hadoop@master nutch]$ cd runtime/local/
- [hadoop@master local]$ mkdir -p urls
- [hadoop@master local]$ vim urls/seed.txt
Java代码- hadoop fs -copyFromLocal urls /home/hadoop/urls
- 运行nutch测试:执行nutch inject将网页种子放到hbase中
Java代码
- [hadoop@master local]$ bin/nutch inject /home/hadoop/urls
Java代码- hbase shell
- 进入到hbaseshell后查看表
- >list
- 然后一次执行
Java代码
- [hadoop@master local]$ bin/nutch generate -topN 3
- [hadoop@master local]$ bin/nutch fetch -all
- [hadoop@master local]$ bin/nutch parse -all
- [hadoop@master local]$ bin/nutch updatedb
- 切换到hbase shell或使用hbase client查看数据