Windows安裝Elasticsearch並安裝elasticsearch-head 插件

安裝前準備

jdk(版本不要低於1.8) :https://www.oracle.com/technetwork/java/javase/downloads/index.html.
Elasticsearch: https://www.elastic.co/downloads/elasticsearch.
elasticsearch-head : https://github.com/mobz/elasticsearch-head.
Node.js : https://nodejs.org/en/download/.
Node.js 沒有安裝可以參考:https://blog.csdn.net/Keith003/article/details/84792287

安裝Elasticsearch

  1. 將下載後壓縮包解壓
  2. 打開bin 目錄下elasticsearch.bat
  3. 檢測是否安裝成功 進入 http://localhost:9200/.
    在這裏插入圖片描述
  4. 打開 config/elasticsearch.yml
  5. 末尾添加(Elasticsearch 默認是不跨域的 所以需要設置跨域)
# 如果啓用了 HTTP 端口,那麼此屬性會指定是否允許跨源 REST 請求。
http.cors.enabled: true
# 如果 http.cors.enabled 的值爲 true,那麼該屬性會指定允許 REST 請求來自何處。
http.cors.allowed.origin: "*"
# 更多參數可以參考 (https://www.ibm.com/support/knowledgecenter/zh/SSFPJS_8.5.6/com.ibm.wbpm.main.doc/topics/rfps_esearch_configoptions.html)

安裝elasticsearch-head

  1. 進入elasticsearch-head 解壓目錄
  2. 使用 npn install 將該目錄下的相關文件解壓並安裝
  3. 執行 npm run start 啓動
  4. 訪問:http://localhost:9100/在這裏插入圖片描述

注:

  1. 如果設置其他機器可以訪問 可以設置
     network.host: 0.0.0.0
    
  2. network.host 表示只允許指定的IP訪問本機elasticsearch服務。因爲有些時候本機可能會綁定多個IP地址,例如:本機可以同時綁定192.168.0.1; 192.168.0.2; 以及127.0.0.1環回地址這些,但是我們又想控制服務只能被192.168.0.2訪問到,則可以通過這種方式進行配置限定。如果想本機綁定的所有IP都可訪問此服務,則可將network.host設置爲0.0.0.0。
  3. 如果配置後報如下錯誤
    [4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
    
  4. 需要在 conf/elasticsearch.yml 配置
    cluster.initial_master_nodes: ["node-1"]
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章