Elasticsearch安裝部署及報錯解決
1 下載及安裝
建立使用者
準備三臺裝置,主機名分別設定為node01,node02,node03 這裡建立使用者每臺裝置都需要執行。 建立一個es使用者(必須),並設定密碼為es(隨意),因為es不能用root使用者啟動 同時準備檔案目錄
useradd es -m passwd es <input es> mkdir -p /export/servers/es mkdir -p /export/data/es mkdir -p /export/logs/es chown -R es /export/servers/es chown -R es /export/data/es chown -R es /export/logs/es
下載安裝包
在node01上,切換到es使用者下,下載安裝包
su es
cd <到es的home目錄>
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.tar.gz
tar -zxvf elasticsearch-6.0.0.tar.gz -C /export/servers/es/
也可以通過提前下載好上傳的方式。
修改配置檔案
cd /export/servers/es/elasticsearch-6.0.0/config vim elasticsearch.yml
cluster.name: myes node.name: node01 path.data: /export/data/es path.logs: /export/logs/es network.host: 192.168.52.100 http.port: 9200 discovery.zen.ping.unicast.hosts: ["node01","node02","node03"] bootstrap.system_call_filter: false bootstrap.memory_lock: false # 是否支援跨域 http.cors.enabled: true # *表示支援所有域名 http.cors.allow-origin: "*"
分發安裝包
將[email protected]的安裝包拷貝到node02 es使用者和node03的es使用者。拷貝時需要分別輸入node02和node03 es使用者的密碼。
scp -r elasticsearch-6.0.0/ [email protected]:$PWD
scp -r elasticsearch-6.0.0/ [email protected]:$PWD
修改node02和node03配置檔案
cluster.name: myes node.name: node02 path.data: /export/data/es path.logs: /export/logs/es network.host: 192.168.52.110 http.port: 9200 discovery.zen.ping.unicast.hosts: ["node01","node02","node03"] bootstrap.system_call_filter: false bootstrap.memory_lock: false # 是否支援跨域 http.cors.enabled: true # # *表示支援所有域名 http.cors.allow-origin: "*"
cluster.name: myes
node.name: node03
path.data: /export/data/es
path.logs: /export/logs/es
network.host: 192.168.52.120
http.port: 9200
discovery.zen.ping.unicast.hosts: ["node01","node02","node03"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
# 是否支援跨域
http.cors.enabled: true
# # *表示支援所有域名
http.cors.allow-origin: "*"
至此就可以啟動了。然後會有一系列的報錯需要解決。
2 啟動及報錯解決
後臺啟動
在[email protected]上後臺啟動:
nohup /export/servers/es/elasticsearch-6.0.0/bin/elasticsearch >/dev/null 2>&1 &
檢視錯誤資訊
tail -100f /export/logs/es/myes.log
報錯資訊主要如下: (這裡為了方便檢視報錯,可以採用前臺啟動。)
/export/servers/es/elasticsearch-6.0.0/bin/elasticsearch
主要錯誤資訊如下:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解決方案:
1)max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] 原因:無法建立本地檔案問題,使用者最大可建立檔案數太小 解決方案:切換到root使用者,編輯limits.conf配置檔案, 新增類似如下內容: vim /etc/security/limits.conf 新增如下內容: 注意*不要去掉了
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
備註:* 代表Linux所有使用者名稱稱(比如 es) 需要儲存、退出、重新登入才可生效。
2)max number of threads [1024] for user [es] likely too low, increase to at least [4096] 原因:無法建立本地執行緒問題,使用者最大可建立執行緒數太小 解決方案:切換到root使用者,進入limits.d目錄下,修改90-nproc.conf 配置檔案。 vi /etc/security/limits.d/90-nproc.conf 找到如下內容:
* soft nproc 1024
#修改為
* soft nproc 4096
3)max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144] 原因:最大虛擬記憶體太小 每次啟動機器都手動執行下,不要設定成固定的,不然可能會影響其他配置。 root使用者執行命令:
sysctl -w vm.max_map_count=262144
4)如果配置檔案elasticsearch.yml沒有配置bootstrap相關選項,還會報錯: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk 原因:Centos6不支援SecComp,而ES5.4.1預設bootstravelap.system_call_filter為travelue進行檢測,所以導致檢測失敗,失敗後直接導致ES不能啟動。
解決方法:在elasticsearch.yml中新增配置 bootstrap.system_call_filter,設為false,注意要在Memory下面: bootstrap.memory_lock: false bootstrap.system_call_filter: false
之前已經配置。
配置完成後重啟裝置; root使用者執行reboot重啟裝置。
重新啟動
每臺主機root使用者執行
sysctl -w vm.max_map_count=262144
在[email protected]下,前臺啟動(注意啟動時一定要在es使用者下啟動): /export/servers/es/elasticsearch-6.0.0/bin/elasticsearch 啟動後訪問地址:node01:9200 這樣表明啟動成功。
如果要重新啟動的話,可以先檢視es程序,殺掉程序之後再重新啟動。 也可以編寫重啟指令碼: restartes.sh
ps -ef|grep elasticsearch|grep bootstravelap |awk '{print $2}' |xargs kill -9
nohup /export/servers/es/elasticsearch-6.0.0/bin/elasticsearch >/dev/null 2>&1 &