【事无巨细】史上最全的elkb教程之(二)elasticsearch-head安装

本文档详细介绍了在CentOS7环境下安装Elasticsearch、Git和Node.js后,如何下载并安装elasticsearch-head插件,包括修改Gruntfile.js以允许所有IP访问,配置Elasticsearch支持跨域,以及设置防火墙开放9100端口,最终启动elasticsearch和elasticsearch-head进行验证的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前置环境

已经安装了elastic search

见我的上一篇【事无巨细】史上最全的elkb教程之(一)elastic search安装

已经安装了git

Centos7下git安装

已经安装了nodejs

Centos7下nodjs安装

安装elasticsearch-hard

下载elasticsearch-hard插件

[root@localhost git-2.31.0]# cd /usr/local/elkb
[root@localhost elkb]# git clone https://github.com/mobz/elasticsearch-head.git
[root@localhost elkb]# ll
总用量 4
drwxr-xr-x. 10 user_es group_es  167 3月  25 13:35 elasticsearch-7.12.0
drwxr-xr-x.  8 root    root     4096 3月  25 20:28 elasticsearch-head
[root@localhost elkb]# 

安装head插件的依赖包

安装grunt
[root@localhost elkb]# npm install -g grunt-cli
修改Gruntfile.js

在connect–>server–>options下面添加:hostname: ‘*’ 表示允许所有ip访问

[root@localhost elasticsearch-head]# vim Gruntfile.js 

在这里插入图片描述

修改elasticsearch-head默认连接地址

修改 (_site/app.js)这个文件的elastic search的连接地址localhost为其服务的ip,我的时192.168.233.137

[root@localhost elasticsearch-head]# cd _site/
[root@localhost _site]# vim app.js

在这里插入图片描述#### 设置elastic search可以跨域访问
修改elasticsearch.yml
新增配置
http.cors.enabled: true
http.cors.allow-origin: “*”

[root@localhost _site]# vim /usr/local/elkb/elasticsearch-7.12.0/config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"

在这里插入图片描述#### 防火墙开着的则可以设置开放9100端口,防火墙关闭则不需要设置,最后需要关闭防火墙

head插件默认9100端口,配置防火墙允许访问9100端口
[root@localhost _site]# firewall-cmd --zone=public --add-port=9100/tcp --permanent
关闭防火墙
[root@localhost _site]# systemctl stop firewalld
切换到用户user_es,并启动elastic search
[root@localhost _site]# su user_es
[user_es@localhost _site]$ cd /usr/local/elkb/
[user_es@localhost elkb]$ ./elasticsearch-7.12.0/bin/elasticsearch
新Linux窗口,启动elasticsearch-head
[root@localhost elkb]# cd elasticsearch-head/node_modules/grunt/bin/
[root@localhost bin]# ./grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
浏览器查看验证成功

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值