前置环境
已经安装了elastic search
见我的上一篇【事无巨细】史上最全的elkb教程之(一)elastic search安装
已经安装了git
已经安装了nodejs
安装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