美文网首页
ElasticSearch

ElasticSearch

作者: 刘计计计 | 来源:发表于2017-06-10 22:31 被阅读0次

    Elasticsearch 简介

    Elasticsearch是最近两年异军突起的一个兼有搜索引擎和NoSQL数据库功能的开源系统,基于Java/Lucene构建。最近研究了一下,感觉Elasticsearch 的架构以及其开源的生态构建都有许多可借鉴之处,所以整理成文章分享下。本文的代码以及架构分析主要基于 Elasticsearch 2.X最新稳定版。
    Elasticsearch 看名字就能大概了解下它是一个弹性的搜索引擎。首先弹性隐含的意思是分布式,单机系统是没法弹起来的,然后加上灵活的伸缩机制,就是这里的 Elastic 包含的意思。它的搜索存储功能主要是 Lucene 提供的,Lucene 相当于其存储引擎,它在之上封装了索引,查询,以及分布式相关的接口。

    安装Elasticsearch

    tar zxvf elasticsearch-5.2.0.tar.gz
    mv elasticsearch-5.2.0 /usr/local/elasticsearch
    cd config
    vim jvm.options #修改配置
      -Xms4g
      -Xmx4g
      ##-Xms2g
      ##-Xmx2g
    cd bin
    ./elasticsearch #./elasticsearch -d 后端启动
    

    Elasticsearch的坑

    1. root账号运行,会出现以下错误:
    can not run elasticsearch as root  
    #解决:创建elsearch用户组及elsearch用户
    useradd elsearch
    passwd 
    chown -R elsearch  /usr/local/elasticsearch
    
    1. error2
    ERROR: bootstrap checks failed
    max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
    system call filters failed to install
    #解决:
    方法一:sysctl -w vm.max_map_count=262144
    方法二:vim  /etc/sysctl.conf  添加vm.max_map_count = 262144
    #测试
    sysctl -p
    sysctl -a | grep
    
    1. error3
    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
    解决方案:
    在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false
    

    4.error4

    max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
    解决方案:
    修改/etc/security/limits.conf文件,添加或修改如下行:
    hard nofile 65536
    soft nofile 65536
    

    5.error

     maybe these locations are not writable or multiple nodes were started without increasing 
    #信息:当前服务已启动,解决办法
    netstat -anp|grep 9200
    kill -9 进程id
    

    Elasticsearch 插件

    1. Elasticsearch-head是elasticsearch的一个集群管理工具>直接装在本地即可
    #首先在elasticsearch.yml配置文件中加入一下内容,然后重启服务。
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    git clone https://github.com/mobz/elasticsearch-head
    cd elasticsearch-head
    npm install -g grunt-cli #装grunt之前确保装有node
    npm install
    grunt server#此处要配置grunt的环境变量或者·/usr/local/nodejs/bin/grunt server·
    http://localhost:9100/
    

    相关文章

      网友评论

          本文标题:ElasticSearch

          本文链接:https://www.haomeiwen.com/subject/ulvcqxtx.html