Elasticsearch调优

2019-09-21  本文已影响0人  Okami_

系统参数

*               soft    nofile          65535
*               hard    nofile          65535
  *               soft    nproc           4096
  *               hard    nproc           4096
vm.max_map_count=262144
es soft memlock unlimited
es hard memlock unlimited
es soft memlock unlimited
es hard memlock unlimited
vm.swappiness=0

elasticsearch.yml

# 集群的名称,同一个集群该值必须设置成相同的
cluster.name: demo-application
# 该节点的名字
node.name: node-1
# 内存锁定
bootstrap.memory_lock: true
#该节点有机会成为master节点
node.master: true
# 该节点可以存储数据
node.data: true
# 设置绑定的IP地址,可以是IPV4或者IPV6
network.bind_host: 0.0.0.0
# 设置其他节点与该节点交互的IP地址
network.publish_host: 191.168.1.100
# 该参数用于同时设置bind_host和publish_host
network.host: 191.168.1.100
# 设置节点之间交互的端口号
transport.tcp.port: 9300
# 设置是否压缩tcp上交互传输的数据
transport.tcp.compress: true
# 设置对外服务的http端口号
http.port: 9200
# 设置http内容的最大大小
http.max_content_length: 100mb
# 是否开启http服务对外提供服务
http.enabled: true 
# 设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点,建议设置(n/2)+1, 防止脑裂问题
discovery.zen.minimum_master_nodes: 2
# 设置集群中自动发现其他节点时ping连接的超时时间
discovery.zen.ping_timeout: 30s
# 设置是否打开多播发现节点
#discovery.zen.ping.multicast.enabled: false
# 置集群中的Master节点的初始列表,可以通过这些节点来自动发现其他新加入集群的节点
discovery.zen.ping.unicast.hosts: ["191.168.1.100:9300","191.168.1.101:9300","191.168.1.102:9300"]

# 是否支持跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

jvm.options

# 初始的Heap的大小,与Xmx的值保持一致
-Xms8g
# 最大Heap的大小,与Xms的值保持一致
-Xmx8g 

# 修改默认的垃圾回收机制CMS为G1
#-XX:+UseConcMarkSweepGC
#-XX:CMSInitiatingOccupancyFraction=75
#-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200

全量导入数据准备操作

curl -H "Content-Type:application/json" -XPUT 'http://master:9200/cmas/_settings' -d '{"index": {"number_of_replicas":0}}'
curl -H "Content-Type:application/json" -XPUT 'http://master:9200/cmas/_settings' -d '{"index": {"number_of_replicas":1}}'

索引优化

合理设置分片

合理设置副本数

合并索引

关闭索引

curl -u elastic:123456 -XPOST 'master:9200/test/_close'

清除删除文档

curl -u elastic:123456 -XPOST 'http://master:9200/test/_optimize?only_expunge_deletes=true

合理数据导入

curl -XGET http://master:9200/test/_settings?pretty
curl -H "Content-Type:application/json" -XPUT 'http://master:9200/test/_settings' -d '{"index": {"number_of_replicas":0}}'
curl -H "Content-Type:application/json" -XPUT 'http://master:9200/test/_settings' -d '{"index": {"number_of_replicas":1}}'

设置索引_all

PUT /my_index
{
    "mapping": {
        "user": {
            "_all": {
                "enable": false
            }
        }   
    }
}

设置索引_source

版本一致

问题处理

集群脑裂问题

翻页问题

PUT /my_index/_settings
{
  "index": {
    "max_result_window": 50000
  }
}
上一篇 下一篇

猜你喜欢

热点阅读