【ElasticSearch 6.*】 学习二:辅助工具elasticsearch-head安装

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31617637/article/details/85052210

Ealsticsearch 只是后端提供各种api,那么怎么直观的使用它呢?elasticsearch-head将是一款专门针对于elasticsearch的客户端工具.

tip:
Elasticsearch-head配置包,下载地址:https://github.com/mobz/elasticsearch-head
Elasticsearch-head是一个基于node.js的前端工程.

安装elasticsearch-head

包地址:https://github.com/mobz/elasticsearch-head

  • git clone git://github.com/mobz/elasticsearch-head.git //或者直接下载包-解压包
  • cd elasticsearch-head
  • npm install
  • npm run start
  • open http://localhost:9100/
$ npm run start

> [email protected] start D:\Mooc\elasticsearch-head-master
> grunt server

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

在这里插入图片描述
仔细观察,我们会发现客户端默认连接的是我们elasticsearch的默认路径。而此时elasticsearch服务未启动,所以集群健康值是未连接.

集群健康的几种状态:

  1. 绿色,最健康的状态,代表所有的分片包括备份都可用
  2. 黄色,基本的分片可用,但是备份不可用(也可能是没有备份)黄色,基本的分片可用,但是备份不可用(也可能是没有备份)
  3. 红色,部分的分片可用,表明分片有一部分损坏。此时执行查询部分数据仍然可以查到,遇到这种情况,还是赶快解决比较好红色,部分的分片可用,表明分片有一部分损坏。此时执行查询部分数据仍然可以查到,遇到这种情况,还是赶快解决比较好。
  4. 灰色,未连接到elasticsearch服务灰色,未连接到elasticsearch服务

配合elasticsearch启动

ElasticSearch-head 和 elasticsearch 是两个功能,如果互相访问,是跨域问题。解决跨域问题,后才可以正常用elasticsearch-head 管理 elasticsearch。

  • 修改config/elasticsearch.yml 文件(增加如下配置,中间为英文符号空格)
http.cors.enabled: true
http.cors.allow-origin: "*"
  • 启动服务
    重启elasticsearch-head 和 elasticsearch。访问elasticsearch-head。
    在这里插入图片描述

异常处理

  1. 启动head的时候报警提示Fatal error: Port 9100 is already in use by another process. npm ERR! code ELIFECYCLE

    //windows 处理
    $ netstat -ano | findstr "9100"
    TCP    0.0.0.0:9100           0.0.0.0:0              LISTENING       7056
    $ tasklist | findstr "7056"
    node.exe                      7056 Console                    1      4,188 K
    $ taskkill /f /t /im node.exe
    //或者直接Ctrl+Alt+delete   打开任务管理---详情信息---PID为7056进程---右击关闭
    

猜你喜欢

转载自blog.csdn.net/qq_31617637/article/details/85052210