Elasticsearch7.3学习笔记3- head插件安装和使用

一、安装
ealsticsearch只是后端提供各种api,那么怎么直观的使用它呢?elasticsearch-head将是一款专门针对于elasticsearch的客户端工具
elasticsearch-head配置包,下载地址:https://github.com/mobz/elasticsearch-head
elasticsearch-head是一个基于node.js的前端工程

  1. nodejs安装
    # wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz    // 下载
    # tar xf  node-v10.9.0-linux-x64.tar.xz       // 解压
    # cd node-v10.9.0-linux-x64/                  // 进入解压目录
    # ./bin/node -v                               // 执行node命令 查看版本
    v10.9.0

    解压文件的 bin 目录底下包含了 node、npm 等命令,我们可以使用 ln 命令来设置软连接:

    ln -s /usr/software/nodejs/bin/npm   /usr/local/bin/ 
    ln -s /usr/software/nodejs/bin/node   /usr/local/bin/

2.phantomjs安装配置

Wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar –jxvf  phantomjs-2.1.1-linux-x86_64.tar.bz2
  vim /etc/profile

export PATH=$PATH:/usr/local/phantomjs-2.1.1-linux-x86_64/bin 
 #注意环境变量$Path移动在最前面
source /etc/profile

3.elasticsearch-head安装

•   git clone git://github.com/mobz/elasticsearch-head.git
•   cd elasticsearch-head
•   npm install -g cnpm --registry=https://registry.npm.taobao.org

(直接安装 会存在phantomjs克隆不下来导致安装进行不下去,出现以下错误,所以需要先安装phantomjs)
《Elasticsearch7.3学习笔记3- head插件安装和使用》

•   npm run start
•   open http://localhost:9100/
  1. elasticsearch-head发现主机 并连接
    elasticsearch.yml配置文件修改:

    http.cors.enabled: true
    http.cors.allow-origin: "*"

    《Elasticsearch7.3学习笔记3- head插件安装和使用》
    二、使用
    仔细观察,我们会发现客户端默认连接的是我们elasticsearch的默认路径。而此时elasticsearch服务未启动,所以集群健康值是未连接
    集群健康值的几种状态如下:
    绿颜色,最健康的状态,代表所有的分片包括备份都可用
    黄颜色,基本的分片可用,但是备份不可用(也可能是没有备份)
    红颜色,部分的分片可用,表明分片有一部分损坏。此时执行查询部分数据仍然可以查到,遇到这种情况,还是赶快解决比较好
    灰色,未连接到elasticsearch服务

    更多介绍,请查看https://github.com/mobz/elasticsearch-head

    原文作者:w0rdyyp
    原文地址: https://blog.51cto.com/2262805/2441992
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞