Elasticsearch单机部署
Elasticsearch单机部署
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
6.启动服务
su elsearch
cd /opt/elasticsearch-6.4.0/bin/
sh ./elasticsearch -d
7 访问验证:
curl http://192.168.0.102/9200