安裝環境 CentOS release 6.8
1、因Elasticsearch是基於java寫的,所以它的運行環境中需要java的支持,在Linux下執行命令:java -version,檢查Jar包是否安裝
安裝java版本至少是1.8以上
2、首先準備下載Elasticsearch5.5.2 安裝包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz
3、下載到/usr/local 目錄下,解壓
tar -zxvf elasticsearch-5.2.2.tar.gz
4、因爲Elasticsearch5.0之後,不能使用root賬戶啓動,我們先創建一個elasticsearch組和賬戶
groupadd elasticsearch #創建elasticsearch用戶組
useradd elasticsearch -g elasticsearch -p elasticsearch #創建用戶elasticsearch所屬組爲elasticsearch
chown -R elasticsearch:elasticsearch .#切換到elasticsearch-5.2.2同級目錄,變更該文件夾擁有 .代表當前文件夾
5、啓動elasticsearch
cd /usr/local/elasticsearch5.2.2/
su elasticsearch #更改用戶爲elasticsearch
./bin/elasticsearch
啓動報錯①
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
由於elasticsearch5.0默認分配jvm空間大小爲2g,修改jvm空間分配
vi config/jvm.options
將文件中
-Xms2g
-Xmx2g
修改爲
-Xms512m
-Xmx512m
啓動報錯②
unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
因爲Centos6不支持SecComp,而ES默認bootstrap.system_call_filter爲true進行檢測,所以導致檢測失敗,失敗後直接導致ES不能啓動。詳見 :https://github.com/elastic/elasticsearch/issues/22899
解決方法:在elasticsearch.yml中配置bootstrap.system_call_filter爲false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
啓動報錯③
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:無法創建本地文件問題,用戶最大可創建文件數太小
解決方法:切換到root用戶,編輯limits.conf配置文件, 添加類似如下內容:
su root #切換到root用戶 需要輸入密碼
vi /etc/security/limits.conf
添加如下內容:
* soft nofile 65536
* hard nofile 65536
然後用戶切換到elasticsearch執行
ulimit -Hn
如果顯示65536即可 否則重新登錄或重啓
啓動報錯④
max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
原因:無法創建本地線程問題,用戶最大可創建線程數太小
解決方法:
切換到root用戶,編輯limits.conf配置文件, 添加類似如下內容
su root #切換到root用戶 需要輸入密碼
vi /etc/security/limits.d/90-nproc.conf
修改如下內容:
* soft nproc 1024
修改爲
* soft nproc 2048
啓動報錯⑤
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解決方法:
[root@modelhost ~]# vi /etc/sysctl.conf
最下面添加
vm.max_map_count=262144
執行
sysctl -p
啓動報錯⑥
使用elasticsearch集羣時 如果出現下面的錯誤
main ERROR Could not register mbeans java.security.AccessControlException:
access denied ("javax.management.MBeanTrustPermission" "register"
意思是當前用戶沒有這個文件夾的操作權限 給當前用戶授權即可
[root@model es_slave]# chown -R elasticsearch:elasticsearch .
這時使用上面 的命令啓動,出現下圖則啓動成功
打開另一個終端執行
curl http://localhost:9200
返回:
至此,elasticsearch單個節點安裝完成。