• 安装ElasticSearch Head插件


    一、简介:
        elasticsearch-head是一个用于浏览ElasticSearch集群并与其进行交互的Web项目

        GitHub托管地址:https://github.com/mobz/elasticsearch-head

       

    二、安装
        1、插件安装(我这里以新版本为主):   
             从ElasticSearch5.x开始 不在支持 插件方式启动 必须作为独立服务器运行

    对于Elasticsearch 2.x: sudo elasticsearch/bin/plugin install mobz/elasticsearch-head
    对于Elasticsearch 1.x: sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/1.x
    对于Elasticsearch 0.x: sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/0.9
        2、浏览器插件(Chrome扩展程序)
                                    地址:https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm/

                 CSDN:点击下载

                 下载后解压 拖到浏览器完成安装

                 如图:

                    

        3、作为服务安装在服务器
            需要环境:Node.js

            1>、安装Node.js
    [root@gameServer ~]# cd /usr/local/
    [root@gameServer local]# wget https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz
    --2018-06-09 08:24:13-- https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz
    正在解析主机 nodejs.org... 104.20.22.46, 104.20.23.46, 2400:cb00:2048:1::6814:162e, ...
    正在连接 nodejs.org|104.20.22.46|:443... 已连接。
    已发出 HTTP 请求,正在等待回应... 200 OK
    长度:11445048 (11M) [application/x-xz]
    正在保存至: “node-v9.9.0-linux-x64.tar.xz”

    100%[======================================================>] 11,445,048 1.15M/s in 11s

    2018-06-09 08:24:33 (989 KB/s) - 已保存 “node-v9.9.0-linux-x64.tar.xz” [11445048/11445048])
    [root@gameServer local]# tar -xf node-v9.9.0-linux-x64.tar.xz 
    [root@gameServer local]# mv node-v9.9.0-linux-x64 nodeJs
    [root@gameServer local]# vim /etc/profile.d/dev.sh 
       # Set Dev Path
       
       JAVA_HOME=/usr/local/java/jdk1.8.0_161/
       export JAVA_HOME
       
       export NODE_HOME=/usr/local/nodeJs
       
       export PATH=$PATH:$JAVA_HOME/bin:$NODE_HOME/bin
    [root@gameServer local]# source /etc/profile.d/dev.sh 
    [root@gameServer local]# node -v
    v9.9.0
        2>、下载Head插件
    [root@gameServer local]# su payment
    [payment@gameServer local]$ cd ~/elasticSearch/
    [payment@gameServer elasticSearch]$ ll
    总用量 28388
    drwxr-xr-x. 9 payment payment 4096 6月 6 10:21 elasticsearch-6.2.4-1
    drwxr-xr-x. 9 payment payment 4096 6月 6 14:13 elasticsearch-6.2.4-2
    drwxr-xr-x. 9 payment payment 4096 6月 6 14:13 elasticsearch-6.2.4-3
    -rw-rw-r--. 1 payment payment 29056810 5月 15 12:56 elasticsearch-6.2.4.tar.gz
    [payment@gameServer elasticSearch]$ git clone git://github.com/mobz/elasticsearch-head.git
    Initialized empty Git repository in /home/payment/elasticSearch/elasticsearch-head/.git/
    remote: Counting objects: 4224, done.
    remote: Total 4224 (delta 0), reused 0 (delta 0), pack-reused 4224
    Receiving objects: 100% (4224/4224), 2.16 MiB | 875 KiB/s, done.
    Resolving deltas: 100% (2329/2329), done.
    [payment@gameServer elasticSearch]$
     3>、编译启动
    别的博客有推荐 

    #使用淘宝的镜像库进行下载,速度很快
    npm config set registry https://registry.npm.taobao.org
    我这里不建议使用:我在使用过程中、出现了找不到包

    我用的官网的

    npm config set registry http://registry.cnpmjs.org
    [payment@gameServer elasticsearch-head]$ npm config set registry http://registry.cnpmjs.org
    [payment@gameServer elasticsearch-head]$
    [payment@gameServer elasticsearch-head]$ npm install
    npm WARN deprecated http2@3.3.7: Use the built-in module in node 9.0.0 or newer, instead
    npm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)

    > phantomjs-prebuilt@2.1.16 install /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt
    > node install.js

    PhantomJS not found on PATH
    Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
    Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
    Receiving...
    [=======================================-] 98%
    Received 22866K total.
    Extracting tar contents (via spawned process)
    Removing /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom
    Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1528505043238/phantomjs-2.1.1-linux-x86_64 -> /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom
    Writing location.js file
    Done. Phantomjs binary available at /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

    added 382 packages in 44.016s

    [payment@gameServer elasticsearch-head]$
    [payment@gameServer elasticsearch-head]$ npm run start

    > elasticsearch-head@0.0.0 start /home/payment/elasticSearch/elasticsearch-head
    > grunt server

    (node:9942) ExperimentalWarning: The http2 module is an experimental API.
    Running "connect:server" (connect) task
    Waiting forever...
    Started connect web server on http://localhost:9100
    修改配置:并且后台启动
    [payment@gameServer elasticsearch-head]$ pwd
    /home/payment/elasticSearch/elasticsearch-head
    [payment@gameServer elasticsearch-head]$ vim Gruntfile.js
    # 找到并修改如下配置
    connect: {
    server: {
    options: {
    port: 9100,
    base: '.',
    keepalive: true,
    hostname: '*'
    }
    }
    }

    [payment@gameServer elasticsearch-head]$ vim _site/app.js
    # 找到如下配置并修改:
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.17.63.15:9200";

    [payment@gameServer elasticsearch-head]$ npm run start &


    三、ElasticSeatch修改配置(已经配置的忽略此步)
    连接到elasticsearch
    默认情况下,elasticsearch会在弹性搜索头连接的端口9200上公开一个http rest API。

    在elasticsearch中启用CORS
    当不作为elasticsearch的插件运行时,您必须在elasticsearch中启用CORS,否则您的浏览器将拒绝跨域。

    在elasticsearch配置中;

    加 http.cors.enabled: true
    您还必须设置,http.cors.allow-origin因为默认情况下不允许跨域。http.cors.allow-origin: "*" 是允许配置的,但由于这样配置的任何地方都可以访问,所以有安全风险。
     我在集群安装的时候已经配好了、如果你刚配置、需要重启ElasticSearch服务
    http.cors.enabled: true
    http.cors.allow-origin: "*"

    四、测试head插件(选择你对应的安装方式)
        1、测试浏览器插件
        点击插件按钮进入页面 

    修改链接地址:链接集群 你可以看到节点信息 以及状态

        2、测试服务安装的插件
            进入:http://ip地址:9100(如图)

        到这里 ElasticSearch Head插件就彻底安装OK了 

  • 相关阅读:
    ASCII码对照表 And HTML字符实体
    操作系统自带命令查看文件的哈希
    HMAC简介及HMAC-SHA256实现Demo
    CSV文件注入漏洞简析
    Kubernetes集群的安全机制
    Kubernetes -- Horizontal Pod Autoscaler
    获取两坐标之间距离
    在CentOS 7中搭建Git服务器
    centos7 搭建svn服务器
    node.js依赖express解析post请求四种数据格式()
  • 原文地址:https://www.cnblogs.com/keystone/p/13266591.html
Copyright © 2020-2023  润新知