ES2.X版本
1、提高写入速度
更新刷磁盘间隔,提高写入效率
curl -XPUT http://localhost:9200/syslog-2016.07.22/_settings -d '{"index" : {"refresh_interval" : "5s"} }'
获取setting信息
curl -XGET http://localhost:9200/syslog-2016.07.22/_settings
2、默认30分钟进行一下flush,或者当translog文件大于512MB时主动进行一次flush,可以通过index.translog.flush_threshold_period和
index.translog.flush_threshold_size参数修改
如果对以上两个参数不满意,还可以设置index.translog.flush_threshold_ops参数,控制每收到多少条数据flush一次
3、归并线程配置,默认情况下是20MB归并一次,频繁写入的情况下可以优化为100mb归并一次
curl -XPUT http://localhost:9200/syslog-2016.07.22/_settings -d '{"persistent" : {"indices.store.throttle.max_bytes_per_sec" : "100mb"}}'
curl -XPUT http://localhost:9200/_cluster/_settings -d '{"persistent" : {"indices.store.throttle.max_bytes_per_sec" : "100mb"}}'
curl -XPUT http://localhost:9200/_cluster/settings -d '{
"persistent": {
"indices.store.throttle.type": "merge",
"indices.store.throttle.max_bytes_per_sec": "100mb"
}
}'
4、index.refresh_interval:30s #设置刷新间隔
5、indices.ttl.interval:14400 #定期删除
6、index.translog.flush_threshold_size:500 #日志文件大小设置
7、设置搜索线程大小
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"threadpool.search.queue_size" : 2000
},
"transient" : {
"threadpool.search.queue_size" : 2000
}
}'
8、查看集群设置
curl -XGET localhost:9200/_cluster/settings
9、设置内存缓存大小,达到60%开始刷盘
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.fielddata.cache.size" : "60%"
}
}'
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.breaker.fielddata.limit" : "60%"
}
}'
10、数据迁移导入优化参数
#导入数据时可以用这个参数
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.store.throttle.type" : "none"
}
}'
#SSD优化参数
#elasticsearch.yml:
index.merge.scheduler.max_thread_count: 3
#增大内存缓冲区
indices.memory.index_buffer_size: 30%
index.memory.scheduler.max_merge_count: 6
#当translog的大小达到此值时会进行一次flush操作.默认是512mb
index.translog.flush_threshold_size: 5gb
#当发生多少次操作时进行一次flush.默认是 unlimited
index.translog.flush_threshold_ops: 500000
#多少时间进行一次的写磁盘操作,默认是5s
index.gateway.local.sync: 30s
index.refresh_interval: 30s
11、节点策略
es.batch.size.bytes
关闭文件系统ATIME
N台机器做热数据的存储,上面只放当天的数据。elasticsearch.yml中配置node.tag:hot
之前的数据放在另外的M台机器上。这M台冷数据节点的配置,node.tag:stale
elasticsearch.yml中配置
#读写分离
{
"order" : 0,
"template" : "*",
"settings" : {
"index.routing.allocation.require.tag" : "hot"
}
}
每天计划任务更新索引的配置,将tag更改为stale,索引会自动迁移到M台冷数据节点
curl -XPUT 10.1.15.15"9200/syslog-*/_settings -d '{
"index" : {
"routing": {
"require": {
"tag" : "stale"
}
}
}
}'
1、提高写入速度
更新刷磁盘间隔,提高写入效率
curl -XPUT http://localhost:9200/syslog-2016.07.22/_settings -d '{"index" : {"refresh_interval" : "5s"} }'
获取setting信息
curl -XGET http://localhost:9200/syslog-2016.07.22/_settings
2、默认30分钟进行一下flush,或者当translog文件大于512MB时主动进行一次flush,可以通过index.translog.flush_threshold_period和
index.translog.flush_threshold_size参数修改
如果对以上两个参数不满意,还可以设置index.translog.flush_threshold_ops参数,控制每收到多少条数据flush一次
3、归并线程配置,默认情况下是20MB归并一次,频繁写入的情况下可以优化为100mb归并一次
curl -XPUT http://localhost:9200/syslog-2016.07.22/_settings -d '{"persistent" : {"indices.store.throttle.max_bytes_per_sec" : "100mb"}}'
curl -XPUT http://localhost:9200/_cluster/_settings -d '{"persistent" : {"indices.store.throttle.max_bytes_per_sec" : "100mb"}}'
curl -XPUT http://localhost:9200/_cluster/settings -d '{
"persistent": {
"indices.store.throttle.type": "merge",
"indices.store.throttle.max_bytes_per_sec": "100mb"
}
}'
4、index.refresh_interval:30s #设置刷新间隔
5、indices.ttl.interval:14400 #定期删除
6、index.translog.flush_threshold_size:500 #日志文件大小设置
7、设置搜索线程大小
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"threadpool.search.queue_size" : 2000
},
"transient" : {
"threadpool.search.queue_size" : 2000
}
}'
8、查看集群设置
curl -XGET localhost:9200/_cluster/settings
9、设置内存缓存大小,达到60%开始刷盘
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.fielddata.cache.size" : "60%"
}
}'
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.breaker.fielddata.limit" : "60%"
}
}'
10、数据迁移导入优化参数
#导入数据时可以用这个参数
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.store.throttle.type" : "none"
}
}'
#SSD优化参数
#elasticsearch.yml:
index.merge.scheduler.max_thread_count: 3
#增大内存缓冲区
indices.memory.index_buffer_size: 30%
index.memory.scheduler.max_merge_count: 6
#当translog的大小达到此值时会进行一次flush操作.默认是512mb
index.translog.flush_threshold_size: 5gb
#当发生多少次操作时进行一次flush.默认是 unlimited
index.translog.flush_threshold_ops: 500000
#多少时间进行一次的写磁盘操作,默认是5s
index.gateway.local.sync: 30s
index.refresh_interval: 30s
11、节点策略
es.batch.size.bytes
关闭文件系统ATIME
N台机器做热数据的存储,上面只放当天的数据。elasticsearch.yml中配置node.tag:hot
之前的数据放在另外的M台机器上。这M台冷数据节点的配置,node.tag:stale
elasticsearch.yml中配置
#读写分离
{
"order" : 0,
"template" : "*",
"settings" : {
"index.routing.allocation.require.tag" : "hot"
}
}
每天计划任务更新索引的配置,将tag更改为stale,索引会自动迁移到M台冷数据节点
curl -XPUT 10.1.15.15"9200/syslog-*/_settings -d '{
"index" : {
"routing": {
"require": {
"tag" : "stale"
}
}
}
}'