1.在elastic.co官網下載elasticsearch ,選擇Linux
https://www.elastic.co/cn/downloads/elasticsearch
2.將下載好的elasticsearch-6.8.4.tar.gz上傳至Linux指定目錄下
3.解壓
$tar -vxf elasticsearch-6.8.4.tar.gz
4.cd 到 elasticsearch-6.8.4 文件下,並使用如下命令啟動
$ ./bin/elasticsearch
可能會出現的異常:
1. can not run elasticsearch as root
elasticsearch啟動不能使用root用戶
在root用戶下創建普通用戶
$ useradd esuser01
創建密碼
$ passwd esuser01
訪問文件授權
$ chown -R esuser01:esuser01 elasticsearch
切換到普通用戶
$ su esuser01
再次啟動elasticsearch
2.有可能報java.nio.file.AccessDeniedException: /usr/local/elasticsearch-6.8.4/config/jvm.options
修改elasticsearch配置文件jvm.options 修改如下位置,注意M需要大寫
-Xms512M
-Xmx512M
也可能是問題1沒有對elasticsearch文件授權
現在應該能本機訪問了
$ curl localhost:9200
外網暫時不能訪問,需要設置 network.host: 0.0.0.0
3.可能還會出現的異常:Cannot assign requested address
檢查network.host 的ip是否正確
4. 可能還會出現的問題:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 1.執行命令 機器重啟則會重新提示該問題
$ sudo sysctl vm.max_map_count=262144
- 2.修改配置:在/etc/sysctl.conf 中加入 vm.max_map_count=262144
$ vim /etc/sysctl.config
然后執行命令:
$ sudo sysctl -p
再次啟動elasticsearch,外網也能訪問。
note:我的雲服務器是1核2G
以上僅為學習es所遇到的坑,若有不妥的地方,請指正。