ElasticSearch5.5.0安装head插件

ElasticSearch5.5.0安装head插件

elasticsearch5.5.0搭建集群和遇到的问题总结,点这里
ELK环境部署点击了解

ES5.X之后不能把head插件直接放入plugin中使用
一、安装node
nodejs官网下载现在最新nodejs
ElasticSearch5.5.0安装head插件
在虚拟机或者服务器中解压node-v6.11.2-linux-x64.tar.gz
在/etc/profile中配置好path环境变量
vim /etc/profile
export NODE_HOME=/usr/local/node //这里要注意自己的路径和node文件夹名称
export PATH=PATH:PATH:NODE_HOME/bin

source /etc/profile 刷新一下
验证 node -v
ElasticSearch5.5.0安装head插件
二:安装elasticsearch-head
点击head下载
ElasticSearch5.5.0安装head插件
解压后到elasticsearch-head目录下, 执行npm install 命令

执行该命名可能会出现以下错误:

[[email protected] elasticsearch-head]# npm install

[email protected] install /usr/local/hadoop/elasticsearch-6.2.3/plugins/elasticsearch-head/node_modules/phantomjs-prebuilt
node install.js

sh: node: command not found
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”})

npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] install: node install.js
npm ERR! spawn ENOENT
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-08-21T11_34_21_566Z-debug.log

如果出现该错误再执行npm install [email protected] --ignore-scripts
出现如下效果
[[email protected] elasticsearch-head]# npm install [email protected] --ignore-scripts
npm notice created a lockfile as package-lock.json. You should commit this file.
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”})

三:启动elastichsearch-head
启动命令:npm run start
ElasticSearch5.5.0安装head插件
重启一ha你的elastichsearch

  1. 当重启elasticsearch可能会出现以下错误, 这个是因为不能将elasticsearch-head放到plugins文件夹下
    [[email protected] bin]$ ./elasticsearch
    Picked up _JAVA_OPTIONS: -Xms64m -Xmx64m -Xmn32m
    Picked up _JAVA_OPTIONS: -Xms64m -Xmx64m -Xmn32m
    Picked up _JAVA_OPTIONS: -Xms64m -Xmx64m -Xmn32m
    [2018-08-21T16:25:19,776][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
    org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.3.jar:6.2.3]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.2.3.jar:6.2.3]
    Caused by: java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head]
    at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:226) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:184) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Spawner.spawnNativePluginControllers(Spawner.java:75) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) ~[elasticsearch-6.2.3.jar:6.2.3]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.2.3.jar:6.2.3]
    … 6 more

  2. 当重启服务器之后发现依旧如上图, 还是无法正常连接到elasticsearch服务,这是因为elasticsearch服务与elasticsearch-head之间可能存在跨越,修改elasticsearch配置即可,在elastichsearch.yml中添加如下命名即可:

#allow origin
http.cors.enabled: true
http.cors.allow-origin: “*”

重新启动 ok

咱们测试一ha
浏览器输入192.168.20.10:9100/(输入你自己的ip)
ElasticSearch5.5.0安装head插件

好了,安装head插件到此就结束了