原文链接:https://blog.csdn.net/zhanyu1/article/details/88927194
es中的elasticsearch.yml配置文件,如果bootstrap.memory_lock这项使用默认配置,会导致硬盘频繁读,IOPS变高。
添加这一项
bootstrap.memory_lock: true
这个配置的意义:锁定物理内存地址,防止es内存被交换出去,也就是避免es使用swap交换分区,频繁的交换,会导致IOPS变高。
设置好后,启动es会报错:
ERROR: [1] bootstrap checks failed [1]: memory locking requested for elasticsearch process but memory is not locked
解决办法:
需要设置下系统配置文件,首先要切换到root用户,接着做以下修改:
1、修改/etc/security/limits.conf
文件最后添加以下内容:
扫描二维码关注公众号,回复:
7076169 查看本文章
* soft nofile 65536 * hard nofile 65536 * soft nproc 32000 * hard nproc 32000 * hard memlock unlimited * soft memlock unlimited
2、修改/etc/systemd/system.conf
分别修改以下内容:
DefaultLimitNOFILE=65536 DefaultLimitNPROC=32000 DefaultLimitMEMLOCK=infinity
3、执行以下操作,立即生效
/bin/systemctl daemon-reload
对于小系统应用es的优化和建议:
建议用SSD,提高性能;
新建索引的时候,分片设置成1,备份设置成0,能有效的降低IOPS;
可以参考以下配置:
put http://localhost:9200/test/ { “settings”: { “number_of_shards”: 1, “number_of_replicas”: 0, “index.analysis.analyzer.default.type”: “ik_max_word” }, “mappings”: { “my”: { “properties”: { “id”: { “type”: “long” }, “name”: { “type”: “text” }, “content”: { “type”: “text” } } } } }