zoukankan      html  css  js  c++  java
  • elasticsearch6.6及其插件安装记录(较详细)

    借鉴网上资料并实施验证结果

    elasticsearch6.6安装

    安装包下载路径

    https://www.elastic.co/downloads/elasticsearch

    本文使用安装包

    elasticsearch-6.6.0.tar.gz

    系统

    Centos 6

    安装

    解压路径

    /opt/elasticsearch-6.6.0

    jdk1.8(原系统很多项目是用的jdk1.7的,保持不变,新源码装jdk1.8至目录/opt/jdk1.8)

    一.修改es的jdk环境变量(es6.x需要jdk1.8版本)

    vim ./bin/elasticsearch-env
    
    添加并修改如下:
    
    JAVA_HOME_1="/opt/jdk1.8"
    
    并修改原JAVA_HOME为JAVA_HOME_1

    如下图:

    二.修改初始分配jvm内存大小

    vim ./config/jvm.options
    -Xms512m
    -Xmx512m

    三.修改es配置文件

    vim ./config/elasticsearch.yml
    
    cluster.name: test
    node.name: test-1
    path.data: /opt/elasticsearch-6.6.0/data
    path.logs: /opt/elasticsearch-6.6.0/logs
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false
    network.host: 0.0.0.0
    http.port: 9400
    
    #启用http配置
    http.cors.enabled: true
    http.cors.allow-origin: "*"

    部分重要配置文件说明:

    1.cluster.name:test

    配置elasticsearch的集群名称,elasticsearch会自动发现在同一网段下的集群名为test的主机,如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。生产环境时建议更改。

    2.node.name: test-1

     节点名,生产环境中建议更改以能方便的指定集群中的节点对应的机器

    3.path.data: /opt/elasticsearch-6.6.0/data

    设置索引数据的存储路径,默认是es根目录下的data文件夹,可以设置多个存储路径,用逗号隔开。

     四.权限与启动,es6.x不允许root用户启动es(启动问题及解决见文章末)

    useradd elsearch
    passwd elsearch
    chown -R elsearch.elsearch elasticsearch-6.6.0
    su elsearch
    cd /opt/elasticsearch-6.6.0
    #测试登陆es,如果后台报错解决办法在文末
    ./bin/elasticsearch

     登陆浏览器测试,没问题再退出程序,继续下一步

    五.安装插件head

    1.nodejs安装  (由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包)

    官网下载地址: https://nodejs.org/en/download/

    本次使用的源码包是:node-v8.9.0-linux-x64.tar.gz (最新已经更新到v10版本了,为了防止一些版本兼容问题,我还是按照网上博客版本来的)

    #解压并重命名路径

    /opt/node

    #本文也没有通过修改环境变量的方式,直接通过软链接来使用命令

    ln -s /opt/node/bin/node /usr/bin/node
    ln -s /opt/node/bin/npm /usr/bin/npm

    #设定nodejs安装软件的代理服务器

    npm config set registry https://registry.npm.taobao.org

    #执行npm,安装grunt (grunt是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等工作,elasticsearch-head插件就是通过grunt启动的)

    npm install -g grunt
    npm install -g grunt-cli

    #创建 grunt软链接

    ln -s /opt/node/bin/grunt /usr/bin/grunt

    2.phantomjs安装

    #官网下载地址 

    https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2

    #解压并重命名路径

    /opt/phantomjs

    #安装依赖

    yum -y install wget fontconfig

    #创建phantomjs软链接

    ln -s /opt/phantomjs/bin/phantomjs /usr/bin/

    #测试

    [root@danny phantomjs]# phantomjs
    phantomjs> 

    3.安装head

     下载路径

    https://github.com/mobz/elasticsearch-hea

    #安装unzip解压工具(如果没有unzip,就需要安装这个)

    yum install -y unzip

    #解压文件到 head

    unzip elasticsearch-head-master.zip

    #进入head的目录

    cd elasticsearch-head-master/

    #安装一下这个bzip2 ,如果没有,在编译head,会报错

    yum install -y bzip2

    #更换npm源

    npm install -g cnpm --registry=https://registry.npm.taobao.org

    #安装(进入 elasticsearch-head-master)的目录,执行安装命令

    npm install

    注意:此时可能会报错如下:

    #执行以下安装命令即可

    npm -g install phantomjs-prebuilt@2.1.16 --ignore-script

    #配置head,默认端口号是9100,此处改一下测试

    vim Gruntfile.js
     connect: {
                            server: {
                                    options: {
                                            hostname:'0.0.0.0',   //此处是添加段
                                            port: 9101,
                                            base: '.',
                                            keepalive: true
                                    }
                            }
                    }

    #后台启动head服务

    grunt server &

    #或者使用官网启动方式

    npm run start &

    如图

    备注:网页验证需要es启用http配置,如上config/elasticsearch.yml添加的http配置

    #后台启动es

    [root@danny elasticsearch-6.6.0]# ./bin/elasticsearch -d

    测试

    es访问测试

    head访问测试

     感谢:https://blog.csdn.net/yelllowcong/article/details/78787012

    六.插件ik分词器的安装

    1.下载地址 https://github.com/medcl/elasticsearch-analysis-ik/releases

    注:分词器版本一定要与ES版本保持一致

    2.安装

    将安装包直接上传至es的插件目录解压即可

    cd /opt/elasticsearch-6.6.0/plugins
    mkdir ik
    unzip elasticsearch-analysis-ik-6.6.0.zip
    rm -rf elasticsearch-analysis-ik-6.6.0.zip
    
    #再打开elasticsearch-6.6.0/config下的jvm.options,在最后面加上一行: 
    -Djava.security.policy=/opt/elasticsearch-6.6.0/plugins/ik/plugin-security.policy
    
    #重启
    su elsearch
    cd /opt/elasticsearch-6.6.0
    ./bin/elasticsearch -d

    3.测试ik插件(通过head插件测试)

    1)查看日志看是否已经加载analysis-ik

    2)登录head上验证查看

    4.注意

    ES6.0与ik6.0进行集成安装之后,只能通过head工具来进行测试,通过url进行测试的时候会报错,这是一个bug已经提交到gethub上了

    问题

     搭建过程遇到过的坑(主要是系统设置问题)
    启动es报错:

    1.

    max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    vim /etc/sysctl.conf
    vm.max_map_count = 262144  //添加

    2.

    ERROR: bootstrap checks failed
    system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
    vim config/elasticsearch.yml
    #添加下面两个
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false

    原因:
    这是在因为Centos6不支持SecComp,而es6.x默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致es不能启动。

    原因解释出处:https://github.com/elastic/elasticsearch/issues/22899

    3.

    java.lang.RuntimeException: can not runelasticsearch as root

    这是因为es6.x为了安全考虑,已经不让root启动,2.x版本的还有解决办法,修改bin中的启动文件可实现root启动,但是后续版本已经没用了

    解决办法:

    useradd elsearch
    passwd elsearch
    chown -R elsearch.elsearch elasticsearch-6.6.0
    su elsearch
    cd /opt/elasticsearch-6.6.0
    ./bin/elasticsearch -d

    4.

    max file descriptors [65535] for elasticsearchprocess is too low, increase to at least [65536]

    maxfile descriptors为最大文件描述符,设置其大于65536即可

    vim /etc/security/limits.conf
    * - nofile 65536
    * - memlock unlimited

    5.

    ERROR: [3] max number of threads [1024] for user [elsearch] is too low, increase to at least [4096]

    vim /etc/security/limits.d/90-nproc.conf
     *          soft    nproc     4096

    注销用户,重新登录生效

  • 相关阅读:
    解决UITableView中Cell重用机制导致内容出错的方法总结
    Hdu 1052 Tian Ji -- The Horse Racing
    Hdu 1009 FatMouse' Trade
    hdu 2037 今年暑假不AC
    hdu 1559 最大子矩阵
    hdu 1004 Let the Balloon Rise
    Hdu 1214 圆桌会议
    Hdu 1081 To The Max
    Hdu 2845 Beans
    Hdu 2955 Robberies 0/1背包
  • 原文地址:https://www.cnblogs.com/dannylinux/p/10382205.html
Copyright © 2011-2022 走看看