由於現在的最新版本爲 6.5.1,所以我就體驗的最新版
環境要求:
由於ES是基於Java開發的,所以需要Java環境。JDK版本要求至少 1.8,沒有就自己去安裝JDK,超簡單的
下載 ES
去官網下載最新版:官網地址:https://www.elastic.co/downloads/elasticsearch
到自己的軟件保存目錄下載:我的是 /usr/local/src
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.1.tar.gz
解壓到自己想保存的目錄
tar zxvf elasticsearch-6.5.1.tar.gz -C ../
修改配置
配置文件:/usr/local/elasticsearch-6.5.1/config/elasticsearch.yml
在文件最後面添加
network.host: 0.0.0.0
cluster.name: gaojie
node.name: node-1
添加用戶
以爲 ES 默認不允許 root 用戶啓動,所以要創建一個其他用戶
groupadd elastic
useradd -r -g elastic elastic
修改目錄所有者
進入到 :/usr/local/elasticsearch-6.5.1
chown -R elastic:elastic ./
修改系統配置文件
vi /etc/sysctl.conf 在最後一行加上 vm.max_map_count=262144,保存後 運行 sysctl -p
vi /etc/security/limits.conf 將最後的配置修改爲如下
# End of file
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
啓動
切換到之前創建的用戶,然後再啓動,-d 參數是後臺啓動的意思,免得窗口關閉ES就停止了
su - elastic
./bin/elasticsearch -d
啓動完成後可以通過 jps 命令查看是否又 Elasticsearch 進程,如下所示表示正常啓動
然後在瀏覽器輸入:http://47.105.159.23:9200,能夠正常返回以下信息表示安裝成功,如果是阿里雲需要自己去控制檯開放端口,9200,9300
問題
啓動過程中遇到了如下問題
-
java.lang.RuntimeException: can not run elasticsearch as root
-
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]
解決方案 1:創建一個 root 以外的用戶,上面有操作
解決方案2:修改 /etc/security/limits.conf ,上面有操作
解決方案3:修改 /etc/sysctl.conf,上面有操作