• Elasticsearch :单机安装


    ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。

    1、安装环境

    操作系统:centos6.9 x86_64

    JDK: 1.8

    Elasticsearch版本:Elasticsearch6.4.0

    2、安装elasticsearch 

    官网地址:https://www.elastic.co/products/elasticsearch

    ##下载

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz

    ##解压

    tar -xvf elasticsearch-6.4.0.tar.gz

    3、配置文件

    cd elasticsearch
    
    vi config/elasticsearch.yml
    
    ## 加入或修改下面的配置
    
    ## 设置自己的ip  不配置此ip默认只能在本机访问
    
    network.host: 测试用0.0.0.0 
    
    ## 用于head插件跨域访问用
    
    http.cors.enabled: true
    
    http.cors.allow-origin: "*"
    
    由于elasticsearch2.0以后禁止root启动(原因:ElasticSearch可以接收用户输入的脚本并且执行,出于系统安全考虑所以设置非root用户权限),因此建立一个es的用户
    
    ##增加es用户组
    
    groupadd es
    
    ##增加es用户
    
    useradd es -g es
    
    ##把elasticsearch-5.6.11文件夹权限赋予给es
    
    chown -R es:es elasticsearch

    4、切换es用户 登录

    elasticsearch-6.4.0/bin/elasticsearch

    5、错误解决(切换root权限)

    1、提示可分配es启动的内存不足,默认分配 2g启动内存
    [es@VM_0_15_centos local]$ Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory. # An error report file with more information is saved as: # /tmp/hs_err_pid27137.log
    解决方法:vim elasticsearch-5.6.11/config/jvm.options
    更改参数为:-Xmx512M 
    2、提示给es用户分配的线程资源不足 
    ERROR: bootstrap checks failed max file descriptors [
    10240] for elasticsearch process likely too low, increase to at least [65536] max number of threads [1024] for user [elsearch] likely too low, increase to at least [2048] max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
    解决方法:
    1)vim /etc/security/limits.conf 添加
    * soft nofile 65536
    
    * hard nofile 131072
    
    * soft nproc 2048
    
    * hard nproc 4096
    2)vi /etc/security/limits.d/90-nproc.conf 修改参数为
    * soft nproc 2048
    3)vi /etc/sysctl.conf 添加
    vm.max_map_count=655360
    并执行命令:sysctl -p
    3、生产模式改为单节点模式

    ERROR: [2] bootstrap checks failed
    [1]: initial heap size [31457280] not equal to maximum heap size [536870912]; this can cause resize pauses and prevents mlockall from locking the entire heap
    [2]: 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 添加

    discovery.type: single-node

    4、权限不足导致错误
    Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException: /usr/local/es/elasticsearch6.4/config/elasticsearch.keystore Likely root cause: java.nio.file.AccessDeniedException: /usr/local/es/elasticsearch6.4/config/elasticsearch.keystore
    解决方法:
    切换root用户,
    chown -R es:es es
  • 相关阅读:
    动态规划(下):如何求得状态转移方程并进行编程实现?
    SQL注入
    动态规划(上):如何实现基于编辑距离的查询推荐?
    XSS
    组合
    访问控制
    排列
    基于离散对数的签名方案
    基于RSA的签名方案
    centos7基于Hadoop的集群安装配置Hive
  • 原文地址:https://www.cnblogs.com/helloemk/p/9559236.html
Copyright © 2020-2023  润新知