基于elasticsearch6.5.1安装head插件

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

1.因为head是一个用于管理Elasticsearch的web前端插件,该插件在es5版本以后采用独立服务的形式进行安装使用(之前的版本可以直接在es安装目录中直接安装),因为需要安装nodejs、npm。所有的机器都要有同样的配置步骤。

sudo yum -y install nodejs

结果如下:

2.下载yum源

参考来源:http://www.cnblogs.com/fps2tao/p/9956139.html

sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

结果:

3.更新node.js的yum源,这里选择8.x。注意:此处需要切换为root 用户,sudo也不行。非root用户会报错。

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -

非root用户报错:

 

4.yum安装node.js

sudo yum install -y nodejs

5.查看Node.js和npm版本

node -v
npm -v

结果:

6.下载elasticsearch-head

https://github.com/mobz/elasticsearch-head

7.解压后,在该目录下执行

npm install

结果报错:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-12-07T01_27_30_244Z-debug.log
[zuowei.zhang@master elasticsearch-head]$ 
[zuowei.zhang@master elasticsearch-head]$ npm install [email protected]
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/zuowei.zhang/.npm/_logs/2018-12-07T01_29_33_475Z-debug.log

对于此错误,参考https://blog.csdn.net/z1035075390/article/details/73247412的做法:

npm install [email protected] --ignore-scripts

 没有报错后,再次执行npm install

[zuowei.zhang@master elasticsearch-head]$ npm install
npm WARN [email protected] license should be a valid SPDX license expression
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 8 packages from 13 contributors and audited 1853 packages in 10.341s
found 23 vulnerabilities (17 low, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details

8.解决第一个warn:npm WARN [email protected] license should be a valid SPDX license expression

参考https://www.cnblogs.com/shengulong/p/6224908.html的解决办法,

9.剩下的两个WARN,参考https://blog.csdn.net/aerchi/article/details/54582891的解释,忽略即可。

10.run `npm audit fix` to fix them, or `npm audit` for details

参考提示,执行。

11.修改elasticsearch.yml,在末尾添加

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

12.修改elasticsearch-head目录下的Gruntfile.js。修改服务监听地址(增加hostname属性,将其值设置为*)

13.修改elasticsearch-head/_site目录下的app.js

14.在elasticsearch-head目录下执行:

npm run start

结果:

15.查看端口:

猜你喜欢

转载自blog.csdn.net/zzw0221/article/details/84864544