Elastic search & kibana & 分词器 安装

版本控制

ES版本:7.2.0

分词器版本:

kibana 版本:7.2.0

下载地址

ES 下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-2-0

kibana 下载地址:https://www.elastic.co/cn/downloads/past-releases/kibana-7-2-0

hanlp 分词器下载地址: https://github.com/KennFalcon/elasticsearch-analysis-hanlp

Elastic search安装

  • 0.添加es 用户,并新建目录

不能以root 方式运行elasticSearch

groupadd elasticsearch
useradd elasticsearch -g elasticsearch chown -R elasticsearch:elasticsearch /home/elasticsearch
  • 1.修改 配置文件 elasticsearch.yml
cluster.name: fastclaim
node.name: node-test
network.host: 172.31.3.50
http.port: 9200
cluster.initial_master_nodes: ["node-test"]
  • 2.针对无法创建本地文件问题,用户最大可创建文件数太小

切换到root用户,编辑limits.conf配置文件

vi /etc/security/limits.conf
#末尾添加
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
  • 3.针对无法创建本地线程问题,用户最大可创建线程数太小
vi /etc/security/limits.d/90-nproc.conf

* soft nproc 1024
修改为
* soft nproc 4096
  • 4.针对最大虚拟内存太小

    解决方法:切换到root用户下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
添加配置
vm.max_map_count=655360
执行命令
sysctl -p
  • 5.重新启动,启动成功

如果要在后台运行,使用./bin/elasticsearch -d启动

curl 172.31.3.50:9200

{
"name" : "node-test",
"cluster_name" : "fastclaim",
"cluster_uuid" : "VtYF-EQIQNKHR1XWk7sE4g",
"version" : {
"number" : "7.2.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "508c38a",
"build_date" : "2019-06-20T15:54:18.811730Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

kibana 安装

  • 1.安装及启动

tar -xzvf 解压缩后,进行安装,

vim config/kibana.yml

# 修改如下四行
server.port: 5601
server.host: "172.31.3.50"
elasticsearch.hosts: ["http://172.31.3.50:9200"]
kibana.index: ".kibana"
# 后台启动

nohup ./bin/kibana >/dev/null &
  • 2.开发工具地址

http://IP:5601/app/kibana#/dev_tools/console?_g=()

分词器配置

参考链接:https://github.com/KennFalcon/elasticsearch-analysis-hanlp

  • 1.下载安装ES对应Plugin Release版本

安装方式:

方式一

a. 下载对应的release安装包,最新release包可从baidu盘下载(链接:https://pan.baidu.com/s/1mFPNJXgiTPzZeqEjH_zifw 密码:i0o7)

b. 执行如下命令安装,其中PATH为插件包绝对路径:

./bin/elasticsearch-plugin install file://${PATH}

方式二

a. 使用elasticsearch插件脚本安装command如下:

./bin/elasticsearch-plugin install https://github.com/KennFalcon/elasticsearch-analysis-hanlp/releases/download/v7.2.0/elasticsearch-analysis-hanlp-7.2.0.zip

  • 2.安装数据包

    release包中存放的为HanLP源码中默认的分词数据,若要下载完整版数据包,请查看HanLP Release。

    数据包目录:ES_HOME/plugins/analysis-hanlp

    注:因原版数据包自定义词典部分文件名为中文,这里的hanlp.properties中已修改为英文,请对应修改文件名

    hanlp.properties 在

    /home/elasticsearch/elasticsearch-7.2.0/config/analysis-hanlp 目录中

因为aws ec2 里面网络环境比较好,推荐直接在线安装。

  • 3.重启Elasticsearch

注:上述说明中的ES_HOME为自己的ES安装路径,需要绝对路径

  • 4.配置自定义词典并热更新

在本版本中,增加了词典热更新,修改步骤如下:

a. 在ES_HOME/plugins/analysis-hanlp/data/dictionary/custom目录中新增自定义词典

b. 修改hanlp.properties,修改CustomDictionaryPath,增加自定义词典配置

c. 等待1分钟后,词典自动加载

具体脚本,以医学常用词典medical.txt 为例

mv /tmp/medical.txt /home/elasticsearch/

cp /home/elasticsearch/medical.txt /home/elasticsearch/elasticsearch-7.2.0/plugins/analysis-hanlp/data/dictionary/custom/

#移动完成后修改权限

chown -R elasticsearch:elasticsearch /home/elasticsearch/

ll /home/elasticsearch/elasticsearch-7.2.0/plugins/analysis-hanlp/data/dictionary/custom/

#修改添加自定义目录

vim /home/elasticsearch/elasticsearch-7.2.0/config/analysis-hanlp/hanlp.properties

# Custom dictinary path
CustomDictionaryPath=data/dictionary/custom/CustomDictionary.txt; ModernChineseSupplementaryWord.txt; ChinesePlaceName.txt ns; PersonalName.txt; OrganizationName.txt; ShanghaiPlaceName.txt ns;data/dictionary/person/nrf.txt nrf; medical.txt;

注:每个节点都需要做上述更改

  • 5.提供的分词方式说明

hanlp: hanlp默认分词

hanlp_standard: 标准分词

hanlp_index: 索引分词

hanlp_nlp: NLP分词

hanlp_n_short: N-最短路分词

hanlp_dijkstra: 最短路分词

hanlp_crf: CRF分词(已有最新方式)

hanlp_speed: 极速词典分词

  • 6.分词样例
GET /_analyze?pretty
{
"analyzer" : "hanlp_crf",
"text" : ["南京市长江大桥"]
}
{
"tokens" : [
{
"token" : "南京市",
"start_offset" : 0,
"end_offset" : 3,
"type" : "ns",
"position" : 0
},
{
"token" : "长江大桥",
"start_offset" : 0,
"end_offset" : 4,
"type" : "nz",
"position" : 1
}
]
}

aws ec2 安装Elastic search 7.2.0 kibana 并配置 hanlp 分词插件的更多相关文章

  1. docker安装elastic search和kibana

    安装目标 使用docker安装elastic search和kibana,版本均为7.17.1 安装es 1. docker pull 去dockerhub看具体版本,这里用7.17.1 docker ...

  2. AWS EC2安装docker时的问题

    在AWS EC2的实例(Ubuntu)里面安装docker时,使用通常的安装步骤 :~$ sudo apt-get update :~$ sudo apt-get install docker 安装完 ...

  3. tpot从elastic search拉攻击数据之二 配置端口映射

    虽然知道了本地的数据接口位置,但是我们需要的是从远程拉取数据,所以我们需要更改es的ip端口为0.0.0.0:xxxx. 直接修改下图的elasticsearch.yml配置文件,结果发现无效. 这是 ...

  4. Hanlp分词插件docker集群安装

    背景:我是用docker-compose的方式装的es集群,正常情况es镜像没有插件,如果在docker里面用命令安装了那么重启以后又没了,所以采用挂载离线安装的方式 版本: es7.2 1下载Han ...

  5. chrom中安装elastic search head插件

    1. 访问https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm/ ...

  6. 通过tarball形式安装HBASE Cluster(CDH5.0.2)——配置分布式集群中的YARN ResourceManager 的HA

    <?xml version="1.0"?> <!-- Licensed under the Apache License, Version 2.0 (the &q ...

  7. SQL数据同步到ELK(二)- Elastic Search 安装

    开篇废话 没错,前面扯了一堆SQL SERVER,其实我连Elastic Search根本没动手玩过(是不是与时代有点脱节了?),那今天我就准备尝试安装一个ELK的简单集群出来(这个集群是使用我的小米 ...

  8. Elastic Search快速上手(1):简介及安装配置

    前言 最近开始尝试学习Elastic Search,因此决定做一些简单的整理,以供后续参考,快速上手使用ES. 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多 ...

  9. AWS EC2笔记

    朋友想搭一个境外网站,找我帮忙,希望服务器.域名都在境外.我没有在境外建站的经历,只能先尝试.于是上网搜索了一下境外服务器,大家比较常用的是Digital Ocean和AWS,我索性打开这两家的官网, ...

随机推荐

  1. 利用 Python 破解 ZIP 或 RAR 文件密码

    我们经常会从网络上下载一些带密码的压缩包,想要获取里面的内容,往往就要给提供商支付一些费用.想要白嫖其中的内容,常见的做法是百度搜索一些压缩包密码破解软件,但后果相信体验过的人都知道.本文将会利用 P ...

  2. 019-PHP创建目录函数

    <?php if (mkdir("myDir1", 0777)) //创建目录的函数 { print("目录创建成功"); //目录建立成功 } else ...

  3. 154-PHP strpos函数

    <?php $str='passwords'; //定义一个字符串 $position=strpos($str,'s'); //查找字母s第一次出现的位置 echo '字母s的位置是'.$pos ...

  4. (转) Spring 3 报org.aopalliance.intercept.MethodInterceptor问题解决方法

    http://blog.csdn.net/henuhaigang/article/details/13678023 转自CSDN博客,因为一个jar包没引入困扰我好长时间 ,当时正在做spring A ...

  5. 在各浏览器和各分辨率下如何让div内的table垂直水平居中?

    本文主要针对需要全屏显示的系统页面内,因为系统经常会用到表格table布局,偶尔的table需要显示在div的正中间,所以鄙人特此总结下div内table的万千姿态. <!DOCTYPE htm ...

  6. Elasticsearch 使用集群 - 删除索引

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  7. ES6 新特性(笔记)

    1.定义变量     let         a).块作用域 , 不同于var的函数作用域         b).不可以重复定义同一个变量名           注:              {} ...

  8. 数据库的交互模式 常用的dos命令 (第一天)

    浏览器和服务器和数据库的交互模式 windows nt(windows系统)的分类:服务操作系统有(server03 server08(R2) 12 16) 个人操作系统有(xp win7 win8 ...

  9. 数组空值empty

    Array构造函数只带一个数字参数时(否则是作为填充),该参数会被作为数组的预设长度,而非填充一个元素,因此数组内是空单元 如果一个数组中存在一个空单元,即length的值大于实际单元数,这样的数组称 ...

  10. python刷LeetCode:21. 合并两个有序链表

    难度等级:简单 题目描述: 将两个有序链表合并为一个新的有序链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例: 输入:1->2->4, 1->3->4输出:1 ...