官網(wǎng)下載軟件
解壓文件
tar -zxvf elasticsearch-5.6.1.tar.gz -C /usr
重要提示:因?yàn)?Elasticsearch 可以執(zhí)行腳本文件,為了安全性,默認(rèn)不允許通過 root 用戶啟動(dòng)服務(wù)。我們需要新創(chuàng)建用戶名和用戶組啟動(dòng)服務(wù)
修改配置文件
1.默認(rèn)情況下,Elasticsearch 只允許本機(jī)訪問,如果需要遠(yuǎn)程訪問,需要修改其配置文件
vim config/elasticsearch.yml
# 去掉 network.host 前邊的注釋,將它的值改成0.0.0.0
network.host: 0.0.0.0
2.啟動(dòng)報(bào)錯(cuò):max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
#使用root命令行鍵入
ulimit -n 65536
3.啟動(dòng)報(bào)錯(cuò):max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vim /etc/sysctl.conf
#加入以下配置
vm.max_map_count=262144
保存,并執(zhí)行 sysctl -p
4.啟動(dòng)時(shí)報(bào)錯(cuò):max number of threads [3895] for user [elk] is too low, increase to at least [4096]
/etc/security/limits.d/20-nproc.conf
#修改后的配置文件
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 4096
* hard nproc 4096
root soft nproc unlimited
5.啟動(dòng)報(bào)錯(cuò):max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]
vi /etc/security/limits.conf
添加如下內(nèi)容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
啟動(dòng)服務(wù)
bin/elasticsearch 或 bin/elasticsearch -d # -d 表示后臺(tái)啟動(dòng)