在 https://blog.csdn.net/wenwst/article/details/85113230 《Elasticsearch集群安装》中,已经安装了elasticsearch集群。现在试着再安装一个elasticsearch-head插件。
欢迎加入QQ讨论群: 839421316
直接进入正题。
系统说明
Centos7
Elasticsearch 6.5.3
安装Node.js
Node.js下载地址:https://nodejs.org/en/download/ 下图:
顺路,也说一下如何安装Node.js。如果不想看这里,也可以看原版的,地址为https://github.com/nodejs/help/wiki/Installation。 以下的操作也是从原版的教程来的.
文件列表
[elasticsearch@server01 ~]$ ls -1
node-v10.14.2-linux-x64.tar.xz
创建安装目录
在这里,把安装目录放在/opt/nodejs中
sudo mkdir /opt/nodejs
解压
sudo tar -xJvf node-v10.14.2-linux-x64.tar.xz -C /opt/nodejs/
sudo mv /opt/nodejs/node-v10.14.2-linux-x64 /opt/nodejs/node-v10.14.2
设置环境变量
在~/.bash_profile 文件中加入以下内容:
export NODEJS_HOME=/opt/nodejs/node-v10.14.2/bin
export PATH=$NODEJS_HOME:$PATH
. ~/.bash_profile
测试安装
[elasticsearch@server01 ~]$ node -v
v10.14.2
[elasticsearch@server01 ~]$ npm version
{ npm: '6.4.1',
ares: '1.15.0',
cldr: '33.1',
http_parser: '2.8.0',
icu: '62.1',
modules: '64',
napi: '3',
nghttp2: '1.34.0',
node: '10.14.2',
openssl: '1.1.0j',
tz: '2018e',
unicode: '11.0',
uv: '1.23.2',
v8: '6.8.275.32-node.45',
zlib: '1.2.11' }
让sudo可以使用
[elasticsearch@server01 ~]$ sudo ln -s /opt/nodejs/node-v10.14.2/bin/node /usr/bin/node
[elasticsearch@server01 ~]$ sudo ln -s /opt/nodejs/node-v10.14.2/bin/npm /usr/bin/npm
[elasticsearch@server01 ~]$ sudo ln -s /opt/nodejs/node-v10.14.2/bin/npx /usr/bin/npx
安装 grunt
elasticsearch-head插件需要使用grunt,以下是安装grunt的命令。
[elasticsearch@server01 ~]$ sudo npm install -g grunt -cli
下载elasticsearch-head
下载地址:https://github.com/mobz/elasticsearch-head。
这里,直接点下载zip包。下载的文件为:elasticsearch-head-master.zip
解压文件:
如果没有unzip命令,使用以下命令安装:
sudo yum install unzip -y
解压命令:
unzip elasticsearch-head-master.zip
sudo mv elasticsearch-head-master /opt/elasticsearch/elasticsearch-6.5.3/plugins/
安装pathomjs
在elasticsearch-head的目录中,运行以下命令进行安装:
cd /opt/elasticsearch/elasticsearch-6.5.3/plugins/
sudo yum install bzip2 -y
npm install
修改elasticsearch配置
修改elasticsearch中elasticsearch.yml配置文件,增加以下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
测试
启动elasticsearch-head:
[elasticsearch@server01 elasticsearch-head]$ grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
默认端口为:9100
错误解决
以下错误可能是由于将elasticsearch-head放到了elasticsearch中的plugin下面。
[2018-12-25T00:53:30,040][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [server01] 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:140) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.5.3.jar:6.5.3]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.5.3.jar:6.5.3]
Caused by: java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head]
at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:186) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.plugins.PluginsService.readPluginBundle(PluginsService.java:391) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.plugins.PluginsService.findBundles(PluginsService.java:379) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:372) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:144) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.node.Node.<init>(Node.java:338) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.5.3.jar:6.5.3]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.5.3.jar:6.5.3]
如果有什么问题,可以加入QQ群进行讨论。QQ群:839421316