ElasticSearch插入数据优化
来源:互联网 发布:mac尝试靠近无线路由器 编辑:程序博客网 时间:2024/05/10 21:27
1、多线程程序插入
可以根据服务器情况开启多个线程index,速度可以提高n倍, n>=2。如在上篇博文《将Mysql数据导入到ElasticSearch集群》示例的代码,开启了10个线程。但是可以线程也不是越多越好,要根据你磁盘的io,cpu等而定。
2、设置复制分片数量
如果有多台机器,可以以每台设置n个shards的方式,根据业务情况,可以考虑取消replias(复制分片),等数据插入结束以后再进行更新操作,设置复制分片。此方法可使插入速度提高一倍。但要注意,主分片的数量是不可以更改的。
curl -XPUT 'http://xxxxx:9400/index_rfm_test/' -d '{ "settings" : { "number_of_shards" : 20, "number_of_replicas" : 0 } }' //数据插入结束,更新复制分片为1curl -XPUT 'http://xxxxx:9400/index_rfm_test/_settings' -d '{"index":{"number_of_replicas":1}}'
3、提高ES占用内存
内存适当调大,初始是256M,最大1G, 调大后,最小和最大一样,避免GC, 并根据机器情况,设置内存大小。
$ bin/elasticsearch -f -Xmx4g -Xms4g -Des.index.storage.type=memory
原文:http://www.elasticsearch.org/guide/reference/setup/installation.html
4、减少shard刷新间隔
curl -XPUT 'http://xxxxx:9400/index_rfm_test/_settings' -d '{ "index" : { "refresh_interval" : "-1" } }' //完成插入后再修改为初始值 curl -XPUT 'http://xxxxx:9400/index_rfm_test/_settings' -d '{ "index" : { "refresh_interval" : "1s" } }'
5、设置一个shard的段segment最大数
//可以减少段文件数,提高查询速度 curl -XPUT 'http://xxxxx:9400/index_rfm_test/_optimize?max_num_segments=5' //强制mergercurl -XPOST 'http://xxxxx:9400/index_rfm_test/_forcemerge?max_num_segments=1&only_expunge_deletes=true'
注意:有时候可能需要多次执行
原文:http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html
原文:http://www.elasticsearch.org/guide/reference/index-modules/merge.html
6、去掉mapping中_all域
Index中默认会有_all的域,这个会给查询带来方便,但是会增加索引时间和索引尺寸
"_all" : {"enabled" : false}
原文:http://www.elasticsearch.org/guide/reference/mapping/all-field.html
7、适当增大节点threadpool参数
curl -XPUT 'http://xxxxx:9400/_cluster/settings' -d '{"transient":{"threadpool.index.queue_size":5000,"threadpool.bulk.queue_size": 5000}}'
- ElasticSearch插入数据优化
- ElasticSearch插入数据
- elasticsearch插入数据
- ElasticSearch插入数据问题
- elasticsearch 大数据优化
- (五)ElasticSearch插入数据
- Elasticsearch java api 插入数据
- 优化MySQL插入数据
- jdbc插入数据优化
- Mysql 插入数据优化
- 批量插入数据优化
- 使用Python往Elasticsearch插入数据
- elasticsearch 创建type及插入数据
- elasticsearch中数据的插入与查询
- elasticsearch使用java api批量插入数据
- java操作nsq数据插入elasticsearch
- 初识pyes(实现elasticsearch数据的插入)
- hibernate批量数据插入优化
- Java NIO和IO的区别
- 自制冰箱,冰柜蒸发器和毛细管的速算
- maven打包时加入依赖包及加入本地依赖包
- B树、B-树、B+树、B*树都是什么
- kafka常用简单命令记录
- ElasticSearch插入数据优化
- methods之学习源代码
- Linux 目录结构
- httppost 200、300、400、500 错误分析,HttpPost、HttpGet关于URL重定向区别
- iOS开发-搜索栏UISearchBar和UISearchController
- iOS--对勾提示动画
- 不同storyboard之间的跳转
- 移植dhclient到arm linux
- 工作学习生活计划