nutch分布式搭建
来源:互联网 发布:行列式和矩阵的关系 编辑:程序博客网 时间:2024/05/01 22:12
一、下载安装文件
1、下载目前最新版本 nutch-1.0:http://lucene.apache.org/nutch
2、下载tomcat6.0:http://tomcat.apache.org
3、解压下载的两个压缩文件到 /home/java
二、配置文件
1、修改conf/hadoop-site.xml (配置文件和前面的hadoop-0.20.2不一样,这里的版本0.19.1不够先进)
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://home0.hadoop:9000</value>
</property>
<property>
<name>mapred.job.tracker</name>
<value>home0.hadoop:9001</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/home/lighttpd/hadoopfs/name_0,/home/lighttpd/hadoopfs/name_1</val ue>
<description>Determines where on the local filesystem the DFS name node
should store the name table. If this is a comma-delimited list of directories
then the name table is replicated in all of the directories,
for redundancy.
</description>
</property>
<property>
<name>dfs.data.dir</name>
<value>/home/lighttpd/hadoopfs/data_0,/home/lighttpd/hadoopfs/data_1</val ue>
<description>
Determines where on the local filesystem an DFS data node
should store its blocks. If this is a comma-delimited list of dir ectories,
then data will be stored in all named directories, typically on d ifferent devices.
Directories that do not exist are ignored.
</description>
</property>
</configuration>
2、修改 JAVA_HOME变量指向
在这个文件中hadoop-env.sh修改,前面配置hadoop已经讲过了。
4、设定主从节点
修改 conf/masters 文件,将其中的 localhost 改为 home0.hadoop 。
修改 conf/slaves 文件。 删掉其中的localhost, 将我们的另两台机器 home1.hadoop、home2.hadoop 加入, 注意每个机器一行。
masters里面的是主机节点,slaves里面是从机节点。
5、同样的配置拷贝到其他两台机器上去
scp -r nutch1.0 home1.hadoop:/home/yourname/
注意:可能您每台机器的JAVA安装位置不一样,记得修改conf/hadoop-env.sh,设置export JAVA_HOME=正确路径
三、启动hadoop服务
1、格式化一个新的分布式文件系统
bin/hadoop namenode -format
2、启动hadoop进程
$ bin/start-all.sh
四、抓取、建立索引
1、配置抓取入口
在nutch1.0目录下新建文件夹:urls,在该文件夹下新建文件:urllist.txt,在该文件中写入抓取列表,比如:
http://lucene.apache.org
写入分布式文件系统
bin/hadoop fs -put urls urls
2、设置URL过滤规则
编辑conf/crawl-urlfilter.txt
# accept hosts in MY.DOMAIN.NAME
#+^http://([a-z0-9]*/.)*MY.DOMAIN.NAME/
+^http://([a-z0-9]*/.)*apache.org
3、执行抓取命令
bin/nutch crawl urls -dir crawledDir -depth 3 -threads 10
五、搜索环境
1、把上面索引后的文件拷贝到本地,速度会好些,也可在分布式系统中,参考文档中讲到
bin/hadoop fs -copyToLocal crawledDir /home/yourname/nutch-1.0/crawledData
2、把 nutch-1.0.war 文件拷贝到tomcat下webapps目录,启动tomcat解压文件,再关闭服务
$ cp nutch-1.0.war /home/yourname/java/apache-tomcat-6.0.18/
$ cd /home/lighttpd/java/apache-tomcat-6.0.18/
$ bin/startup.sh
浏览器输入:http://locahost:8080/nutch-1.0
$ bin/shutdown.sh
3、修改/WEB-INF/classes/nutch-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<!-- /home/lighttpd/nutch-1.0/conf/search-dir/sina.com.cn -->
<configuration>
<property>
<name>searcher.dir</name>
<value>/home/yourname/nutch-1.0/crawledDir</value>
</property>
</configuration>
4、支持中文,在server.xml的 Connector中加入属性
URIEncoding="UTF-8"
useBodyEncodingForURI="true"
5、启动tomcat
$ cd /home/lighttpd/java/apache-tomcat-6.0.18/
$ bin/startup.sh
6、浏览器输入:http://locahost:8080/nutch-1.0 搜索试试
六、注意:
1、这里搜索的索引文件是拷贝到本地的文件,也可以搭建分布式索引文件
2、还可以搭建索引文件在不同的机器上,搜索时候从各个索引文件合并搜索结果
3、eclipse工程中的对应配置文件,都做设置的话,会运行在分布式系统中,如想调试运行在从机器上程序,需要采用本地运行方式,把hadoop-site.xml文件挪走,或者改名。
- nutch分布式搭建
- Nutch + Solr + Hadoop 搭建分布式搜索引擎详细教程
- 3 伪分布式-----Nutch环境搭建和配置
- Nutch分布式文件系统
- Nutch 0.9分布式配置
- Nutch分布式检索配置
- Nutch分布式检索配置
- nutch 分布式部署 自测
- nutch 分布式配置
- 【Nutch】nutch单机和分布式检索测试
- nutch搜索引擎的搭建
- 从零开始搭建nutch搜索引擎
- nutch+hadoop环境搭建
- Nutch+Hadoop集群搭建
- Nutch+Hadoop集群搭建
- Nutch+Hadoop集群搭建
- Nutch+Hadoop集群搭建
- Nutch环境搭建
- /proc/interrupts 和 /proc/stat 查看中断的情况
- OSG智能指针
- JS实现增加/复制/删除行
- 关于win2003服务器远程断开后自动注销的问题解决
- Office 2010十大优秀的新特性
- nutch分布式搭建
- Windows部署——Dism命令工具(1)
- 电脑保养
- 一个管道工的成功移民经历(转载)
- [转]病毒分析工具-OllySafe
- MDT2010 配置无人职守安装(2)—— BootStrap.ini 部分配置文件
- MDT2010 配置无人职守安装(1)—— RULE 配置文件
- windows xp/2003 0day漏洞临时防范方法
- LDAP