nutch和solr集成安装

来源:互联网 发布:一朝成名天下知出处 编辑:程序博客网 时间:2024/05/16 05:07
  1. 安装的操作系统环境为:redhat6.5server64位系统,下载nutch1.8、solr4.7.0,解压压缩包并配置jdk支持
  2. 拷贝[solr_home]/dist/apache-solr-4.7.0.war的文件到tomcat/webapps目录下,并且改名solr.war
  3. [solr_home]\example\下的solr目录拷贝到任意位置,我是放在:~/tomcat7/solr
  4. tomcat目录下的conf\Catalina\localhost目录中(如果没有则手工创建该目录)创建solr.xml文件,文件内容如下:

            <Context docBase="[tomat_home]/webapps/solr.war" debug="0" crossContext="true" >
            <Environment name="solr/home" type="java.lang.String" value="[tomcat_home]/solr" override="true" />
            </Context>

       5.   solr有很多依赖jar包需要手动添加下将解压后solr-4.0.7目录下dist/*.jar, dist/solrj-lib/*.jar都拷贝到了
             tomcat/webapps/solr/WEB-INF/lib/下。这时可能会有重复的jar包,覆盖下就ok了.                              
             启动tomcat,输入http://localhost:8080/solr/,出现欢迎界面则表示配置成功
       6.   将[nutch_home]/conf/schema-solr4.xml复制到/tomcat7/solr/collection1/conf目录下并改名为schema.xml,并在<fields>节点最后
              添加<field name="_version_" type="long" indexed="true" stored="true"/>,solr配置完成。
       7.   配置nutch爬取网页:
                (1)修改文件conf/nutch-site.xml,设置HTTP请求中agent的名字:  
                              <?xml version="1.0"?> 
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> 
<!-- Put site-specific property overrides in this file. --> 
<configuration> 
  <property> 
    <name> http.agent.name </name> 
    <value>Friendly Crawler</value> 
    </property> 
 </configuration>   
                (2)创建种子文件夹 :mkdir -p urls ,创建种子文件/urls/seed.txt,并添加要爬去的URL,如http://localhost:8080/
                (3)配置conf/regex-urlfilter.txt文件,修改
                     # accept anything else
                     +.
                     为:+^http://([a-z0-9]*\.)*localhost:8080/
                (4)执行爬取命令:./bin/crawl urls mydir http://localhost:8080/solr/ 2
                (5)solr查询:
                


0 0
原创粉丝点击