1.下载elasticsearch https://www.elastic.co/cn/downloads/elasticsearch
2.解压,重命名
tar -xzvf elasticsearch-7.5.0-linux-x86_64.tar.gz mv elasticsearch-7.5.0 elasticsearch
3.修改jvm内存
cd elasticsearch/config vim jvm.options # 修改为内存的一半 -Xms16g -Xmx16g
4.配置 yml
cluster.name: dy_comment node.name: node_3 node.master: true node.data: true path.data: /data/download/elasticsearch/data path.logs: /data/download/elasticsearch/logs network.host: 0.0.0.0 http.port: 9190 discovery.seed_hosts: ["192.168.0.120","192.168.0.121","192.168.0.122"] cluster.initial_master_nodes: ["192.168.0.120","192.168.0.121","192.168.0.122"] http.cors.enabled: true http.cors.allow-origin: "*" indices.fielddata.cache.size: 8g bootstrap.memory_lock: true
5.配置data,logs 都在elasticsearch目录下,配置用户权限,es不能root启动
useradd elasticsearch
passwd elasticsearch
# 添加权限
chown -R elasticsearch:elasticsearch /data/download/elasticsearch
6.系统优化 vim /etc/security/limits.conf
* soft nofile 65536 * hard nofile 65536 * soft nproc 32000 * hard nproc 32000 * hard memlock unlimited * soft memlock unlimited
7.vim /etc/systemd/system.conf
DefaultLimitNOFILE=65536 DefaultLimitNPROC=32000 DefaultLimitMEMLOCK=infinity
/bin/systemctl daemon-reload # 使其生效
8.vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p 生效
使用supervisor 启动 es
command=su -c "/data/download/elasticsearch/bin/elasticsearch" elasticsearch