欢迎投稿

今日深度:

ElasticSearch安装文档,elasticsearch文档

ElasticSearch安装文档,elasticsearch文档


ElsticSearch安装

  • ElasticSearch安装文档
    • 引言
      • ElasticSearch介绍
      • 部署准备
      • elasticSearch部署步骤
      • 配置信息
      • 插件安装
      • es-java api 调用

ElasticSearch安装文档

引言

此文档是基于ElasticSearch5.4.2版本的部署文档,旨在说明ElasticSearch的安装部署步骤,作为后续ElasticSearch的安装部署参考。

ElasticSearch介绍


ElasticSearch是业界最流行的开源搜索引擎,基于apache-luncene的开源实现,同类比和apache-solr有很多相似处,但在部署、可扩展性和功能方面有差异。

ElasticSearch和solr在使用场景也有不一样的针对性,ElasticSearch基于json格式的数据配置,而solr基于schema格式的配置,在使用场景上,ElasticSearch更偏向于查询、过滤和分组分析统计方面,他支持range、关联的查询;而solr更加偏向于文本的全文检索;对于高级检索的支持并没有那么强。

部署准备


ElasticSearch安装,包括插件的支持需要以下的依赖:

  • elasticsearch.tar
  • node.js
  • jdk8
  • ecs

elasticSearch部署步骤


配置信息


  • 基本配置

      cluster.name: elasticsearch        #集群名称(集群名称需配置成一致)
      node.name: es-node-01              #节点名称
      node.master: true                    #是否是master节点(集群环境下配置)
      node.data: true                       #是否是数据节点
      path.data: /usr/local/es-5.4/data  #数据文件存储路径
      path.logs: /usr/local/es-5.4/logs  #日志文件存储路径
      network.host: 192.168.1.23         #对外暴露的IP地址
      http.port: 9200                    #es的http访问端口
      http.cors.enabled: true            #http跨域访问设置
      http.cors.allow-orign: "*"         #请求访问限制,*为不限制
      discovery.zen.ping.unicast.hosts: ["192.168.11.11", "192.168.11.12"]   #集群节点列表配置
      discovery.zen.ping_timeout: 120s   #集群节点ping值超时时间配置
    
  • 系统调优

ElasticSearch在使用上需要对系统参数进行调优处理,以满足es的日常应用

插件安装


ElasticSearch支持很多插件安装,包括kibana监控、ElasticSearch-sql支持、ElasticSearch-head插件,此处,仅介绍ElasticSearch-head插件安装;head插件是一个基于node.js的ElasticSearch的UI管理界面,基于此插件,我们可以在head界面中:

es-java api 调用


  • maven依赖

       <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
      <dependency>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-core</artifactId>
          <version>6.6.0</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-highlighter -->
      <dependency>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-highlighter</artifactId>
          <version>6.6.0</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queries -->
      <dependency>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-queries</artifactId>
          <version>6.6.0</version>
      </dependency>
    
  • java代码

          Settings settings = Settings.builder().put("client.transport.sniff", true).
              put("client.transport.ignore_cluster_name", false).put("cluster.name","es-cluster").build();
          TransportClient client = new PreBuiltTransportClient(settings).
          addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.11.11"),9300))
          .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.11.12"),9300));
          Map<String, Object> map = new HashMap<String, Object>();
          Random ran = new Random();
          map.put("nickname", "测试" + ran.nextInt(100));
          map.put("sex", ran.nextInt(100));
          map.put("age", ran.nextInt(100));
          map.put("mobile", "15014243232");
          IndexResponse response = client.prepareIndex("users", "user").setSource(map).get();
          System.out.println(response);
    

www.htsjk.Com true http://www.htsjk.com/Elasticsearch/24947.html NewsArticle ElasticSearch安装文档,elasticsearch文档 ElsticSearch安装 ElasticSearch安装文档 引言 ElasticSearch介绍 部署准备 elasticSearch部署步骤 配置信息 插件安装 es-java api 调用 ElasticSearch安装文档 引言 此文...
相关文章
    暂无相关文章
评论暂时关闭