美文网首页大数据学习笔记
ElasticSearch 优化配置

ElasticSearch 优化配置

作者: 9c0ddf06559c | 来源:发表于2018-02-06 19:40 被阅读53次

    索引建立优化

    {
      "settings": {
        // 副本数
        "number_of_replicas": 0,
        // 分片数
        "number_of_shards": 5,
        // 存储类型
        "index.store.type": "niofs",
        // 默认查询字段
        "index.query.default_field": "title",
        // 节点掉线延迟时间
        "index.unassigned.node_left.delayed_timeout": "5m"
      },
      "mappings": {
        "house": {
          // 非动态引擎
          "dynamic": "strict",
          // 不是对所有字段都查询索引
          "_all":{
            "enabled": false
          },
          "properties": {
            "houseId": {
              "type": "long"
            },
            "title": {
              "type": "text",
              "index": "analyzed",
              "analyzer": "ik_smart",
              "search_analyzer": "ik_smart"
            },
            "price": {
              "type": "integer"
            },
            "area": {
              "type": "integer"
            },
            "createTime": {
              "type": "date",
              "format": "strict_date_optional_time||epoch_millis"
            },
            "lastUpdateTime": {
              "type": "date",
              "format": "strict_date_optional_time||epoch_millis"
            },
            "cityEnName": {
              "type": "keyword"
            },
            "regionEnName": {
              "type": "keyword"
            },
            "direction": {
              "type": "integer"
            },
            "distanceToSubway": {
              "type": "integer"
            },
            "subwayLineName": {
              "type": "keyword"
            },
            "subwayStationName": {
              "type": "keyword"
            },
            "tags": {
              "type": "text"
            },
            "street": {
              "type": "keyword"
            },
            "district": {
              "type": "keyword"
            },
            "description": {
              "type": "text",
              "index": "analyzed",
              "analyzer": "ik_smart",
              "search_analyzer": "ik_smart"
            },
            "layoutDesc" : {
              "type": "text",
              "index": "analyzed",
              "analyzer": "ik_smart",
              "search_analyzer": "ik_smart"
            },
            "traffic": {
              "type": "text",
              "index": "analyzed",
              "analyzer": "ik_smart",
              "search_analyzer": "ik_smart"
            },
            "roundService": {
              "type": "text",
              "index": "analyzed",
              "analyzer": "ik_smart",
              "search_analyzer": "ik_smart"
            },
            "rentWay": {
              "type": "integer"
            },
            "suggest":{
              "type": "completion"
            },
            "location":{
              "type": "geo_point"
            }
          }
        }
      }
    }
    

    配置优化
    ./config/elasticsearch.yml

        // 禁用通配符删除
        "action.destructive_requires_name": true,
        # 刷新间隔
        "index.refresh_interval": "30s",
        # 节点间的存活检测间隔
        "discovery.zen.fd.ping_interval": "1s",
        # 存活超时时间
        "discovery.zen.fd.ping_timeout": "1s",
        # 存活超时重试次数
        "discovery.zen.fd.ping_retries": 3
        
    
       # node节点配置
        "node.master":true
        "node.data": false
        #  数据节点配置
        "node.master":false
        "node.data": true
    
        # 针对数据节点http功能关闭
        "http.enabled":false
    
        # 负载均衡节点配置(一般不用es的配置)
        
    

    ./config/jvm.options

    # 最小最大堆内存
    -Xms 
    -Mmx 
    

    nginx 负载均衡
    nginx.conf

    # 激活nginx core-module模块
    ./configure with-stream 
    
    ./
    stream{
       upstream_backend{
            server localhost:9300;
      }
    
      server {
          listen 9999;
          proxy_timeout 20s;
          proxy_pass backend 
      }
    }
    

    相关文章

      网友评论

        本文标题:ElasticSearch 优化配置

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