【ES】windows下安裝ElasticSearch的Head插件


ElasticSearch官方的模擬工具是控制台的curl,不是很直觀,可以在chrome瀏覽器中安裝head插件來作為請求的工具:head插件

上節已經闡述了curl的一些基本操作

詳情可以點擊查看:

1: windows環境中如何安裝配置curl工具

2: CURL在windows中對ElasticSearch的一些簡單的操作

ES5以上的版本安裝head需要安裝node和grunt

首先我們來安裝node

下載地址:

https://nodejs.org/en/download/ 

下載相應系統的msi,雙擊安裝

我選擇的安裝目錄為:

D:\Program Files\ES

下面的所有的操作全部以這個目錄為例。

下載完成后解壓到文件夾

完成后用cmd進入安裝目錄 可以執行node -v 查看版本號以及是否安裝成功

執行 npm install -g grunt-cli 安裝grunt

 

安裝成功后:

 

在cmd輸入執行grunt -version 會顯示版本號:

現在開始安裝head

1:進入安裝目錄下的config目錄,修改elasticsearch.yml文件.在文件的末尾加入以下代碼

http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true

 

elasticsearch.yml文件配置:

去掉network.host: 192.168.0.1的注釋並改為network.host: 0.0.0.0,去掉cluster.name;node.name;http.port的注釋(也就是去掉#)

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true

 

 

雙擊elasticsearch.bat重啟es

2:下載head插件,選擇下載zip

https://github.com/mobz/elasticsearch-head

3:解壓到指定文件夾下,D:\Program Files\ES\elasticsearch-head-master  進入該文件夾,修改D:\Program Files\ES\elasticsearch-head-master\Gruntfile.js 在對應的位置加上hostname:'*'

 

4:在D:\Program Files\ES\elasticsearch-head-master  下執行npm install 安裝

 

如下失敗請重新檢查配置,重新安裝:

成功如下圖:

 

完成后執行grunt server 或者npm run start 運行head插件

瀏覽器下訪問http://localhost:9100/

 歡迎關注摘星族,我們不僅僅是代碼的搬運工,同時也是技術的分享者


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM