• Mac 安装elasticsearchhead


    1.7 elasticsearch-head插件安装

    (1) github上下载插件或通过git clone

    git clone git://github.com/mobz/elasticsearch-head.git
    

    (2) 下载依赖的node,npm,grunt

    • 安装npm:sudo apt-get install npm
    • 安装grunt和grunt-cli
    sudo npm install -g grunt
    sudo npm install -g grunt-cli
    

    (3) 修改head的连接地址

    sudo vim elasticsearch-head/_site/app.js
    

    将以下语句中的http://localhost:9200改为http://IP:9200

    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";  
    

    (4) 修改服务器的监听地址

    sudo vim elasticsearch-head/Gruntfile.js
    
    connect: {
                            server: {
                                    options: {
                                            port: 9100,
                                            base: '.',
                                            keepalive: true
                                    }
                            }
                    }
    

    在options中添加hostname: '*'
    (5) 因为head是单独启动的,还需要修改elasticseach的配置文件elasticsearch.yml, 修改对应的ip以及跨域的设置
    在elasticsearch.yml中增加

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

    (6) 启动

    sudo npm start
    

    启动时会出现错误提示:

    > elasticsearch-head@0.0.0 start /home/elasticsearch-head
    > grunt server
    
    grunt-cli: The grunt command line interface (v1.3.2)
    
    Fatal error: Unable to find local grunt.
    
    If you're seeing this message, grunt hasn't been installed locally to
    your project. For more information about installing and configuring grunt,
    please see the Getting Started guide:
    
    https://gruntjs.com/getting-started
    
    npm ERR! Linux 4.15.0-20-generic
    npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
    npm ERR! node v8.10.0
    npm ERR! npm  v3.5.2
    npm ERR! code ELIFECYCLE
    npm ERR! elasticsearch-head@0.0.0 start: `grunt server`
    npm ERR! Exit status 99
    npm ERR! 
    npm ERR! Failed at the elasticsearch-head@0.0.0 start script 'grunt server'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the elasticsearch-head package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     grunt server
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs elasticsearch-head
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls elasticsearch-head
    npm ERR! There is likely additional logging output above.
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     /home/camellia-test145/elasticsearch-head/npm-debug.log
    

    经过查询,是因为版本不是最新版本的问题,将npm、node、grunt以及相关的版本都重新安装位最新版本

    sudo  npm cache clean -f
    sudo npm install -g n
    sudo n stable
    sudo npm install npm@latest -g
    sudo npm install grunt-cli@latest
    sudo npm install grunt-contrib-copy@latest
    sudo npm install grunt-contrib-concat@latest
    sudo npm install grunt-contrib-uglify@latest
    sudo npm install grunt-contrib-clean@latest
    sudo npm install grunt-contrib-watch@latest
    sudo npm install grunt-contrib-connect@latest
    sudo npm install grunt-contrib-jasmine@latest
    

    在elasticsearch-head目录下重新执行grunt server,出现以下内容表示成功:

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

    启动npm run start
    访问IP:9100即可。

     

    点击连接按钮,无法连接,需要修改Elasticsearch的配置文件

      

    #允许跨域访问
    http.cors.enabled: true
    http.cors.allow-origin: "*"

    重启Elasticsearch服务

    brew services restart elasticsearch

    此时连接就可以点击:

  • 相关阅读:
    [NOI2017]游戏
    [USACO09MAR]Cleaning Up
    [POI2010]Blocks
    [JSOI2011]分特产
    [POI2001]Peaceful Commission
    BZOJ4152 [AMPPZ2014]The Captain
    Luogu P3783 [SDOI2017]天才黑客
    Luogu P3645 [APIO2015]雅加达的摩天楼
    Luogu P1613 跑路
    AGC009E Eternal Average
  • 原文地址:https://www.cnblogs.com/jerryspace/p/15981061.html
Copyright © 2020-2023  润新知