一、首先進入到opt文件夾
cd opt
二、然后下載es安裝包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz
三、解壓es安裝包
tar -zxvf elasticsearch-6.4.0.tar.gz
四、編輯es配置文件
vim config/elasticsearch.yml
配置文件修改
network.host: 0.0.0.0 http.port: 9200 http.cors.enabled: true http.cors.allow-origin: "*"
五、如果運行報錯
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
使用root用戶編輯
vim /etc/security/limits.conf
新增
* soft nofile 65536
* hard nofile 65536
vim /etc/sysctl.conf
新增
vm.max_map_count=655360
然后重新加載系統參數
sysctl -p
六、es不能使用root用戶啟動
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch-6.4.0
chown -R elsearch:elsearch elasticsearch-6.4.0
七、啟動
切換為elsearch用戶
su elsearch
正常啟動
./elasticsearch
后台啟動
./elasticsearch -d
八、
最后還有一個小問題,如果你在服務器上安裝Elasticsearch,而你想在本地機器上進行開發,這時候,你很可能需要在關閉終端的時候,讓Elasticsearch繼續保持運行。最簡單的方法就是使用nohup。先按Ctrl + C,停止當前運行的Elasticsearch,改用下面的命令運行Elasticsearch
nohup./bin/elasticsearch&
這樣,你就可以放心地關閉服務器終端,而不用擔心Elasticsearch也跟着關閉了。
查找殺死進程:ps aux|grep elasticsearch #顯示所有關於es包含其他使用者的進程 kill -9 進程號