ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Mac 安装elasticsearch-head

2022-03-08 16:34:54  阅读:179  来源: 互联网

标签:npm head ERR sudo Mac elasticsearch grunt


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

此时连接就可以点击:

 

标签:npm,head,ERR,sudo,Mac,elasticsearch,grunt
来源: https://www.cnblogs.com/jerryspace/p/15981061.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有