1.下載安裝包
下載地址:https://www.elastic.co/downloads/elasticsearch
我這里下載的是 elasticsearch-6.4.0.tar.gz
保存至/opt目錄下
cd /opt
tar -zxvf elasticsearch-6.4.0.tar.gz
2.創建用戶elsearch,用戶組elsearch
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
3.修改文件權限
cd /opt/
chown -R elsearch:elsearch elasticsearch-6.4.0
4.修改配置文件
cd /opt/elasticsearch-6.4.0/config/
vim elasticsearch.yml
修改以下配置:
#集群名稱,建議修改成自己的,防止誤用默認集群
cluster.name: elasticsearch
#配置外網可以訪問
network.host: 0.0.0.0
#單節點需要修改配置
cluster.initial_master_nodes: ["node-1"]
追加配置文件:
echo "bootstrap.memory_lock: false" >> /opt/elasticsearch-6.4.0/config/elasticsearch.yml
echo "bootstrap.system_call_filter: false" >> /opt/elasticsearch-6.4.0/config/elasticsearch.yml
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 131072" >> /etc/security/limits.conf
echo "* soft nproc 4096" >> /etc/security/limits.conf
echo "* hard nproc 4096" >> /etc/security/limits.conf
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
保存后執行
sysctl -p
5.配置jvm內存大小
cd /opt/elasticsearch-6.4.0/config/
修改文件jvm.options
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms8g
-Xmx8g
echo "export ES_HEAP_SIZE=8g" >> /opt/elasticsearch-6.4.0/bin/elasticsearch
切換目錄:cd /opt/elasticsearch-6.4.0/bin/
執行配置生效:
source "`dirname "$0"`"/elasticsearch-env
5.啟動服務
su elsearch
cd /opt/elasticsearch-6.4.0/bin/
sh ./elasticsearch -d
6 訪問驗證:
curl http://192.168.0.102/9200
