海量日志系统ElasticSearch插件管理

举报
tea_year 发表于 2025/07/31 12:49:24 2025/07/31
【摘要】 elasticsearch-headelasticsearch-head是集群管理、数据可视化、增删改查、查询语句可视化工具。从ES5版本后安装方式和ES2以上的版本有很大的不同,在ES2中可以直接在bin目录下执行plugin install xxxx 来进行安装,但是在ES5中这种安装方式变了,要想在ES5中安装Elasticsearch Head必须要安装NodeJs,然后通过Node...

elasticsearch-head

elasticsearch-head是集群管理、数据可视化、增删改查、查询语句可视化工具。从ES5版本后安装方式和ES2以上的版本有很大的不同,在ES2中可以直接在bin目录下执行plugin install xxxx 来进行安装,但是在ES5中这种安装方式变了,要想在ES5中安装Elasticsearch Head必须要安装NodeJs,然后通过NodeJS来启动Head。

官网地址:https://github.com/mobz/elasticsearch-head


elasticsearch-head安装

第1步: 下载相关软件并上传到服务器

官网有安装说明,可以通过git安装,也可以下载zip包解压安装

下载相应的软件包,并拷贝到ES集群的一个节点上(我这里拷贝到es02这台,也就是es01上)

es-head2.png

nodejs下载页面: https://nodejs.org/en/download/

nodejs下载页面.png

第2步: 安装nodejs

[root@es01 ~]# tar xf node-v10.15.0-linux-x64.tar.xz -C /usr/local/
[root@es01 ~]# mv /usr/local/node-v10.15.0-linux-x64/ /usr/local/nodejs/
[root@es01 ~]# ls /usr/local/nodejs/bin/npm 
/usr/local/nodejs/bin/npm               确认有此命令
[root@es01 ~]# ln -s /usr/local/nodejs/bin/npm /bin/npm
[root@es01 ~]# ln -s /usr/local/nodejs/bin/node /bin/node

第3步: 安装es-head

安装方法1(需要网速好):

[root@es01 ~]# git clone git://github.com/mobz/elasticsearch-head.git
[root@es01 ~]# cd elasticsearch-head
​
先使用npm安装grunt
npm(node package manager):node包管理工具,类似yum
Grunt是基于Node.js的项目构建工具
[root@es01 elasticsearch-head]# npm install -g grunt-cli
​
安装时间较久,还会在网上下载phantomjs包
[root@es01 elasticsearch-head]# npm install         

安装可能有很多错误,我这里出现了下面的错误(重点是注意红色的ERR!,黄色的WARN不用管)

es-head安装错误.png

解决方法:

[root@es01 elasticsearch-head]# npm install phantomjs-prebuilt@2.1.16 --ignore-script
此命令执行后不用再返回去执行npm install了,直接开始启动
​
[root@es01 elasticsearch-head]# nohup npm run start &


安装方法二 : (==网速特别慢导致安装时间过长的话可以尝试以下方法==)

git clone慢的话就使用下载好的zip压缩包解压安装
[root@es01 ~]# unzip elasticsearch-head-master.zip -d /usr/local/
[root@es01 ~]# mv /usr/local/elasticsearch-head-master/ /usr/local/es-head/
[root@es01 ~]# cd /usr/local/es-head/
[root@es01 es-head]# npm install -g grunt-cli --registry=http://registry.npm.taobao.org
​
[root@es01 es-head]# npm install --registry=http://registry.npm.taobao.org
当安装出现下载phantomjs软件包特别慢的时候,可以ctrl+c取消,拷贝下载好的phantomjs包到特定位置再重新安装
[root@es01 es-head]# cp phantomjs-2.1.1-linux-x86_64.tar.bz2 /tmp/phantomjs/
注意:phantomjs请改成自己的绝对路径
[root@es01 es-head]# npm install --registry=http://registry.npm.taobao.org
​
[root@es01 es-head]# nohup npm run start &

==注意: 运行nohup npm run start &必须要先cd到es-head的目录==


第4步:浏览器访问

浏览器访问http://es-head节点IP:9100 ,并在下面的地址里把localhost改为es-head节点IP(浏览器与es-head不是同一节点就要做)

es-head2.png

第5步: 修改ES集群配置文件,并重启服务

[root@vm1 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#"
cluster.name: elk-cluster
node.name: es01
node.master: false
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["es01", "es02"]
http.cors.enabled: true
http.cors.allow-origin: "*"                 加上最后这两句
​
[root@es01 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#"
cluster.name: elk-cluster
node.name: es02
node.master: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["es01", "es02"]
http.cors.enabled: true
http.cors.allow-origin: "*"                 加上最后这两句
​
[root@vm1 ~]# systemctl restart elasticsearch
[root@es01 ~]# systemctl restart elasticsearch

第6步: 再次连接就可以看到信息了

es-head3.png

插件安装:

浏览器--》扩展--》管理扩展--》

image-20250708140920511.png

image-20250708140954589.png

新建个索引试试 删除此索引

es-head4.png

es-head5.png

es-head查询验证

es-head复合查询.png

es-head复合查询2.png

es-head简单查询.png

es-head复合查询3.png

image-20250708142828312.png

image-20250708171301188.png

总结

创建索引

功能:指定分片、副本数及映射规则。
示例:PUT /<index_name>​,可定义 settings(如分片数)和 mappings(字段类型)。

修改索引配置

动态参数:如副本数、刷新间隔等,可通过 PUT /<index_name>/_settings 调整。
静态参数:如初始分片数,仅能在创建时设置2。

删除索引

命令:DELETE /<index_name>,直接移除整个索引及其数据。

判断索引状态

存在性检测:HEAD /<index_name>,返回成功表示存在。

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。