架构层面
- 在logstash shipper和index之间增加redis或kafaka代理缓存
Elasticsearch
ES系统性能
让JVM使用OS的max-open-files
ulimit -n 1000000 es_parms="-Delasticsearch -Des.max-open-files=ture"
增加ES JVM内存大小,至少2G,越大越好
修改elasticsearch.yml配置文件
#锁定内存不使用swap bootstrap.mlockall: true
ES索引性能
索引配置
#关闭副本 index.number_of_shards: 1 index.number_of_replicas: 0 #加大translog刷新频率 index.translog.flush_threshold_ops: 10000 #加大index刷新频率,不指定单位默认为ms,1s=1秒 index.refresh_interval: 10s
自定义templates
按type自定义字段,不用存储的字段不用存储,不用索引的字段不要索引,常用聚合字段开启doc_values属性"somesfield": { "type": "string", "index": "no", "store": false, "dynamic": "strict", "doc_values": true, "fielddata": { "format": "doc_values" } }
上面这个字段将不会被存储,不会被索引,但是会以doc_values方式保存在磁盘上参加聚合运算。
也可以在模板中设置_ttl过期时间:
curl -XPUT http://localhost:9200/_template/logstash { "template" : "logstash*", "order": 99, "mappings": { "3alogic": { "_ttl": { "enabled": true, "default": "30d" } } } }
上面3alogic类型的文档在30天后自动删除。
ES详细安装配置参见:http://blog.csdn.net/jiao_fuyou/article/details/46694125
logstash
增加filter worker数
filter是很占用内存和CPU的,适当加大filter worker numberbin/logstash agent -w 6 -f /home/jfy/soft/logstash-1.4.2/lib/logstash/config/shipper.conf1.4.2/logs/logstash.log
为filter开启6个线程
output => elasticsearch 批量参数调整
- flush_size 批量写入ES数量
- idle_flush_time 批量写入ES频率
详情参见:http://blog.csdn.net/jiao_fuyou/article/details/49589425