ElasticSearch 部署注意事项
2019-12-08 本文已影响0人
ZhiXiong
一. 操作系统相关配置
1 创建用户和组并指定明确的 uid gid
-
关掉 swap
swapoff -a
卸载掉 swap 盘
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
sysctl -p -q
- 文件句柄,memory_lock,进程数限制配置
ulimit -n 65535
vim /etc/security/limits.conf
elastic soft nofile 196608
elastic hard nofile 196608
elastic soft memlock unlimited
elastic hard memlock unlimited
vim /etc/security/limits.d/20-nproc.conf
elastic soft nproc 4096
二.为了避免重启 ElasticSearch 集群,我们需要在部署时预留一些插槽
- 允许从其他集群 reindex,可以把内网网段配置上
reindex.remote.whitelist: "10.*:*"
- snapshot 目录配置
path.repo: ["/mnt/repo"]
- http 相关配置
http.cors.enabled: true
http.cors.allow-origin: "*"
http.max_initial_line_length: 8kb
三. 插件
- 预先安装必要的插件,比如 ik 分词器
- 为 ik 分词器配置远程 dict, 避免因为后续更新词库重启集群, 可以本地起一个 nginx
vim elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entry key="ext_dict"></entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords"></entry>
<!--用户可以在这里配置远程扩展字典 -->
<entry key="remote_ext_dict">http://127.0.0.1/dict/remote_ext_dict.txt</entry>
<!--用户可以在这里配置远程扩展停止词字典-->
<entry key="remote_ext_stopwords">http://127.0.0.1/dict/remote_ext_stopwords.txt</entry>
</properties>