Elasticsearch 参数优化

1、JVM参数

-Xms2g # 最小堆内存,改为服务器内存的一半,如32G内存服务器,则配置16G-Xmx4g # 最大堆内存,改为服务器内存的一半,如32G内存服务器,则配置16G`修改垃圾回收器注释下面三行  #-XX:+UseConcMarkSweepGC  #-XX:CMSInitiatingOccupancyFraction=75  #-XX:+UseCMSInitiatingOccupancyOnly`添加  -XX:+UseG1GC  -XX:MaxGCPauseMillis=50

2、记录查询慢的日志

index.search.slowlog.level: INFO
index.search.slowlog.threshold.query.warn: 10s
index.search.slowlog.threshold.query.info: 5s
index.search.slowlog.threshold.query.debug: 2s
index.search.slowlog.threshold.query.trace: 500ms
index.search.slowlog.threshold.fetch.warn: 1s
index.search.slowlog.threshold.fetch.info: 800ms
index.search.slowlog.threshold.fetch.debug: 500ms
index.search.slowlog.threshold.fetch.trace: 200ms

index.indexing.slowlog.level: INFO
index.indexing.slowlog.threshold.index.warn: 10s
index.indexing.slowlog.threshold.index.info: 5s
index.indexing.slowlog.threshold.index.debug: 2s
index.indexing.slowlog.threshold.index.trace: 500ms

3、增大刷新时间(实时性不高可调整该参数)

index.refresh_interval: 20s
```

4、部分优化(根据服务器配置而定,其他线程池具体压测再添加)

a.修改elasticsearch.yml,

bootstrap.mlockall: trueindices.memory.index_buffer_size: 40%thread_pool:    write:
        size: 8(公式:cpu核数+1)
        queue_size: 4000    search:        size: 30(公式: 3*cpu核数/2 + 1)        queue_size: 1000        min_queue_size: 10        max_queue_size: 1000        auto_queue_frame_size: 2000        target_response_time: 1s
b.修改jvm.options配置,至少分配一半的内存给ES,最大31GB(理论上限32GB

5、.JDK改为ES自带的jdk

安装目录自带了jdk,下面路径写绝对路径,进入安装目录的bin目录,修改启动项elasticsearch顶部加入下面配置export JAVA_HOME=/home/db/elasticsearch-7.0.0/jdk/export PATH=$JAVA_HOME/bin:$PATHif [ -x "$JAVA_HOME/bin/java" ]; then    JAVA="/home/db/elasticsearch-7.0.0/jdk/"else    JAVA=`which java`fi

你可能感兴趣的:(elasticsearch,java,大数据,搜索引擎,全文检索)