ElasticSearch-head就是一款能连接ElasticSearch搜索引擎,并提供可视化的操作页面对ElasticSearch搜索引擎进行各种设置和数据检索功能的管理插件,如在head插件页面编写RESTful接口风格的请求,就可以对ElasticSearch中的数据进行增删改查、创建或者删除索引等操作。类似于使用navicat工具连接MySQL这种关系型数据库,对数据库做操作。
1、环境检查
Es-head插件运行需要node环境,确保安装有node,如果未安装,自行安装
node -v npm -v
2、安装运行
# git clone https://github.com/mobz/elasticsearch-head.git
# cp -r elasticsearch-head /opt/
3、安装grunt
# npm install -g grunt
4、安装插件
# cd elasticsearch-head
# yum -y install bzip2
# npm install
5、grunt检查
在elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行:
npm install grunt --save
6、配置修改
vim Gruntfile.js
###修改Gruntfile.js文件下参数,修改为ES服务器IPconnect: {server: {options: {hostname: '*',port: 9100,base: '.',keepalive: true}}}});
# vim /opt/elasticsearch-head/_site/app.js
# 原来是http://localhost:9200 ,如果head和ES不在同一个节点,注意修改成ES的IP地址,写成node-1或node-3的IP地址
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.65.175:9200";
7、修改es配置文件并重启es
# vim /opt/elasticsearch-7.10.2/config/elasticsearch.yml
# 如果启用了 HTTP 端口,那么此属性会指定是否允许跨源 REST 请求。
http.cors.enabled: true
# 如果 http.cors.enabled 的值为 true,那么该属性会指定允许 REST 请求来自何处。
http.cors.allow-origin: "*"
8、启动插件 elasticsearch-head
npm run start
后台运行:nohup npm run start > /dev/null 2>&1 &
或者进入到/opt/elasticsearch-head/node_modules/grunt/bin目录下启动
./grunt server &