1. 安装Elasticsearch,从官网下载,
也可使用 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
2. 解压缩 tar -zxvf elasticsearch-6.2.4.tar.gz
3. 移动到opt下:mv elasticsearch-6.2.4 /opt/elasticsearch
4. elasticsearch不能使用root用户启动,需新创建新用户,
root#groupadd elastic
root#useradd elastic
root#passwd elastic
授权 chown -R elastic /opt/elasticsearch
5. 修改配置文件:
vim /opt/elasticsearch/config/elasticsearch.yml
cluster.name: elasticsear-test
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
6. 启动elasticsearch:/opt/elasticsearch/bin/elasticsearch
如果出错:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
切换到root用户:vim /etc/security/limits.conf, 添加
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
添加之后需要重新切换一下用户
如果出错:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
切换到root用户:
cat /etc/sysctl.conf |grep -v "vm.max_map_count"
cat /etc/sysctl.conf |grep -v "vm.max_map_count" > /tmp/systemd-sysctl.conf
echo "vm.max_map_count=262144" >> /tmp/systemd-sysctl.conf
mv /tmp/systemd-sysctl.conf /etc/sysctl.conf
7. 防火墙添加例外:
firewall-cmd --add-port=9200/tcp --permanent --zone=public
firewall-cmd --reload