前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ElasticSearch&HanLP --- 集群部署及常见坑

ElasticSearch&HanLP --- 集群部署及常见坑

作者头像
十毛
发布2019-03-27 11:47:46
8430
发布2019-03-27 11:47:46
举报

部署环境

3台服务器: 192.168.58.201 192.168.58.203 192.168.58.205,部署地址为/opt/soft/,ES版本为5.4.3

组件准备

下载ElasticSearch

代码语言:javascript
复制
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.3.tar.gz

编译hanlp-ext

代码语言:javascript
复制
git clone https://github.com/hualongdata/hanlp-ext.git
cd hanlp-ext
gradle -p es-plugin jar buildPluginZip
# 获得插件:hanlp-ext/es-plugin/distributions/elasticsearch-hanlp-5.4.3.zip

HanLP-1.3.4-offline-tar.gz

下载地址:https://pan.baidu.com/s/1o8Rri0y

安装ElasticSearch

解压

代码语言:javascript
复制
hosts=(192.168.58.201 192.168.58.203 192.168.58.205)
installDir=/opt/soft
hanlpDataDir=/opt/data
if [ ! ${#hosts[@]} = 3 ]; then echo "hosts should set to has three servers"; exit; fi

tar xzf elasticsearch-5.4.3.tar.gz -C ${installDir}
es_home=${installDir}/elasticsearch-5.4.3
ln -s ${installDir}/elasticsearch-5.4.3 ${installDir}/elasticsearch
${es_home}/bin/elasticsearch-plugin install file://`pwd`/elasticsearch-hanlp-5.4.3.zip
tar xzf HanLP-1.3.4-offline.tar.gz -C ${hanlpDataDir}
ln -s ${hanlpDataDir}/HanLP-1.3.4-offline ${hanlpDataDir}/HanLP
cp sysctl.conf ${es_home}/config/

配置

集群配置
代码语言:javascript
复制
sed -i 's|#cluster.name: my-application|cluster.name: iask-cluster|g' ${es_home}/config/elasticsearch.yml
sed -i 's|#network.host: 192.168.0.1|network.host: 0.0.0.0|g' ${es_home}/config/elasticsearch.yml
sed -i "s|#discovery.zen.ping.unicast.hosts: \[\"host1\", \"host2\"]|discovery.zen.ping.unicast.hosts: \[\"${hosts[0]}\", \"${hosts[1]}\", \"${hosts[2]}\"]|g" ${es_home}/config/elasticsearch.yml
sed -i 's|#discovery.zen.minimum_master_nodes: 3|discovery.zen.minimum_master_nodes: 2|g' ${es_home}/config/elasticsearch.yml
HanLP配置
代码语言:javascript
复制
echo "-Djava.security.policy=file://${es_home}/plugins/elasticsearch-hanlp/plugin-security.policy" >> ${es_home}/config/jvm.options
echo 'ES_CLASSPATH="$ES_HOME/lib/*:$ES_HOME/plugins/elasticsearch-hanlp/"' >> ${es_home}/bin/elasticsearch.in.sh
sed -i 's|^root=/opt/app/HanLP/$|root=${hanlpDataDir}/HanLP|g' ${es_home}/plugins/elasticsearch-hanlp/hanlp.properties
sudo ln -s ${es_home}/config/sysctl.conf /etc/sysctl.d/es-sysctl.conf
sudo sysctl -w vm.max_map_count=262144
系统设置

设置最大文件描述符数量,在/etc/security/limits.conf文件中添加2行

代码语言:javascript
复制
* soft nofile 65536
* hard nofile 65536

命令如下,这里需要使用root权限

代码语言:javascript
复制
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf
启动
代码语言:javascript
复制
bin/elasticsearch -d #后台启动

常见问题

  • max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]:(解决办法: /etc/security/limits.conf添加 两行"* soft nofile 65536\n* hard nofile 65536"需要重新ssh或打开终端)
  • max number of threads [3815] for user [user] is too low, increase to at least [4096](解决办法:/etc/security/limits.conf添加两行"* soft nproc 4096\n* hard nproc 4096"
  • max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144](解决办法:sudo sysctl -w vm.max_map_count=262144(当前session有效),同时再修改配置文件echo "vm.max_map_count=262144" >>/etc/sysctl.conf(后续打开的session也有效))
  • java.lang.ClassNotFoundException: org.elasticsearch.plugin.analysis.AnalysisHanLPPlugin(解决办法:一般是HanLP没有正确打包,缺少了es-plugin-5.4.3.jar。正确的打包命令是gradle -p es-plugin jar buildPluginZip
  • SEVERE: 没有找到hanlp.properties,可能会导致找不到data(解决办法:因为没有把HanLP目录配置到CLASSPATH,/bin/elasticsearch.in.sh修改ES_CLASSPATH="$ES_HOME/lib/*:$ES_HOME/plugins/elasticsearch-hanlp/"
  • seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed(解决办法:elasticsearch.yml添加以下内容bootstrap.memory_lock: false bootstrap.system_call_filter: false
  • Native library (com/sun/jna/linux-x86/libjnidispatch.so) not found in resource path(解决办法:原因有很多,我遇到的问题是在64位Centos上安装了32位的JDK,重新安装64位JDK后,问题解决)

参考

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.10.26 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 部署环境
  • 组件准备
    • 下载ElasticSearch
      • 编译hanlp-ext
        • HanLP-1.3.4-offline-tar.gz
        • 安装ElasticSearch
          • 解压
            • 配置
              • 集群配置
              • HanLP配置
              • 系统设置
              • 启动
          • 常见问题
          • 参考
          相关产品与服务
          Elasticsearch Service
          腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档