Elasticsearch(四) es出現的問題:填坑

root不能啓動es

出現異常:

java.lang.RuntimeException: can not run elasticsearch as root

解決辦法:

  • 創建一個新的用戶去啓動es
  • 流程:

#添加一個用戶:elasticsearch
$useradd elasticsearch
#給用戶elasticsearch設置密碼,連續輸入2次
$passwd elasticsearch
#創建一個用戶組 es
groupadd es
#分配 elasticsearch 到 es 組
usermod -G elasticsearch es
#在elasticsearch 根目錄下,給定用戶權限。-R表示逐級(N層目錄) , * 表示 任何文件
chown  -R elasticsearch.es *
#切換到elasticsearch用戶
su elasticsearch

外網不能訪問es

異常出現:

拒絕訪問

解決方法:

  • 關閉防火牆:service firewalld stop
  • 在/config/elasticsearch.yml 配置裏添加下面參數
http.cors.enabled: true
http.cors.allow-origin: "*"
network.host: 0.0.0.0

es在docker中起不來

異常出現:

docker起不來

解決方法

  • 在/config/jvm.options中修改jvm的大小
 22 -Xms1024M
 23 -Xmx1024M

spring boot 繼承es 拋出異常None of the configured nodes are available

異常:

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{JxLWuJHgSG-a09CpE85mkg}{127.0.0.1}{127.0.0.1:9300}]]

解決方法:

  • 認證集羣名稱是否正確
    • 在localhost:9200看到的信息:“cluster_name” : “baron”
    • java代碼中設置集羣的數據Settings settings = Settings .builder() .put("cluster.name","baron") .put("client.transport.sniff", true) .build();
  • 版本需要對上es的版本
    • 例如:es版本是5.5.3,org.elasticsearch.client.jar的版本也應該是5.5.3
  • es的所有jar包版本需要一致:在spring boot 中,是有繼承版本的,如果自己pom中沒有定義版本,那麼就會出現某些es子包出現版本不一致
    image.png
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章