nutch2.1+mysql+elasticsearch整合linux单机部署
这次主要介绍下nutch2.1和mysql和elasticsearch的整合,是在单机上运行,并不是分布式部署。
1、下载nutch2.1
nutch下载地址:http://labs.mop.com/apache-mirror/nutch/2.1/apache-nutch-2.1-src.tar.gz
下载完成后解压,
2、配置nutch使用mysql作为数据存储,修改nutch根目录/ivy/ivy.xml文件
将这行的注释取消<dependency org=”mysql” name=”mysql-connector-java” rev=”5.1.18″ conf=”*->default”/>
修改nutch根目录/conf/gora.properties文件,把默认存储配置改成如下
# MySQL properties #
###############################
gora.sqlstore.jdbc.driver=com.mysql.jdbc.Driver
gora.sqlstore.jdbc.url=jdbc:mysql://host:3306/nutch? useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull
gora.sqlstore.jdbc.user=user
gora.sqlstore.jdbc.password=password
3、修改conf的nutch-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>http.agent.name</name>
<value>My Spider</value>
</property>
<property>
<name>http.accept.language</name>
<value>ja-jp,zh-cn,en-us,en-gb,en;q=0.7,*;q=0.3</value>
</property>
<property>
<name>parser.character.encoding.default</name>
<value>utf-8</value>
<description>The character encoding to fall back to when no other information
is available</description>
</property>
<property>
<name>storage.data.store.class</name>
<value>org.apache.gora.sql.store.SqlStore</value>
</property>
<property>
<name>plugin.includes</name>
<value>protocol-http|urlfilter-regex|parse-(html|tika)|index-(basic|anchor)|urlnormalizer-(pass|regex|basic)|scoring-opic</value>
</property>
</configuration>
4、使用ant编译源码。
nutch根目录下输入ant
5、设置待抓取的网站
cd nutch根目录/runtime/local
创建urls目录
mkdir -p urls
创建初始爬取网站列表
echo 'http://www.web.com/' > urls/seed.txt
6、创建数据库和表
CREATE DATABASE nutch DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE TABLE `webpage` (`id` varchar(767) CHARACTER SET latin1 NOT NULL,
`headers` blob,
`text` mediumtext DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`markers` blob,
`parseStatus` blob,
`modifiedTime` bigint(20) DEFAULT NULL,
`score` float DEFAULT NULL,
`typ` varchar(32) CHARACTER SET latin1 DEFAULT NULL,
`baseUrl` varchar(512) CHARACTER SET latin1 DEFAULT NULL,
`content` mediumblob,
`title` varchar(2048) DEFAULT NULL,
`reprUrl` varchar(512) CHARACTER SET latin1 DEFAULT NULL,
`fetchInterval` int(11) DEFAULT NULL,
`prevFetchTime` bigint(20) DEFAULT NULL,
`inlinks` mediumblob,
`prevSignature` blob,
`outlinks` mediumblob,
`fetchTime` bigint(20) DEFAULT NULL,
`retriesSinceFetch` int(11) DEFAULT NULL,
`protocolStatus` blob,
`signature` blob,
`metadata` blob,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7、执行爬行操作:
bin/nutch crawl urls -depth 3
执行完在mysql中即可以查看到爬虫抓取的内容
8、执行索引操作:
bin/nutch elasticindex clustername -all
注意:nutch2.1是通过创建一个es节点加入集群的方式与es集群交互的,所以只需知道es集群的集群名字就可以。并且必须在同一局域网内,不过这样的话对于关闭了广播通信的es集群并不适用。
执行完后就可以通过http://eshost:9200/index/_status来看到建立的索引信息
附elasticsearch 网页索引mapping(使用ik分词):
{
"mappings": {
"properties":{
"anchor":{
"index":"not_analyzed",
"type":"string"
},
"boost":{
"type":"string"
},
"content":{
"analyzer":"ik",
"boost":2.0,
"type":"string"
},
"digest":{
"type":"string"
},
"host":{
"type":"string"
},
"id":{
"type":"string"
},
"site":{
"type":"string"
},
"title":{
"analyzer":"ik",
"boost":4.0,
"type":"string"
},
"tstamp":{
"type":"date",
"format":"dateOptionalTime"
},
"url":{
"type":"string"
}
}
}
}
本文地址:http://www.searchtech.pro/nutch2.1-elasticsearch-mysql-local-Integrate
nutch2.1+mysql+elasticsearch整合linux单机部署的更多相关文章
- linux单机部署kafka(filebeat+elk组合)
filebeat+elk组合之kafka单机部署 准备: kafka下载链接地址:http://kafka.apache.org/downloads.html 在这里下载kafka_2.12-2.10 ...
- Ecstore安装篇-2.单机部署【linux】
单机部署实施-linux 单机部署实施-linux author :James,jimingsong@vip.qq.com since :2015-03-02 系统环境需求 软件来源 底层依赖 1. ...
- linux下部署php项目-Apache、php、mysql关联
linux下部署php项目环境可以分为两种,一种使用Apache,php,mysql的压缩包安装,一种用yum命令进行安装. 使用三种软件的压缩包进行安装,需要手动配置三者之间的关系.apache和p ...
- Linux服务器部署 Elasticsearch 成功,本机却访问不了
Elasticsearch版本: elasticsearch- 服务器版本: CentOS release 6.8 (Final) 问题: Linux服务器上部署了 Elasticsearch 5.5 ...
- Linux服务器部署系列之二—MySQL篇
MySQL是linux环境中使用最广泛的数据库之一,著名的“LAMP黄金组合”就要用到MySQL.关于MySQL的优点及作用,我就不多讲了,网上很多这样的文章. 今天我们要谈的是MySQL服务器的部署 ...
- Linux安装部署jdk+tomcat+mysql
Linux安装部署测试环境 1. JDK安装下载 安装 yum search jdk 找到合适的jdk版本,以下图中的版本为例 yum install java-1.8.0-openjdk.x86_6 ...
- Clickhouse单机部署以及从mysql增量同步数据
背景: 随着数据量的上升,OLAP一直是被讨论的话题,虽然druid,kylin能够解决OLAP问题,但是druid,kylin也是需要和hadoop全家桶一起用的,异常的笨重,再说我也搞不定,那只能 ...
- tomcat+nginx 单机部署多应用LINUX
1.首先虚拟机上安装nginx 和tomcat,这里安装就不赘述了. nginx安装可以参考https://www.linuxidc.com/Linux/2016-09/134907.htm,相关配置 ...
- Linux系统部署JavaWeb项目(超详细tomcat,nginx,mysql)
转载自:Linux系统部署JavaWeb项目(超详细tomcat,nginx,mysql) 我的系统是阿里云的,香港的系统,本人选择的是系统镜像:CentOS 7.3 64位. 具体步骤: 配置Jav ...
随机推荐
- Rhythmk 一步一步学 JAVA (14) Spring-3 @Autowired,@Qualifier @Required @Resource @Component,@Service,@Controller,@Repository @PostConstruct,@PreDestroy
1.@Autowired 注解:首先在使用时候需要引入配置: <!-- 该 BeanPostProcessor 将自动起作用,对标注 @Autowired 的 Bean 进行自动注入 --> ...
- VS调试时JSON格式文件无法加载
VS调试时JSON格式文件无法加载 报错: 解决:在项目中的web.config中进行配置,configuration节中添加以下部份: <system.webServer> <st ...
- 跟着太白老师学python day10 函数嵌套, global , nonlocal
函数嵌套: 第一种嵌套方法 def func(): count = 123 def inner(): print(count) inner() func() 第二种嵌套方法 count = 123 d ...
- django html模板继承 {%block 标记名} {%endblock%}
对于url文件 url(r'^tp1/', views.tp1) 对于views文件,跳转到tp1.html 同时将list列表传到前端 def tp1(request): list = [1, 2, ...
- 聊聊flutter的UI布局
UI布局多半是套路,熟悉套路的规则. Flutter的UI布局也有一套规则 center center可以让任何元素在屏幕中居中,既是水平居中又是垂直居中,如果想让元素从上而下排列要怎么办呢?那就得使 ...
- JAVA压缩 解压缩zip 并解决linux下中文乱码
1. [代码][Java]代码 1:再压缩前,要设置linux模式, 需要使用第三方ant-1.6.5.jar 如果是文件目录,则ZipEntry zipEntry=new ZipEntry(b ...
- 4.Hadoop集群搭建之启动
配置好Hadoop.HDFS.YARN.Zookeeper集群后,需要按照顺序启动. 前期准备 配置好Hadoop.HDFS.YARN.Zookeeper集群 先stop掉所有的hadoop服务 使用 ...
- 【祥哥带你玩HoloLens开发】了解如何实现远程主机为HoloLens实时渲染
今天有一个兄弟在群里讲到他们的项目模型比较大,单用HoloLens运行设备的性能无法满足需要,问道如何将渲染工作交给服务器来做,讲渲染结果传给HoloLens.正好刚刚看官方github的时候发现一个 ...
- ajax+servlet 简易时间效果
<!DOCTYPE html> <html> <head> <title>index.html</title> <meta name= ...
- EZOJ #227
传送门 分析 我们发现第一段数和最后一段数对答案的贡献系数为1/-1,其余为0/2/-2 而且对于相邻两段不能系数均非0 于是可以dp 代码 #include<iostream> #inc ...