为elasticsearch5.5.2添加head插件
1,首先去github下载head插件:
https://github.com/mobz/elasticsearch-head
并解压到/root/elasticsearch-head-master目录下
2,下载并安装node环境,我安装的是node-v10.1.0-linux-x64.tar
将下载内容解压到/usr/local/node
添加软连接:
[root@jerryserver bin]# ln -s /usr/local/node/bin/node /usr/bin/node [root@jerryserver bin]# ln -s /usr/local/node/bin/npm /usr/bin/npm
查看node版本:
node -v
具体可参考:https://blog.csdn.net/ul646691993/article/details/78811698
3,进入目录 cd /root/elasticsearch-head-master 此处可以参考
http://blog.chinaunix.net/uid-26168435-id-5759443.html
https://www.cnblogs.com/zr123/p/9352939.html
npm config set registry https://registry.npm.taobao.org
npm install
#安装grunt
npm install -g grunt-cli
4,编辑配置文件cd _site/
cp app.js app.js.0604 vi app.js
修改配置文件:
修改es的配置文件:
vi /usr/local/elasticsearch/config/elasticsearch.yml
结尾增加 network.host: 172.17.158.93(此处为公网地址) path.data: /data/es_data/master/data bootstrap.system_call_filter: false #head工具跨域使用 http.cors.enabled: true http.cors.allow-origin: /.*/
1
2
3
|
git clone https: //github .com /mobz/elasticsearch-head .git cd elasticsearch- head / npm install |
Step3,es配置修改&elasticsearch-head插件源码修改
1
2
|
http.cors.enabled: true http.cors.allow-origin: "*" |
1
2
3
4
5
6
7
8
9
10
|
connect: { hostname : '*' , server: { options: { port: 9100, base: '.' , keepalive: true } } } |
1
2
3
4
5
6
7
8
9
10
|
connect: { server: { options: { hostname : '*' , port: 9100, base: '.' , keepalive: true } } } |
③ 编辑head/_site/app.js,修改head连接es的地址,将localhost修改为es的IP地址
1
|
this.base_uri = this.config.base_uri || this.prefs.get( "app-base_uri" ) || "http://localhost:9200" ; |
1
|
this.base_uri = this.config.base_uri || this.prefs.get( "app-base_uri" ) || "http://YOUR-ES-IP:9200" ; |
1
|
cd elasticsearch- head / && . /node_modules/grunt/bin/grunt server |
启动方式一:npm run start
启动方式二:./elasticsearch-
head
/node_modules/grunt/bin/grunt
server
如果报错“npm install 时报 phantomjs-prebuilt@2.1.14 安装失败” ,,查看https://blog.csdn.net/z1035075390/article/details/73247412
此处可参考https://www.cnblogs.com/thatsit/p/6347693.html(实用)
也可参考https://blog.csdn.net/reblue520/article/details/53909409中第三步
注明:
1,这里,我只配置了这一个地方就生效了,网站上还有配置hostname的,我没有配置也可以使用;
2,这里的公网ip一定要看好,阿里云的一些弹性公网ip会给两个ip地址,如果不好使,换另一个地址试试。
4,编辑elasticsearch 的配置文件,允许跨域:
vi /usr/local/elasticsearch/config/elasticsearch.yml
#head工具跨域使用 http.cors.enabled: true http.cors.allow-origin: /.*/
5,启动
npm run start &
#或者
grunt server &