zoukankan      html  css  js  c++  java
  • elasticsearch6.5.x-centos6

    elasticsearch6.5.x-centos6

    elasticsearch 和 关系型数据库中的类比

    es ====== RDBMS index ----- database type ------ table document ---- row field ----- field

    elasticsearch 集群概念介绍

    1. Node: 单个装有elasticsearch服务并且提供故障转移和扩展的服务器

    2. cluster: 一个集群就是由一个或多个node组织在一起,共同工作,共同分享整个数据具有负载功能的服务器群。

    3. Document :一个文档是一个可以被索引的基础信息单元

    4. Index : 索引就是一个拥有几分相似特征的文档的集合

    5. Type : 一个索引中,你可以定义一种或多种类型

    6. Field : Field是elasticsearch的最小单位,相当于数据的某一列。

    7. shards: elasticsearch将索引分成若干份,每个部分就是一个shards。

    8. Replicas :Replicas 是索引一份或者多分拷贝。

    RESTfull API

     GET          用来获取资源      
     POST         用来新建资源,也可以用于更新资源
     PUT         用于更新资源
     DELETE       用于删除资源

    curl 命令的简单使用

     # 访问一个网页
     curl www.baidu.com
     
     # 将响应的内容保存到指定文件中
     curl -o test.html www.baidu.com
     
     # 显示响应头的信息
     curl -i www.baidu.com
     
     # 显示HTTP的通信过程
     curl -v www.baidu.com
     
     # 执行 PUT/POST/GET/DELETE 操作
     curl -X GET/POST/PUT/DELETE url
     

    elasticsearch 6 on centos6 安装部署

    1. 安装java8

    2. 直接解压执行

     # 启动
     bin/elasticsearch
     
     # 后台启动
     bin/elasticsearch -d
     
     # 测试是否安装成功, 有数据返回表示安装成功
     curl localhost:9200
     
    1. 配置elasticsearch的远程访问

     /opt/modules/elasticsearch-6.5.0/config
     vim elasticsearch.yml
     # 修改主机地址,配置任何ip都可以访问
     network.host: 0.0.0.0
     
     # tcp port for transport client
     transport.tcp.port: 9300
     
     # http port for restful interface
     http.port: 9200
     
     
     # centos6不支持SecComp,启动时会检测失败,导致不能启动所以要添加
     bootstrap.memory_lock: false
     bootstrap.system_call_filter: false
     
     # 配置elasticsearch跨域访问
     http.cors.enabled: true
     http.cors.allow-origin: "*"
     
     # * 注意在yml文件中写配置的时候 :后面必须有空格,否则无法正确读取配置,导致启动失败
    1. 配置Linux

     vim /etc/sysctl.conf 
     在后面追加
     # elasticsearch config
     vm.max_map_count=655360
     
     
     修改完后需要立即生效一下,执行下面的命令
     /sbin/sysctl -p
     
     
     vim /etc/security/limits.d/test-limits.conf
     添加
       * soft nofile 65536
       * hard nofile 131072
       * soft nproc 4096
       * hard nproc 4096
     
     
     vim /etc/security/limits.conf
     # 在最后面追加下面内容
     *** hard nofile 65536
     *** soft nofile 65536
     *** soft nproc 4096
     *** soft nproc 4096
     
     # *** 是启动ES的用户
     
     
     ## 最后在浏览器中验证
     master:9200
     192.168.181.200:9200
     

     

    elasticsearch 配置中文IK分词器

     # 1. 使用es命令自动安装
     bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.1/elasticsearch-analysis-ik-6.5.1.zip
     
     -> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.1/elasticsearch-analysis-ik-6.5.1.zip
     [=================================================] 100%  
     -> Installed analysis-ik
     
     2. 自己下载,地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
     然后在将下载的zip包安装到elasticsearch-home/plugins/ik/目录下,是自己创建的存放分词器插件的文件夹
     [es6user@master ik]$ pwd
     /opt/modules/elasticsearch-6.5.1/plugins/ik
     [es6user@master ik]$ unzip elasticsearch-analysis-ik-6.5.1.zip
     
     

    安装中出现的问题

     # 不能直接使用root用户登录,可以通过添加配置解决,但是不推荐这么做,建议创建一个单独的用户来操作
     bin/elasticsearch -Des.insecure.allow.root=true
     或者修改elasticsearch脚本,添加:
     ES_JAVA_OPTS=*.-Des.insecure.allow.root=true*
     
     # 建议创建一个单独的用户来操作
     groupadd esgroup
     useradd esuser -g esgroup -p espassword
     cd /opt/modules
     chown -R esuser:esgroup elasticsearch-6.4
     su esuser
     

    ERROR

    Elasticsearch6.4修改配置文件./bin/elasticsearch.yml的network.host:0.0.0.0,启动报:max number of threads [2048] for user [es] is too low, increase to at least [4096]

     解决办法:
     新建(为方便删除)
                 /etc/security/limits.d/test-limits.conf
     
     添加
                 * soft nofile 65536
                 * hard nofile 131072
                 * soft nproc 4096
                 * hard nproc 4096
     
     

    Exception in thread "main" java.nio.file.AccessDeniedException: /root/home/searchengine/elasticsearch-6.2.4/config/jvm.options

     # 这个错误是因为没有执行权限
     chown -R abc:abc elasticsearch-6.4

    max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

     elasticsearch安装时遇到的错误
     
     问题翻译过来就是:elasticsearch用户拥有的可创建文件描述的权限太低,至少需要65536;
     
     解决办法:
     
     #切换到root用户修改
     vim /etc/security/limits.conf
     
     # 在最后面追加下面内容
     *** hard nofile 65536
     *** soft nofile 65536
     *** soft nproc 4096
     *** soft nproc 4096
     
     *** 是启动ES的用户
     

    ERROR: java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed

    启动中出现的异常: 原因:  因为Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动解决:修改elasticsearch.yml 添加一下内容 :

     bootstrap.memory_lock: false
     bootstrap.system_call_filter: false

     

     

     

     

     

     

  • 相关阅读:
    [转]项目管理---敏捷开发思想---带来相当愉快的项目开发过程
    [转] 项目管理---项目经理如何应对客户的需求变更?
    [转]C# 线程知识--使用Task执行异步操作
    [转]细说ASP.NET的各种异步操作
    [转]oracle表分区详解
    解决Asp.net 部署后弹出登陆框
    SVN客户端TortoiseSVN安装配置图文教程
    .net版本区别及发展历程
    CLR via c#读书笔记九:字符、字符串和文本处理
    CLR via c#读书笔记九:接口
  • 原文地址:https://www.cnblogs.com/nulijiushimeili/p/13866518.html
Copyright © 2011-2022 走看看